instruction
stringlengths
71
95.1k
Is there any way to refactor this? public IEnumerable<Option> Options { get { { List<Option> ListOption = new List<Option>(); if (!String.IsNullOrEmpty(Option1)) { ListOption.Add(new Option() {Name=Option1 }); } if (!String.Is...
I started to play around with Hibernate since yesterday and came up with the following example of one-to-many relationship example, but I am not sure if I am doing right and I have no one around me knowing Hibernate. Please take a quick look at it, then maybe point out anything wrong. My goal is to use a one-to-many r...
I'm currently trying to prove a data structure which I've created to speed up lookups for integral keys. The specific case I have in mind has the following usage case: At start is populated with n number of items (where n can be from 1 to thousands), and the specific key is actually an unsigned int. The critical path ...
I've written a python module that randomly generates a list of ideas that can be used as the premises for furthur research. For instance, it would be useful in situations where a new thesis topic is required, either for a masters or a doctorate program. Or if someone is just simply bored with their lives and wants som...
I'm a pretty visual person and I like to see all the cool information about objects, arrays and different variables in PHP. In the beginning I would just echo '<pre>', var_dump($var), '</pre>'; liberally throughout my code. Then I was introduced to MVC and started grasping the concept of OOP and the Front Controller ...
I am currently developing a login script for my application. The login will use SSL and all required resources will be served through this. It is not protecting anything like a bank however I would like to know what is right and wrong especially for learning purposes I would love some feedback on my class that I have d...
Is this good or not? Input arguments for OsFile_Open must be in UTF8 format. #include <stdio.h> #ifdef WIN32 #include <Windows.h> #endif // Types declaration, originally they are located in header file // typedef int Bool_T; typedef signed long long Int64_T; #define true 1 #define false ...
Moved originally from StackOverflow, not knowing the existence of this sister site ... Must say I find programming in Haskell to require much more cognitive intensity than any other language I've tried. I'm not certain I care about lazy evaluation or monads very much, but I do appreciate certain functional aspects, sta...
My current setup is a 3 layered application: UI > BLL > DAL. Each layer is set up as a separate project. The UI is an ASP.Net website and the BLL & DAL are Class Library projects. I've shown some sample code from each of my layers. Hopefully you guys can critique my application design and give me some tips/pointers or ...
#region GetBookListByPriority private static List<BCBook> GetBookListByPriority(List<BCBook> listBcBook) { List<BCBook> newList = new List<BCBook>(); try { List<BCBook> listNonPriorityBcBooks = new List<BCBook>(); List<BCBook> listPriorityBcBooks = new List<BCBook>(); foreach (BCBoo...
I created a function which has, I believe, truly private variables. It's not quite production ready for several reasons: It's using Object.defineProperty -- I can deal with this It is re-defining every function in the prototype by doing eval( fn.toString() ) -- I do not like this I'm re-defining the prototypes, hence...
Could you please review the following code, and point out how I can make it cleaner, more idiomatic and easier to understand? module Cabbage ( solve ) where data Place = Here | There deriving (Eq, Show) data Pos = Pos { cabb :: Place , goat :: Place , wolf :: Place , fa...
I was wondering if someone could have a look at this BBC iPlayer style content accordion/slider I've just made, and help me to get it working properly? I'm no expert in jQuery and I'm sure I haven't done this correctly, or if there are more efficient ways of doing it. The problem seems to be the clicking. It sometime...
In response to my own question on Stack Overflow, I'm attempting a solution to decouple JavaScript and html. I'd appreciate any comments, proposed refactoring, or criticism. I have a fiddle of it in use here Here's the code: (function (window, $, undefined) { "use strict"; var ab = window.ab = window.autoBinde...
I've recently come across some areas of code in our solution that have a few thread-safety problems. Thread-safety is a minefield at best so I thought I'd have an attempt at writing a few little utility classes that would make it easier to write safe multi-threaded code. The general idea is to link a resource with the...
I am parsing a huge XML file. It contains some million article entries like this one: <article key="journals/cgf/HaeglerWAGM10" mdate="2010-11-12"> <author>Simon Haegler</author> <author>Peter Wonka</author> <author>Stefan Müller Arisona</author> <author>Luc J. Van Gool</author> <author>Pascal Müller</author>...
I've created and launched our first HTML5 site. I've done a lot of research in to the "best practices" for writing a page in HTML5 and put a majority of them to use. I was hoping someone wouldn't mind looking over the site and shouting back any comments, issues, or recommendations on it. I'm looking for anything, from ...
Due to the fact that Entity does not support Enums, I am converting them to strings, string lists, and back again. The reason is two fold: type-safety, and consistency in the database. Now, I have a bunch of these, but I will use Credit Cards as an example: public enum CreditCardName { VISA, Mas...
The program finds the largest palindrome made from the product of two n-digit numbers, where n is specified by the user. The code included works, however, when the user enters 5 or greater, the program runs very slowly. I believe it is \$O(n^2)\$ (feel free to correct that estimate if needed). I'd like feedback/reviews...
My BLL's function is like: public Categorymaster GetByPrimaryKey(CategorymasterKeys keys) { return _dataObject.SelectByPrimaryKey(keys); } // above funciton is calling function written below public Categorymaster SelectByPrimaryKey(CategorymasterKeys keys) { SqlComman...
The task is to write a function findFraction maxDen number to find a short but good rational approximation to a decimal representation of a number — problem statement on TopCoder: Given a fraction F = A/B, where 0 <= A < B, its quality of approximation with respect to number is calculated as follows: Let S be the dec...
I feel like repeating myself but i don't know how to refactor this. Linq condition is the same but property to compare is different (BookingDate ,CheckInDate ,CheckOutDate) protected void FilterByDateRange(ref IEnumerable<ViewBooking> pObjListBooking) { DateTime startDate; DateTime endDate; ...
Normally I could just declare the 'email' variable as the base class for both of EmailInbound & EmailOutbound, then cast-up to the inherited class. However, I don't think when defining EF codefirst classes you can use inherited classes, only POCOs. I could be wrong. Hence I've used the dynamic keyword. Could I use Obje...
I am developing some software that uses a pretty ancient low-level TCP/IP protocol from (I think) the eighties. I can send messages to the server very reliably, but I am a little unsure about receiving them. I cannot predict when the server will send me a message, so I have this method in an infinite loop. GetNextMessa...
public partial class CreateAdmin : System.Web.UI.Page { #region Events. protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LoadOrganizations(); } } // Save Admin and Organization Admin in db. ...
I've recently got into an habit where I've used extension methods for giving things fluent-like properties - such as the below example or as another example entity.AssertNotNull() public static class GenericHelper { public static void AssignOrThrowIfNull<T>(this T obj, ref T assignTo, string paramName) { ...
I'm currently trying to brush up on ADT implementations, specifically an implementation for a Linked List (I'm using Java 5 to do this). Is this implementation I've written for add(i, x) correct and efficient? public void add(int i, Object x) { // Possible Cases: // // 1. The list is non-empty, but the...
What I'm trying to do here is get an RSS feed and append an Enclosure XML node to each item, which has a link to a video file (wmv). Try the below code with url = "http://www.microsoft.com/events/series/digitalblackbelt.aspx?tab=rss" for eg to get the point The performance hit here consists of two parts: the LONG "for...
I'm a beginner and have written my first Python module that parses a XML file containing some events and prints them out to stdout as JSON. I would appreciate some feedback about design, code layout, best practices, what can be optimized and so on. from __future__ import with_statement import json import xml.etree.El...
Please review this: <!DOCTYPE html > <html dir="ltr" lang="en-UK"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Fahad | Just another web designer</title> <!--Styling Starts--> </script> <style type="text/css"> h1 { ...
I'm writing a function to take an anagram pair (words or phrases spelled with the same letters) and determine how you could move the letters to change one into the other. For example: Admirer -> Married The results would be something like this: [[0, 1], [1, 6], [2, 0], [3, 4], [4, 2], [5, 5], [6, 3]] The character in ...
I have some code that I've included in a project I want to release. Here is one such block: NSString *path = nil; if (delegate && [delegate respondsToSelector:@selector(toolbarAssociatedXibName:)]) { path = [delegate toolbarAssociatedXibName:_toolbar]; if (![[NSBundle mainBundle] pathForResource:path ofType:@"...
Is there any other way to do this without all the extra outside parens here? ((ScheduledTask)(scheduledTasks[intCount])).TaskIntervalType
On most my $_post data inputted on my site I use the following php: $example = $_POST['textfield']; $example = strip_tags($example); $example = mysql_real_escape_string($example); And then I would interact with the MySQL database... Is this 'secure' / 'safe'? Any major exploits to the above code? -How could I make it ...
I have written the code below and I am trying to work out if there is a more efficient way of doing it: i.e. less lines of code and quicker etc. I am also wondering whether it is OK to declare variables inside of an if ... else if statement. function test() { var x = 3; if (x > 5) { var msg = "m", state...
I'm on a project involving converting HTML code to HTML5, and I'd like some feedback as to whether my code is correct or not. Here's my stripped-down code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Page Title Goes Here</title> <!--[if IE 9]> <script src="/jsp/fileFolderPath/js/html5shiv.js">...
I am working on a Web chat application. In the app, users can run commands (such as /nick, /msg, etc) by starting with a / and then typing the command followed by parameters. For example, if someone wanted to change their username to "foobar", they would enter this in: /whois foobar However, I cannot think of a good ...
I have zones public class Zone { public string Caption { get; set; } public IList<Module> Contents { get; set; } } public class Zone1 : Zone { } public class Zone2 : Zone { } public class Zone3 : Zone { public enum Direction { Up = 1, Down = 2, Left = 3, Right ...
I just completed my first real application (command line app). It's simple, but I had no prior knowledge of Python. Everything was hit and miss, with many Python books and help from those in this community to guide me. Now, I am trying to see where I can refine my code and make things more efficient, as well as become ...
I have a situation where I have to connect to multiple schema to populate a single page. I altered our singleton db class in to help me do this. It will now destroy and re-declare itself whenever we pass a new set of db credential. Will the PHP pros mind code-reviewing this? we do not have code reviews here and this is...
I have a MySQL database with several columns and two rows of data, so far. I'm using mysql_fetch_assoc to return the data in database, but I don't know how to put it all together in a table so that I can display it in another file. Here is the code of the file that does the process (query.php): <?php // Configure conn...
I am developing a high level OpenCL binding in Haskell, and I need peer-review and testing. It currently only gets platform and device info from OpenCL. I have lots of functions that only change the returned type and the size of the type passed to the C library, but I don't know how to fix it. GitHub getDeviceInfoUlong...
I have this coding and I think it works. However, I would like to understand if there is a better way to do this. This would automatically create new textboxes or delete them based on the given selected number. <script> var OLD_CASE_NUMBER = 1; $("#cornercases").ready(function () { CORNER_CASE_LOADING(...
I've just written two new headers: one that integrates Box2D and SFML by a class called BodyRep which creates/ is a graphic representation of any body, and one that produces huge amounts of uniform shapes, as to reduce copy/pasting. Things I'm worried about: Performance: very important here considering this is based ...
How can I improve this code ? It takes an infinite time if i want to create un big maze (arguments 5000 5000 100 50 100) main.c #include <stdio.h> #include <stdlib.h> #include <time.h> #include "maze.h" /*test: valgrind --show-reachable=yes --leak-check=full -v ./dungeon 50 50 100 50 100*/ int main(int argc, char *ar...
I'm looking for a single-pass algorithm for finding the topX percent of floats in a stream where I do not know the total number ahead of time ... but its on the order of 5-30 million floats. It needs to be single-pass since the data is generated on the fly and recreate the exact stream a second time. The algorithm I ha...
Can this part of a view controller subclass be checked for memory leaks. I am not that good at finding leaks. I need this class to be able to be loaded many time over without it crashing due to memory leaks. The endgame gets called every time it needs to go back to the main menu. I want it to be able to go back to the ...
I've created the following class to persist data by serializing/deserializing objects that are sent to it. I would like to know if there is a better way of writing this class, or if my class is fine the way it is. using System.IO; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization....
I have the following type of many functions so many if condtions are there is there is any way to reduce no. of lines. enter: function(request, callback, callback1){ request.on={}; if(callback==undefined && NodeClientUI.initdata.join!=undefined){ callback=NodeClientUI.initdata.join; request.on.join=...
It feels like pagination is one of the most discussed questions on the web, which always ends up with some quick and dirty hacks on how to paginate. I want to paginate a large result set from an SQL query on a website where I use Spring-JDBC for querying and Displaytag for display. I thought about it for a while and ev...
Here's a working version of my code - http://jsfiddle.net/sambenson/g3qsa/#base How can this be improved upon? $(function(){ var box = {}, island = {}, canvas = {}; box.el = $('#box'); canvas.el = $('#arrow'); function go(el){ if(box.el.css('visibility') == 'hidden'){ ...
I am curious as to what the performance/functional differences are between: private bool OftenCalledMethod(string s) { Regex reg = new Regex(@"^matchme$", RegexOptions.IgnoreCase); return (reg.IsMatch(s)); } Versus: readonly Regex reg = new Regex(@"^matchme$", RegexOptions.IgnoreCase); private bool OftenCalled...
I've created a JQuery script to help illustrate a few points for my teaching class, but I have having trouble slimming it down. $(document).ready(function() { var red = $(".small-box"); var blue = $(".small-box2"); var green = $(".large-box"); red.hover( function () { red.addClass("s...
Yes I'm very slowly making my way through Purely Functional Data Structures. So I went through the section on Red Black Trees. What he presents is amazingly concise, except for the fact that he didn't include the delete function. Searching around didn't turn up many functional delete methods, well only two so far. One ...
Requirement: If the bookshop manager field changes from A to B, I need to email the person B saying that the new Bookshop has been allotted to him and he has to do certain activities. private void SendEmailToAllottedManager() { EmailExpress mEmailExpress = new EmailExpress(); mEmailExpress.SendEmail(Shop.Bookst...
Can you please help me with the following script? At the moment the script is taking up to 20 mins to execute, depending on the amount of data being processed (each time the script is executed, it processes several thousand lines of data). I would like to make the script more responsive. Can you tell me how I can upd...
In your opinion what is the best way to construct an object given the two examples below: Option 1: Lots of parameters private string firstname; private string surname; private Address homeAddress; private PhoneNumber homeNumber; public Person(string firstname, string surname, Address homeAddress, Phone...
http://jsfiddle.net/xkuZF/6/ function func() { document.body.scrollTop++; } window.onmouseover = function() { clearInterval(interval); }; window.onmouseout = function() { interval = setInterval(func); }; var interval = setInterval(func); Do you think that there are any better ways of doing this code? ...
I'm new to sockets and servers in general and I would like to know if I'm doing something really wrong in the following server loop for spawning threads to process requests. private static ServerSocket server; private static final Object request_counter_lock = new Object(); private static int request_counter = 0; priva...
The following code solves this problem: The 3072 characters below contain a sequence of 5 characters which is repeated. However, there is a twist: one of the sequences has a typo. To be specific, you're looking for two groups of 5 characters which share 4 of those characters. Enter the 4 shared characters below ...
The following text is an in-order traversal of a binary tree with 1023 nodes. What is the sum of the digits appearing in the leaves? How can I improve this Clojure code? It looks strange to me to have two recurs in the if. (ns fun2) (defn parse [in sum] (println "sum" sum) (if (> (.length in) 1) (let [next-ch...
$('#step-holder a').click(function (e) { e.preventDefault(); $('#step-holder div').each(function () { if ($(this).attr('class') == 'step-dark-left') { $(this).removeClass('step-dark-left'); $(this).addClass('step-light-left'); } if ($(this).attr('class') == 'step-...
This code removes repeated words from a word array (2D char array). I want to optimize this as much possible for speed. #include "stdio.h" #include "string.h" main() { char words[2000][20]; /*This array is populated by some other module. possible example of this array is given below, but in reality it would f...
I love lambdas, and functional programming etc. But sometimes I wonder if I take it too far.. public static T With<T>(this T source, Action<T> action) { action(source); return source; } public static IEnumerable<T> ForEach<T>(this IEnumerable<T> source, Action<T> action) { return source.Select(x => x.With(...
I'm using Codeigniter but this goes for any project in PHP. Let's say I have the following code in my view. I've been struggling, trying to figure out how best to indent and display PHP code within standard HTML code. ... ... <div id="subcontent"> <?php if ($this->session->flashdata('message')) { ...
I wrote a simple function that calculates and returns the maximum drawdown of a set of returns. I am trying to squeeze as much efficiency for speed out of the code as possible. I've got it down to about as fast as I can go. Does anyone have suggestions on how to write this function more efficiently, perhaps through lis...
An animation is composed of frames. I have the following class: class Frame { private: sf::IntRect rect; unsigned int duration; public: Frame(sf::IntRect rect, unsigned int duration); unsigned int getDuration(); sf::IntRect& getRect(); }; At the animation class I have the following function: void...
I am trying to express the classical TDD kata of mastermind in the most idiomatic scala I can. Here is a scalatest, test suite : package eu.byjean.mastermind import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner import org.scalatest.FlatSpec import org.scalatest.matchers.ShouldMatchers @RunWith(clas...
I am writing a piece of code which models the evolution of a social network. The idea is that each person is assigned to a node and relationships between people (edges on the network) are given a weight of +1 or -1 depending on whether the relationship is friendly or unfriendly. Using this simple model you can say tha...
Context: I wrote a simple as an answer to a problem in Unix.SE and it was suggested to me to post it here for review. A comma separated file is generated by an application. On the first column it contains a last name, on the second a first name and on the tenth column a telephone number. For each row of this csv an vca...
I'm implementing argument check in a method where one parameter is a List of LocalDate objects (from Joda-Time). I want to make sure that List contains at most one LocalDate per month. public List<LocalDate> generateAllDates(List<LocalDate> firstYearDates, ...) { } Thus, for example Arrays.asList( new LocalDate(2...
I am looking for ideas to optimize the below code for speed. I'm also looking for some good improvement in execution time. This code reads a text file. The text file has many lines of ASCII text. Then it finds words out of them (space/tab delimiter). It has to neglect any punctuation symbol in the file. Then it uses ...
I've written code to parse dollars and cents entered by the user. The value returned is the total number of cents. For example: f('$1.50') = 150 f('1.5') = 150 f('0') = 0 f('1000') = 1000 f('$12,500.00') = 12500000 functions.GetTotalCents = function (dollarsAndCentsString) { // Cast the value passed in to a s...
I have a view function that allows a user to Add / Edit / Delete an object. How does the following function look, and in what ways could I improve it? I was thinking about separating aspects of the function into different parts, but since no 'component' is more than four-five lines of code, I thought that would be a bi...
I am working on a PHP/MySQL application that uses a different time zone from the server it runs on, and neither of the timezones are UTC. I'm converting displayed times to be in the user's timezone, and am wondering whether my approach is sensible. I would love any feedback you might have. Firstly, the application's ...
I'm just refactoring some code I've come across whilst fixing a bug, but just wanted a quick sanity check to make sure I'm not missing any reason for keeping what I'm going to remove. The current code: uxButton.Enabled = ((from a in actions select a).Distinct().Count() == 1); There really doesn't seem to be a need for...
Since I'm venturing more and more into the multithreading, I now need to think about how to protect my precious OdbcConnection from breaking at random times. The project specifications: .NET-2.0 ODBC-Connection via MySQL-Connector 3.51 to MySQL 5.0 The main structure of my project in question looks like this: + Asse...
This is working as expected, except in the speed area + I need to make it more readable and shorter if possible, I probably have lot's of things I don't need :). Edit it is working now charset = dict(opening='{[(<',\ closing='}])>',\ string = ('"', "'"),\ comment=(('<!--', '-->'), ('"""', '"""'), ('#', '\...
I have two quite mutually exclusive desires - detailed logs and keeping my code clean. It appears that you can only get either of these. By "logging" I mean logging and not tracing, so AOP adepts wouldn't appreciate it. What I want to have is real description of action my program does, why it does these actions and so ...
What i'm doing I have a string with html information like this: <p> <span class="fieldText" fieldId="field-4">Some text</span> this is a test</p> My goal in the method is to create a dictionary with this value: **key** **value** field-4 Some text This is the code that i'm using to accomplish my task: public st...
I have never done anything functional before. These two functions are hideous to look at. II think the first step to do is extract the inner bits out and then map over my arrays. What else can I do to make this code a bit more functional? https://github.com/dbousamra/scalacloth/blob/master/src/cloth/Cloth.scala Specifi...
I've created this code to send a response to Flash which can be handled with AS2/AS3: <?php /** * Basic server-side API controls for Flash-PHP communication * @author Marty Wallace * @version 1.0.2 */ class API { // MySQL private $con; private $sql_hostname = ''; ...
I want to keep things DRY, so I'm trying to figure out: Is it possible to remove repetitive parameters and code from ASP.NET MVC Controller actions? eg given these Actions: public ActionResult List(string key, string signature) { GetSignature(key); // etc } public ActionResult Add(string key, string signature) { GetS...
I'm developing an application using ASP.NET MVC 3 and Entity Framework 4.1. In that application I have a lot of paged lists. Users can filter and sort these lists. This results in code like the one below. I'm not really happy with this code. Is there a better way to do the filtering and sorting with Entity Framework? S...
this is a basic PHP auth class I've put together for use with simple sites I do from time to time which don't warrant using a framework. I'm wondering if i'm separating out responsibilities all that well, even at this early stage! For example, I'm not sure where I should be filtering user input with mysql_real_escape_s...
Also, I've commented out a function I was trying to do to count the elements of an array; I realized that is not possible due to the fact that I won't be be able to return a NULL on an array. Although this part of a beginner to C exercise, I'd like to know if there is anything I can do to improve my coding. #include <s...
I need to write a function that "packs" an array of bytes (integers between 0 and 255) into a string. I also need to be able to perform the reverse operation, to get my byte array from the string that it was packed into. This needs to be done as fast as possible. Seeing as JavaScript has 16-bit strings, I packed two by...
I've got a lexer written in C++ (Visual Studio 2010, so including lambdas and a few other C++0x tricks). This is my first lexing experience, the only other source code interpretation I ever did was trivial, didn't separate parsing and lexing, that sort of thing. The grammar closely resembles C++ without templates and t...
I have written this method for converting a date time zone. How do i reduce the execution time of this method further. public static Timestamp convertTimeZone(final Timestamp fromDate, final TimeZone fromTZ, final TimeZone toTZ ){ Long timeInDate = fromDate.getTime() ; int fromOffset =...
I am new to Python and had to create a schema parser to pull information on attributes and complex types, etc. and then convert data from flat files into the proper XML format. We are processing a lot of data and I've run into some issues once we pass around 1 millions processed records. I'm looking for any suggestions...
So I have this code in my program, and there are multiple variations of it. Just looking at it, I feel like there must be a way to make it more efficient, but I can't think of anything. Just looking at it, does anyone have any ideas? Essentially, what the code does is it determines which level of the text that it is cu...
I am using XMLReader and avoided SimpleXML because I must handle a huge file and for memory issues, SimpleXML is not the ideal solution. However, even I coded the below script in SimpleXML, it gives me the result really much faster. Because speed and memory is a must for this project, is there any way to speed up this ...
this code finds if there is the string 2004 in <date_iso></date_iso> and if it is so, I echo some data from that specific element that the search string was found. I was wondering if this is the best/fastest approach because my main concern is speed and the XML file is huge. Thank you for your ideas. this is a sample o...
IList<WebSite> wsl = new List<WebSite>(); login1 l = new login1(); string q = "select Id, DomainUrl, IsApproved, Date from website where UserId = @UserId"; using (MySqlConnection con = new MySqlConnection(WebConfigurationManager.ConnectionStrings["MySqlConnectionString"].ToString())) { using (MySqlCommand ...
For some time now, I've been using a pattern which I think could be done more elegantly. I have a lot of XML files that need to be represented in a Django views. My current approach is like this: I get a XML response from an API which gives me several documents. First I define a mock class like this: class MockDocumen...
I am writing a simpel program that can basicly do the same as piping two linux commands can do. For example, ls -l | grep vars.sh, this can be done on the Linux console. I need to write a programm in C that can do the same. I think I got it working but I want to know if I am doing it rite and if there are some modifica...
I'm trying to learn scala. It's hard. I currently have a tree in the form class Node(children:List[Node], value:Int){ } I want to calculate a total cost defined by value + the sum of the totalcost of the children. My java background made me do this: def totalCost() { var total = value for (child <- children){ ...
I implemented the algorithm by Pr. Chrystal described here in Haskell so could someone please tell me: Do i have implemented this algorithm correctly? Initial calling of findPoints takes the first and second point of convex hull and the list of points on convex hull. My second question is: I am trying to solve the pro...
So, I wrote this small library for fast DOM building with API tailored for CoffeeScript I feel like the code overall can be made better/smaller/faster. I am also not particularly happy about a few functions, namely: # Parses out css classes and id from string like: # p#warning.big.yellow # => p # attr {"id": "w...
I want to make figures of a rectangle and a circle. How can I make the code more elegant? import java.awt.*; import java.awt.event.*; import javax.swing.*; class r extends JPanel { public int x1,x2,y1,y2; public static double SWITCH; public r() { setBackground(Color.WHITE); ...