instruction
stringlengths
71
95.1k
I have created this model for Codeigniter. It's working fine, but I need to know if it can be more optimized. class Basic_Function_Model extends CI_Model { var $msg_invalid_array; var $msg_no_table; function __construct() { parent::__construct(); $this->msg_invalid_array = "Data ...
Flash messages are generally composed in the controller. Sometimes we need those flash messages to have links in them (like an undo button). How would you compose such a message? The only sane way I have found to create such messages is by a presenter that includes much of ActionView in it (in order to gain access to m...
Can this Code be any shorter? because it seems it is very long with just simple insertion of data using LINQ TO SQL public void addPatientInformation() { using(DbClassesDataContext myDb = new DbClassesDataContext()){ PatientInfo patientInfo = new PatientInfo(); patientIn...
<html> <body> <?php $username = $_POST['username']; $password = $_POST['password']; $name = $_POST['name']; echo "Doing ``"."useradd $username -p '$password' "."'' as ".get_current_user()."..<br/>"; passthru("/usr/bin/sudo /usr/bin/sbin/useradd $username -p '$password'" ); echo "finished ok<br>"; ?> <p> <a href="index....
I have experience is C#/ASP.NET, and I've done MVC in Ruby On Rails, so I figured making the jump to ASP.NET MVC would be a breeze. Unfortunately, I'm second-guessing my every decision. I'd like some more eyes on this to tell me if my way of doing things is insane. My main question is around editing an entity. My GET...
Could someone be kind enough to review this Fourier transformation, please? I'm especially interested in going about unit testing the code (I don't really know where to begin, beyond applying the fft twice to retrieve the input), and have left test functions blank. If you do spot a bug (and no doubt there are some), pl...
Problem: What is an effective design pattern to allow an end user to indirectly modify the state of data in an object based on a prioritized list of user specified modifers? Explanation : This is very general of course, but hang in there for a second so I can elaborate - I'm not a software person by trade so I don't kn...
As a learning exercise, I decided to write a script for helping me maintain my Unix configuration/dot-files under a git repository. I check out a copy of the repository in my home directory called .dotfiles, and, inside that, I have the Python script called linkify, which deals with creating links from my home director...
I am writing a shell script to sort my files by extension and unzip archives. It works in simple cases, but I haven't tested it extensively. How can I make it more robust against the set of file names that may be present? #!/bin/bash #File sorter SECONDS=0 SAVEIFS=$IFS IFS=$(echo -en "\n\b") echo "trigger took place in...
I'm worried about my own attempt at a solution for a Sphere-Plane collision testing. I originally implemented a solution I found on a mix of Game Development websites around the place, which was similar enough to the following: bool intersecting(BoundingSphere const& s, Vector3 const& s_origin, BoundingPlane const& p, ...
I use the following code: var newValue = ($(event.target).is(":checked")) ? 1 : 0; var oldValue = (!$(event.target).is(":checked")) ? 1 : 0; sendMessage(this.name, oldValue, newValue); Is there any better approach?
I'm attempting to improve my coding style by concentrating on simple and focused OOP client-server interfaces and error handling - atm in the context of designing a Blackjack game. I'm starting with the Card class that represents an individual card. I'm looking for any improvements on or flaws with my approach. #incl...
I feel that my app could be more efficient but I am not sure what else I can do. I feel like I could be reusing more. If you could give me some tips on how I could improve this, I would really appreciate it. public class Main { /** * @param args * @throws InterruptedException */ public static void mai...
I have a sort of database with a many-to-many association between tags and files. For various reasons, I decided to forgo a junction table in favor of having the left and right tables store the associated values in the tables themselves. However I've ended up writing code like this: GHashTable *tagdb_get_tag_files (tag...
As you can see from the code below, my set function accepts two types of parameters: either strings or arrays. Now, ideally I would like to be using operator overloading to handle this, but since PHP doesn't offer anything like that I am stuck with code like this. Is there a better way to write this (or perhaps a bett...
public void AddClient(Client obj){ try{ using(System.Data.SQLite.SQLiteConnection conn = stock.db.SqlLiteConnection.getSQLLiteConnection()){ System.Data.SQLite.SQLiteCommand cmd = conn.CreateCommand(); string sql="insert into Client (email,firstName,lastName,telephone,address,city,state,zip,web) val...
I'm working on a framework (partly out of frustration with Zend, and partially as a learning exercise to improve my coding). I've constructed a fairly solid library of classes for data validation, and the next step was to string them all together with dependency injection. However, I was finding it to be a bit labori...
This code is a mess due the complex nature of the job, so I'd like to know your opinions. The concept is very simple if you know what this is about, but there are some things I'm not being able to refactor.. Examples of what I want as an answer: Macroing of repetitive tasks? Declaring pointers in stack? But I also wan...
It does generate pretty decent normals but I'm not sure if I could improve it even more without losing performance. You can find the whole code here: ropp_map.h gnd.cpp What do you think about this one? Other than declaring an Epsilon constant, of course. void CalcNormals( const Vector3* pVertices, const GND_TILE_IND...
I have a large library (four packages) of data processing code that I have written over the last 12 months. I am quite new to python and would like to see if I am doing things correctly. This utility/convenience code is currently kept in a module called utils that is imported in many places (for an example, see this qu...
I have a data processing application that does some data cleaning as the first step. This is the module I import for that purpose. The only 'public' part of the api is the 'clean' function which returns a processed version of the input data. So to clean data I currently do something like this: c = TemperatureCleaner(da...
Consider the following CSV file: A; B; ; B; ; A; C; ; E F; D; ; E; E; C; ; The fields: $1: the jname. A unique id of the entry. $2: a " "(space)-separated list of incond. $3: a " "(space)-separated list of outcond. For the "link" A-B to be valid, jname A must define B as outcond, and job B must define A as incond. ...
Note that I'm using a C++ compiler ( hence, the cast on the calloc function calls) to do this, but the code is essentially C. Basically, I have a typedef to an unsigned char known as viByte, which I'm using to create a string buffer to parse a file from binary (a TGA file, to be exact - but, that's irrelevant). I'm wri...
Mostly a question on which approach would be better and when utilizing the using keyword, would it still be neccesary to close streams programatically. If an object implements IDisposable should using always be used? Link to my full answer using this sample: Stackoverflow Answer Option 1: WebClient webClient; webClient...
I try to implement a simple RLE compression algorithm as a learning task. In the first step, i need to split my source list to sequences of repeating and non-repeating elements. I've done it, but code seems to be so ugly. Can I simplify it? src = [1,1,2,3,3,4,2,1,3,3,4,3,3,3,3,3,4,5] from itertools import izip isRepe...
I have a problem to solve. My algorithm is assigning Players to Positions. On the start I have a list of about 16 positions and 4 players. The problem is to assing every player to it's closest positions so the overall distance is as low as possible. I've already done this: List players = ... List positions = ... Set po...
I needed to create a method that would sanitize DOM IDs based on the HTML 4 criteria (yeah, HTML 5 is a lot looser). Does this make sense? Did I get too cute with making it concise? Am I totally misinterpreting what a DOM id is? I presumed it meant something like <p id="annoying_paragraph"></p>. def sanitize_dom_id(can...
Super-duper javascript noob here. I'm trying to fetch public repos from GitHub, and add them to a dl. I know this won't work on every website due to cross-site scripting, but GitHub offers a JSON-P API. I'm fairly certain that I'm doing this mostly the right way (it works), but the append function looks ugly, and I'm n...
I am designing a class which (among other things) acts as a vertex in an undirected graph. #include <iterator> #include <string> class Node { public: explicit Node(const std::string& name); Node(const Node&); Node(Node&&); class iterator : public std::iterator<std::random_access_iterator_tag, ...
I'm a ruby programmer who's writing Java for university. I'd love to get some feedback on how my Java looks and how to improve it to conform with the norms. import java.util.Set; import java.util.HashSet; import java.util.List; import java.util.ArrayList; public class Cell { private Set<Integer> possibles; private...
In the following code, checkServerExists function checks if the server exists in the vector. If it does, then the new message is directly pushed in the vector, otherwise a new thread is created and then the message is pushed in the vector. I need to know whether it makes sense to write the code, as I have done. #inclu...
I am new to VB.NET and one of the functions I wrote is below. The idea behind it is to just send a dictionary and table name to the function, get the result and then return. Is this good practice or just silly? Public Function dbInsert(ByRef EntryDetails As Dictionary(Of String, String),ByRef table as String) As Intege...
Here's the exercise in brief: Consider the following file: Code: before.csv A; ; B; B; A; H; C; ; D; D; C; G; E; D; F; F; E; H; G; D; ; H; G; ; And a modified version of the file: after.csv A; ; B; B; A; H; C; ; D; D; ; G; E; D; F; F; E; H; G; D; ; K; ; E; The first field of the CSV is a unique identifier ...
I had an interview recently where I was asked to produce the traditional FizzBuzz solution: Output a list of numbers from 1 to 100. For all multiples of 3 and 5, the number is replaced with "FizzBuzz" For all remaining multiples of 3, the number is replaced with "Fizz" For all remaining multiples of 5, the number is ...
I just started programming in Python this morning, and it is (more or less) my first programming language. I've done a bit of programming before, but never really did much except for "Hello World" in a few languages. I searched around for some Python FizzBuzz solutions, and they all seem significantly more complicated ...
In current task, I'm refactoring the code of converting JSON file into SQLite database on Android device. Code compliant with Java 6. As a benchmark, grabbing the code from remote server takes ~1 second, but parsing it and saving to database takes up to 1 minute In file there is approximately 100 branches, where is ha...
I have a List<string> being stored in my cache with about 600K members. I want this to act as the backend for an Ajax autocomplete box. It's accessible through my model: public static List<string> GetProducts() { var cached = HttpContext.Current.Cache["MyApp-Products"]; if (cached == null) { ...
I have created code to show/hide data from a DB. It works, but as I am new to jQuery, I would like to know if this is a good way. HTML: <li class="devInfo"> <span class="sn_table"><? echo $sn; ?></span> <span class="last_edit_table"><? echo $last_change; ?></span> <span class="comment_table"...
This code feels like it goes through too many conversions to accomplish my goal: based on an IEnumerable of ids get those objects from a data store and set their DisplayOrder property to the position of the associated id. Is there a more elegant solution that I'm missing? public void ReorderElements(IEnumerable<i...
I'm trying to make an audio file tag editor, but I ran into some serious performance issues. Here's my method for loading files: private void LoadFiles(params string[] fileNames) { foreach (string fileName in fileNames) { string path = fileName; if (loadedSongs.ContainsKey(path)) continu...
I'm new to rails. I am using Redis instead of something backed w/ ActiveRecord. I need to validate the presence of location, categories, start_date, and end_date. I then need to check that start_date and end_date are valid dates, that start_date comes before end_date. And that location matches a regex [A-Za-z_]. A...
I tried to solve one SPOJ problem. I wrote one program in Python, however, it got accepted by the SPOJ judges, but its total execution time is 2.88s. The same algorithm used in C language having execution time 0.15s. Please offer suggestions on improving this approach. def tempPalindrome(inputString): """ Code for ...
I'm attempting to escape ampersands from a string before passing to PHP's SimpleXMLElement->addChild() for use with some SOAP webservices, but I don't want to double escape them. I'm getting these strings from a variety of sources so I can't count on them not being escaped already. &amp;amp; or &amp; should be untouch...
I have the following function for validating users facebook information against the rules setup in the database for users. Its working fine but i need to know if it can be more optimized. Few things that you need to know are: There is a possibility that particular rule would not exists in db. But if exists and does n...
I have the following loop which uses Idiorm to write to a table from a PHP Slim application: foreach($jobs->get_items() as $job) { echo $job->get_title().'<br />'; $jobRow = ORM::for_table('jobs')->create(); $jobRow->guid = $job->get_id(TRUE); $jobRow->url = $job->get_link(); $j...
I had a requirement where I need to create object using same interface but one derived class expects simple data and other array of type. Here is solution I came up with: I had two questions: As you can see I am converting IEquatable<T> into T. In my testing so far I did not see any disasters. Can you think of any fro...
In a data processing and analysis application I have a dataCleaner class that conducts a series of functions that help me to clean raw time series data. One of the problems I see in my data is that they often include large gaps at the beginning and end. This is due to the occasional corruption of the timestamp, a beha...
I had a need to isolate some long-running blocking calls in a background thread of my app. I also needed to keep this thread running indefinitely, because COM would complain if some object I created in that thread were accessed from another thread. I then needed to control what these objects did from my main UI thread,...
The code follows the requested format of the output exactly for my assignment. But, for my own personal reference, is there a better way that I could have done anything? Are there any additional tips? Maybe some simple ways that I could gold plate against exceptions or errors? I know how try, catch and throw exceptions...
I am busy creating a basic php mailer script to post to _self and email to a address. Is the script secure? How can I avoid someone clicking on submit the whole time, to spam the mailbox, with minimal extra code <?php //Mail header removal function remove_headers($string) { $headers = array( "/to\:/i", "/from...
I'm a fairly new programmer (just started yesterday!). I decided to tackle Project Euler #2 today, as I did #1 yesterday without many problems. I came up with what seems to me to be a working solution, but I feel like I did it in an exceedingly ugly way. Could anyone suggest improvements to my code and/or logic? Each ...
I've been trough a few css tutorials. I've also been using basic css for a while now. My question, How do you decide witch css to use. For instance. If you want a div box to show on the left. You can either use. float: left; or position: absolute; Another one would be, if you have a paragraph tag inside a div and yo...
I am creating a site that is very heavily relying on Ajax. To stop major spamming on my site, I decided to implement a PHP system that checks how many actions have been made in the last 5 minutes. I wrote this fairly quickly and I was wondering if there are any major issues with my code. Read the footnote as to why I c...
I've tried to write a simple timer class that could later be used in games, such as for updating the screen every second. Problem is, I read gettimeofday() was UNIX-specific and unsafe to use as well (that last one I'm not sure about). I know C has a clock() function, but it only has second precision. Is there a way to...
Let's say I want to create dynamic documentation of functions I wrote, without using the help() function (I don't want the user to care about arguments accepted by my function, nor get cluttered with other stuff like the copyright info, or other stuff that aren't functions). Here's an attempt: import inspect def foo(...
Intention: Automatically scroll the window to the top of a DOM element when the document is loaded. via JavaScript: window.onload = function(){ document.getElementById('foo').scrollIntoView(true); }; Questions and Concerns: Is there a more compact and/or smarter technique? Does this technique pose issues or po...
I wish to create a database for a webpage where users are able to add their own events to a timetable. Users will be able to decide if the events should be recurring (weekly) or not. Users should be able to query other groups of users to organize a time for a meeting. That is it. What I have so far is as follows: Users...
Here's a messy C# method used to calculate some business logic. Does anybody have any suggestions on how I can optimise this code? I'm asking in case there are bad practices, improvements or functions within .NET/LINQ which I'm missing. private static decimal GetRecurringCostEquiv(List<QuotationItemViewModel> items) { ...
Here's a trivial example: if type(length) != int: length = 16 as opposed to: try: len_mod = (length + 33) / 32 + 1 except TypeError: #recover here somehow, over-ride input? len_mod = (16 + 33) / 32 + 1 I don't need an authoritative answer, but some opinion on this approach would be fine. Some info abo...
Have some code that I wrote to parse a flat file of IP address and other junk unwanted information. Just wanting to see if there was any way to make shorter or better. #!/usr/bin/perl use strict; use warnings; #opening the access_log flat file that contains a list of ip addresses with unwanted information after, and...
This is a simple sort of array. The array (in fact I used ArrayList) is stored in default_list.txt file on server, all changes to it are made using servlets. Add.java: import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.A...
Im starting with MVC and I'd like you to see my code. Am I doing right? What can I improve in my classes? Controller class Logar extends Controller { private $view; private $modelDAO; function __construct() { $this->modelDAO = new LogarModel(); $this->view = new LogarView(); } pu...
My classmates and I were given an assignment to make a 'Paint' application (similar to Microsoft Paint). There is a color selection JSlider with a connected textbox to each. My code works fine, but it has some bugs in it. Whenever I draw a shape on the panel and change its color, the background of the panel changes t...
I am parsing a response from server, and in case it contains the fields "chunk_number"(J_ID_CHUNK_NUMBER) and "total_chunk_number"(J_ID_CHUNK_TOTAL), I want to check whether I should request another chunk or not. Not a complicated task. Yet I doubt what would be a better way to implement? Option 1 - using try catch: pr...
This is a simple Python program I wrote. I hope some one could help me optimize this program. If you found any bad habits, please tell me. #!/usr/bin/python import urllib2 def GetURLs(srcURL=""): if srcURL == "": return -1 Content = urllib2.urlopen(srcURL, None, 6) oneLine = Content.readline() ...
I'm new to C++ and decided to have a go at the spotify challenges on their website, http://www.spotify.com/uk/jobs/tech/best-before/ I have now finished but I get the feeling my code is just terrible, I'm guessing it would be very hard for someone else to read and I feel like there are much better ways to code this. If...
I have the following jQuery plugin that binds touch events and moves an element. In the functions moveMe and snap, there is duplicate code doing the same thing because I couldn't figure out how to refactor the scope of the functions to only do this once. $.fn.draggable = function(limit) { var offset = null; var ...
Can anyone help me improve my instr() function? int myInstr(wchar_t *str, wchar_t c, int start, int dir){ int pos = 0, result = 0, len; wchar_t *p1; //Left if(dir == 0) { p1 = str; len = lstrlen(str); while(pos < len) { if(*p1 == c) { ...
I have been learning PHP and wanted to see if I could make a very simple slot machine game. Everything works, but I'm sure this is not the best way to do this. Please let me know how you would do this and what I can do to improve. <?php $num1 = rand(1, 5); $num2 = rand(1, 5); $num3 = rand(1, 5); $result = $num1.' | ...
I use DMD 1.056 with Tango 0.99.9 to build a GPX document using API. I am a beginner in D language. Usage DMD 1.056 with Tango 0.99.9 is compulsory as a requirement The GPX data are here hardcoded but my intent is to write a more high level GPX builder code using appropriate API. The piece of code to refactor: module...
I'm looking for a review of my macros. I have these in the project pre-compile header. I tent to copy them into all my new projects as well, unless its a very simple project. #ifdef __APPLE__ #import <TargetConditionals.h> #endif // turn on or off different types of logging. ALog() is always logged. #define LOG_D...
I have a Queue class that is basically a single linked list. It has 2 remove methods. What would be the cleanest way to avoid duplication of the code? Only the comparisons in methods are different. int Queue::remove(const string& substring) { // Loop through the queue list size_t found; found = current_job-...
I made this little library for personal use to make javascripting faster and easier. I would like to know if there are any inefficiencies in it (in size and performance) and possibly if there is a feature you think is missing that would be useful. //PUT ALL CODE AT THE END OF THE PAGE!!!!!! THIS IS UBER IMPORTANT //do...
I would like any advice on how to improve this code. To clarify what this code considers an intersection to be, the intersection of [3,3,4,6,7] and [3,3,3,6,7] is [3,6,7]. I would appreciate any improvements to make the code more readable or perform faster. public ArrayList<Integer> findIt (int[] a, int[] b){ Array...
I'm new To C++ and decided to have a go at the Spotify challenges on their website. I have now finished but I get the feeling my code is just terrible. I'm guessing it would be very hard for someone else to read and I feel like there are much better ways to code this. Their "Best Before" puzzle asks: Given a possibly a...
I'm new to AJAX and am trying to learn by myself with a small test: It's a survey with 3 questions. I would like to know if I'm using AJAX the correct way, before starting bigger projects. Here is the question.xhtml page: <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...
How can this be optimized? char *crunch(char *s) { char *temp,buff[MAX]; int repeat,count,i,j,k; if (*s == '\0') return NULL; temp = (char*)malloc((strlen(s) + 1) * sizeof(char)); if (isdigit(*s)) return NULL; repeat = 0; for (i = 0, j = 0;i < strlen(s);) { temp[j++] = s[i++]; count = 1...
I need to receive an XML post then process all the data, and do whatever I need to do with the data. I could be receiving anywhere from 60 to 100 values. I know what all the elements are going to be, and all except one is mandatory. For billing, it could either be credit card info or checking info, so I need to check t...
I would like to be able to use it with IE8 or earlier, so I'm staying away from newer array methods. I'm not an expert so my code may not be the most efficient choice, but it works. var data = [ ["John", 2], ["Jenny", 3], ["John", 4], ["Beavis", 5]] var newarr = [["John",5]]; for (var x=0; x < data.length; x++) { ...
We are generating our data access code following this pattern: public static IEnumerable<SomeDataOutputDTO> GetSomeData(SomeDataInputDTO dto, IDbConnection dbConnection) { var queryString = @"Some SQL query"; using (var command = (OracleCommand)dbConnection.CreateCommand()) { command.CommandText = que...
A particular application may refer to a specific property in one of three languages in different contexts: in lowercase English, in uppercase English, and in Hebrew. To facilitate ease of converting one language to another, this monstrosity exists: public string translatePersonType(string personType, string lang) { ...
I've made a solution for this problem: Task: Write a program for calculation of the distance to the next space station. Algorithm: First base is located at the distance equal to SMK from the beginning of the path (Sirius in our case). The next station is located at the distance of F(SMK) from the first. Third st...
This takes in a user specified number of points then finds the two points with the shortest distance. import java.util.Scanner; import java.lang.Math; public class FindNearestPoints { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter the nu...
Problem: Find the intersection of two Object arrays without creating any new classes (no anonymous classes either) and without using any native Java classes in the solution (so no ArrayList implementations etc., but Object can be used) My solution: public Object[] handleArrayIntersection(Object[] array1, Object[] arra...
I have written a game engine for the game Reversi, also called Othello. The game engine works not exactly like the official rules. For example it is possible to place "holes" on the board, places which can never hold a stone. The game engine works fine, I have only some problems with the command line interface which in...
I'm currently working with TornadoWeb but appear to have picked up a lot of bad habbits. I'd appreciate some feedback on the code below: import tornado.ioloop import tornado.web import tornado.template #modules import auth import base import tag #pymongo import pymongo connection = pymongo.Connection("127.0.0.1", 27...
I was just looking at a standard scaffolded Rails controller spec, and tried to get it to use subject or let blocks, and failed miserably ... can subject or let tidy controller specs the same as it would a model spec? require 'spec_helper' describe ProjectsController do def valid_attributes {} end def vali...
I'm creating my first login process in CodeIgniter. I'm using the simpleloginsecure library for actual session management but I wrote the controller and model myself and I was hoping if you could see any flaws in it. My User_model Class <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class U...
I was working on a syllable counting function for a text editor(this function is accurate enough). However, I would like to know if it is possible to optimize it, it already separated into another thread, but I would like to know if there is any kind of optimization that I can do with it to make it more efficient. priv...
i am testing an application that i wrote and want to test the solution my algorithm produces to a Monte carlo solution. I use the harddisk a lot and i was wondering if there was a solution that uses writing data to a file a lot less, since it is really slowing the process down. The solutions are computed on the nodes o...
I use Ruby 1.8.7. I have a method which selects records according to the item that I pass to the method. In my opinion, the code is not DRY. Could somebody offer suggestions on refactoring it to make it shorter? def get_record (id,item) case item when "category" @temp = Category.find(id) when "status" ...
All I want do to is simply get the result of how long (in seconds) the PHP takes to process the SQL query. Am I on a right track? Is my code correct to get the result I want? <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("test3", $co...
i have 3 method which do almost the same thing,they different models to achieve the same goal.I did small refactoring but its still not looks like ruby,can we improve it? Thanks in advance. after: def get_list(id,list_name,attribute_id,attribute,locale_string) map={ "resentact" => ResenAct }, "stagea...
My problem is the following: I wrote a method, which counts words and returns a hash. There is a Ruby idiom which was found by me in some of the forums discussions, which I don't understand. Here is the whole code: text = "bla bla blahh blahh" def count_words(string) inp = string.downcase.scan(/\b[\'a-z]+\b/i).inject...
I wrote a string escaping function in C, and I'm trying to rewrite it to Haskell. The C version, along with comments explaining why it does what it does, can be found on GitHub. Here's a naïve implementation based on Data.ByteString.concatMap: {-# LANGUAGE ViewPatterns #-} import Data.Bits import Data.ByteString ...
I'm writing a simple text-based RPG in Java. I think it's a good exercise to practice OO and think about how objects should best interact. I'd be interested in hearing any thoughts! The Game class contains a single game: public final class Game { private final Player player = Player.newInstance(); public voi...
I am working on a web mapping library, that makes it possible to create a map with SVG and JavaScript. As every map shall consist of SVG and Image elements, which can be grouped in layers, which in turn can be set invisible, I need an API to reflect this functionality. I started with two classes/prototypes: Map() ...
Trying to implement something like CommandLineToArgV: template<typename InIter, typename OutIter> inline InIter CmdLineToArgvWUnescape(InIter begin, InIter end, OutIter target) { if (std::distance(begin, end) < 2 || *begin != L'"') { // ""s are required throw MalformedEscapedSequence(); } ...
Question:Write an algorithm in C to do integer multiplication without using multiplication nor division operators. Could I get a critique of the doMultiplication function? I know the rest of the code has some dumb stuff in it (like using scanf), but I'm looking for feedback on my multiplication implementation. Are ther...
Basically, I'm comparably new to Haskell, which means lacking both knowledge of advanced principles, available libraries and, maybe, some syntax. For educational purposes I hacked together a code implementing Stam-style fluid dynamics solver. For now the code is running in constant space and linear time, which is exact...