instruction
stringlengths
71
71.9k
I wrote a script that moves files older than two days over to a network share (via scheduled task). Windows Task Scheduler doesn't seem to like the script so much, but it works well by itself. Is there a faster way than what I have? Is there a way to programmatically make it a scheduled task or service of some type? ...
Important fact: the number of the input is greater than 1. How do I use this fact to speed up this solution? public class subSetSumR{ // Solving Subset sum using recursion public static boolean subSetSumRecur(int [] mySet, int n, int goal){ if (goal ==0){ return true;} if ((goal<0)|(n>=mySet.length)) ...
Based on the reply of this question I have created the following code. I need to check whether it's good or not. Here is my entity class: public class Employee { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string Designation { get; set; }...
I have a collection of phrases in a List. Each phrase is a String Array where each element in the array is a word. I create a List<Entry<String, Integer>> which holds the words as keys and the times used as value. Everything is sorted by value in descending order. Then what I do is print the top X words that were used...
Below is a simple Trade class with minimal business logic: primarily a method to get market value associated with the trade. But the trade needs the following pieces of core functionality, orthogonal to any business logic: Need to be serializable to/from JSON (toJson/fromJson) Need to be sorted in lists by date (compa...
JavaScript's setTimeout() and setInterval() are evil and not precise: Both functions have a delay of a varying quantity of milliseconds. Both functions are very resource-intensive because they execute several times every second. A new alternative is window.requestAnimationFrame(), which is less resource-intensive, di...
I feel like just because the below works doesn't mean it is correct, I want to improve it but I can't really figure out how. Besides the fact it is down right ugly I feel the performance could be increased a lot also. Am I even using the Entity Framework and/or LINQ the way it is supposed to be used? So I have these cl...
I needed a super simple parser to get HTML attributes and their values. I didn’t want to load a big library or anything so I made this. I realize I am making assumptions here, mainly: Attribute values will be surrounded with either single or double quotes. The input string will end with > or />. Besides those assumpt...
A manager for a speedy async saving objects to isolated storage, using serialization from Newtonsoft.Json. A project to play with is here. public static async Task<T> ReadJsonEx<T>(String filepath) { if (String.IsNullOrEmpty(filepath)) return default(T); return await await Task.Factory....
I just wrote this short little program to increment up the build number for my projects every time I build them. After compiling this exe, I just call it in the pre-build command line. I did take out the filename string because I used it thrice, and I figured I'd get some flack if I didn't. static void Main() { int...
The goal here is to create a Top Level Menu that automatically pulls child pages without the need to manually add them to said menu. I didn't know any other way to accomplish this without a walker, of which I'm not very familiar with. I was playing around with it and was able to get the submenus to work with this. The...
Here is another portion of the same program that I would like optimizing (85-95% of the time running the program is spent within this class!!!) so that it runs faster, especially for users who have less powerful computers. Any optimizations for this section of the code would be greatly appreciated! I have done my best ...
I am trying to make this code that creates accounts in a cpanel/whm account more secure. Could someone please let me know what needs to be done to make this more secure? <?php /////// YOUR WHM LOGIN DATA $whm_user = "username"; // reseller username $whm_pass = "password"; // the password you use to login to ...
Looking for help refactoring the following code to follow a Functional Programming paradigm. The first function builds a configuration object with default settings and optional presets, while the buildResourcePath will assemble a URL for the image service. getSizedUrl and getSizedSkuUrl returns a URL that will be used ...
I have a question regarding a program that is to run an alarm clock and display the time (HH:MM AM/PM) and also trigger the alarm and display "ringing" at 12:00 AM. I am a beginner in Java and I am a little lost. I believe I have most of the skeletal work done. This is much like another question asked on here but I cou...
Please be super brutal, and treat this as a top technical interview. Worst case analysis: \$O(n)\$ (please confirm) Space complexity: \$O(n)\$ Problem: Given an absolute path for a file (Unix-style), simplify it. For example: path = "/home/", => "/home" path = "/a/./b/../../c/", => "/c" Corner Cases: Did you consider...
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital. The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplicand, multiplier, and product is 1 through 9 pandigital. ...
Some recursive code is part of a particularly slow path of a project. Out of curiosity I was playing around with reimplementing the code using stack context iteration instead of recursion. Below are snippets reduced to just the iteration patterns of tree elements using a DOM structure for simplicity. I was surprised w...
I am creating a converter for use in a Windows 8 XAML app (MVVM). As you can see in the code below, the converter is used to convert a bool into one of two strings from a language resource file. My question is, is it better to create one instance of ResourceLoader for the converter class or should I continue creating ...
I somehow acquired the idea that I should reduce the number of trips to the database as much as possible and so I use a lot of very long queries. For example, I had a function that does this: $shelf = get_shelves($shop_id) foreach($shelf) { $weight = get_weight($shelf); } Everytime a user "view shop" it will list...
Recently, I wrote a Sudoku solver in C++. My program is very hard and was solved in a few seconds. In my opinion, this is slow. #include <iostream> #include <conio.h> #include <stdlib.h> #include <time.h> using namespace std; int tab_in[9][9] = {{0,0,0,0,0,0,0,1,0}, {4,0,0,0,0,0,0,0,0}, ...
The title is somewhat a misnomer; my apologies. The goal of the procedure is to partition a range of first, last by mid for the postcondition max(first, mid) <= min(mid, last) The actual code (best_n.h): #include <algorithm> #include <iterator> #if !defined(BidirectionalIterator) #define BidirectionalIterator typenam...
private void log(MethodExecutionArgs args, string message, LogLevel level) { var calling_ip = ((System.Web.Services.WebService)args.Instance).Context.Request.UserHostAddress; string method = args.Method.Name; LogEventInfo logInfo = new LogEventInfo(level, logger.Name, message); logInfo.Prope...
I find myself frequently trying to build up Seq's based on some conditionals, but the code I end up with feels verbose and clunky. An example: def generateSeq(foo: Option[String]) = { Map("bar" -> "baz") ++ ( if (foo.isDefined) { Map("foo" -> foo.get) } else { Nil } ) } If it were Python, I would...
Please verify security from SQL injection attacks. homepage.php <html> <head> </head> <body> <ul id="list"> <li><h3><a href="search.php?name=women-top">tops</a></h3></li> <li><h3><a href="#">suits</a></h3></li> <li><h3><a href="#">jeans</a></h3></li> <li><h3><a href="sear...
I have defined some DataTemplates are similar. The templates are like this: <DataTemplate x:Key="DefaultCellTemplate"> <TextBlock Text="{Binding Value}"> <i:Interaction.Behaviors> <beh:AddErrorButtonAdornerToControlsBehavior DoOnButtonClick="{Binding RelativeSource={Relative...
I’m trying to improve my code’s "signal to noise ratio", hence would appreciate any tips on improving this, what appears to be smelly code. Perhaps there could also be potential performance improvements to be made here: public class PricingInfoDto { [DataMember] public decimal ListPrice { get; set; } [Data...
I have implemented quickly the quick sort algorithm in JavaScript using prototype based style. The code is rather short (http://jsfiddle.net/b8mfY/): <script> "use strict"; var Sort = function( inputArray ) { this.arrayTest = undefined; this.init( inputArray ); }; Sort.prototype.init = function( inputArray ) ...
Background I'm using MS Exchange 2013 in my environment, and have a separate siem box which analyze logs produced by different systems (i.e exchange). The logs for Exchange are internally stored and can however be extracted such as Get-MailboxAuditLog -Identity test-mailbox-1 -LogonTypes Admin,Delegate –ShowDetails -...
I've realized JS callback hell and I started looking into Promises libraries. After reading some articles I decided to start with BluebirdJS. I didn't realise how to properly use them yet, because documentation written with API examples, not real usage. I have two files (NodeJS environment): #monitor.js Promise = requi...
I have written a few simple-to-be-used methods in Java 8, and am wondering what could be improved upon those: public static <E, R, C extends Collection<? extends R>> C transform(final Collection<E> collection, final Function<? super E, ? extends R> mapper) { try { Objects.requireNonNull(collection); ...
Inspired by this question on Stack Overflow, I've attempted to code such animation, mostly to get some more practice with async, promises and Q.js: (Live demo) function addOutput(s) { $('<div>').text(s).appendTo(wnd); //return Q.defer().promise; return Q.delay(100).then(function() { return addPrompt(); }); } fun...
I have made an any class in C++, base loosely on boost::any, but written differently. I am checking to see if I have done it correctly and that there are no mistakes in it: class any { public: any() : dt(new data<void *>(0)) { } template<class T> any(const T &value) : dt...
I have a long command that I am building with shovels (<<), with the intention of eventually running system(command). I'd like to log the command string, to make sure it is built properly, right before I execute the command. However, the command has to contain account credentials that I don't want to log. I'm looking f...
Which one is more verbose? private bool? _hasChangesToReconcile; public bool HasChanges() { if (!_hasChangesToReconcile.HasValue) { if (Model != null) { using (var broker = _documentBrokerDelegateFactory()) { return broker.Value.HasSectionChanges(Model.I...
Here is my Python implementation of a simple fractions class: class frac: def __init__(self, a,b): self.a = a self.b = b def __add__(self, x): return frac(self.a*x.b + self.b*x.a, self.b*x.b) def __mul__(self, x): return frac(self.a*x.a, self.b*x.b) def __sub__(...
I want to print a lot of the same characters and I don't want to use a for loop and I'm also looking for a way to do it as less lines as possible. Even better I would like to be able to store that string in a static variable to use again and again. This is how I currently do it (ugly but at least no for loop): System.o...
Please help me to simplify the script below. It has a lot of variables and a lot of values are getting assigned to them. Can I make it simpler? It has to calculate the percentage of 3 test forms: pre, post and final. DECLARE @tablefinal TABLE ( RowID1 INT IDENTITY(1,1), _CourseIDD int null, _courseName va...
I am building a new system that is using some tables from an old system. For each user on this new system, I need to go to the old system and total up their sales. Currently it takes between 2-5 minutes to load. public static List<DailyTeamGoal> GetListDailyTeamGoals(int teamId) { string teamGoal = ""; List<Pr...
I use 'GROUP_CONCAT' to get comma separated lists of a person's educational background. Included in those lists are the type of degree, major, issuing establishment, and year received. degreeType is a required field and cannot empty. Prior to looping, I split the lists into arrays, like so: $degreeType = explode(","...
I wrote a Player package in Go. It builds correctly, but I would love a review on what I did and did not do "the Go way". I'm new to coding in the language, although I've gotten about halfway through Ivo Balbaert's "The Way To Go". The code consists of a struct and a bunch of setters and getters for the struct. packag...
I'm pretty new to Go, and I do not know the best or idiomatic ways to do most of the stuff, so I'd appreciate feedback on how to make my code better, faster or more idiomatic. My program is a set of methods/functions to parse an infix notation expression then convert it to reverse polish notation using Dijkstra's Shunt...
Here is my solution to Project Euler 23: Non Abundant Sums. I know I'm doing the Divisors function brute force, but I can't seem to get it to work any other way. Any improvements are welcome. #include <iostream> #include <vector> //Calculates divisors void Divisors(unsigned number, std::vector<unsigned> &result){ ...
In an effort to rid my code of jQuery, I wrote a custom global event management/handling system. I was expecting this to be hard as, from what I've read, most people don't create their own. It's far simpler than most libraries I've seen. Is there a flaw in this method? What are the benefits of using something like Even...
I'm implementing some basic algorithms in Go as an introductory exercise. Here are four different algorithms to find the Nth Fibonacci number. I'm looking for general feedback, but I'm specially interested in the Go idiom. Are the algorithms implemented idiomatically? If not, how can I correctly use the Go idiom to imp...
I have been teaching myself Python 3. I watched a video on YouTube entitled "stop writing classes". The Gtable class doesn't even have an init function, so I can't help but wonder if I should have done something different. Also as someone teaching themselves a language for the first time I would really appreciate any c...
This is intended as something of a comparative study. I'm including not just one, but two separate implementations of code to implement the Project Euler problem to sum the even Fibonacci numbers up to 4,000,000. The first is a very C-like implementation. The second attempts to make much more use of modern C++. To do s...
I just made a working implementation of calculating a string's length, but I'm not exactly sure it's the most efficient way. I divide the string up in blocks of four bytes each (32 bits), and add 4 to EAX. Once I hit a completely NULL block, I roll back the count of EAX by 4 bytes, and then calculate the final block's ...
Please review this code. import java.util.Scanner; import java.util.* ; public class LMComplex { Scanner name = new Scanner(System.in); Scanner age = new Scanner(System.in); Scanner gender = new Scanner(System.in); Scanner height = new Scanner(System.in); String usrname; String usrage; String usrgender; Double usrh...
I have code below which is set to check the date of DateToComplete, and if the date is 2 weeks or more ago, change the status of Complete from 3 to 2. Is this the best way? USE [DB] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO Create PROCEDURE [dbo].[spChanger] AS BEGIN Execute ('UPDATE [TblActions] SET Compl...
I am learning PDO. I have a class - User... class User { protected static $table_name="users"; public $id; public $first_name; public $last_name; public function pdo_create() { global $handler; $sql = " INSERT INTO users (first_name, last_name)"; $sql .= " VALUES (?, ?)"; ...
I wrote this script as a way to backup and/or download quickly a set of repos or gists from a user. I don't have any major concerns but I'm a noob at bash scripting, and I've been scouring the internet putting these pieces together. I would love for someone to take a look and let me know best practices or problems th...
I have written some code to track buffs as a side addition to the popular game League of Legends. My code is incredibly repetitive and I also have the issue of not being able to track multiple buffs, although that might not be on topic for the question so feel free to not consider this when answering. import java.util....
I'm pretty new to Perl (and multithreading), so I was wondering if someone would be willing to take a look at my script and give me any tips on increasing performance. Motivation The script is designed to build several hundred C++ components, using multiple threads (one per component) Design At a high level, the script...
I am receiving the JSON from WebService and populating ExpandoObject from this one: var converter = new ExpandoObjectConverter(); var jsonObject = JsonConvert.DeserializeObject<ExpandoObject>(json, converter); The JSON object is quite complex and in order to find the value I am doing this spaghetti code: KeyValuePai...
I am currently developing a touchless lightswitch via a Raspberry Pi, an ultrasonic module and a nice radio module. However, I am quite a beginner in Python and it was a hard time (at least for me) to accomplish my goal. Whenever the measured distance is falling below the limit the switch is triggered "on" (1) and afte...
The old code I had before was atrociously slow but after some advice and research I was able to take a 2-5 minutes run time down to about 5-30 seconds. That is acceptable, but still looking to have it run as quickly as possible. I'm still cleaning it up, like there shouldn't be two seperate PP entities calls. public ...
I have a data structure that uses a Dictionary<ID,TimeSeries> to hold time series for different products. TimeSeries is implemented as something holding an array of Point, which contain a DateTime and a double. Its interface is: TimeSeries{ int Length{ get; } Point ElementAt(int index); DateTime StartTime ...
I asked a math question and was hoping someone could have a look at the code for me as well. Unfortunately you might have to go look at the original question here. protected void ButtonCalRetire_Click(object sender, EventArgs e) { double FVc = 0; double FVd = 0; double PV = double.Parse(TextBoxCurrentSave.Text); double...
I am trying to process an audio library file which is about 350 KB. My application processes each song on the file gets its meta-data and displays it in a List Box. The problem is that it takes too much time (about 1-2 mins). I need to make it faster like in the Windows Media Player. I tried to make it faster by savin...
At the moment is my code secure for SQL injections and so forth? I still need to hash passwords and make sure fields are valid and so forth. <?php try{ $handler = new PDO('mysql:host=localhost;dbname=s','root', '*'); $handler->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e){...
I am not sure if I should be using recursion or not or if it even helps in increasing the performance of my algorithm. I feel as though I am creating and replacing too many arrays by calling my inner rotate() function. Should I add a check to convert rotation -270 to 90 and vice-versa so that I am rotating less often? ...
I understand that account details should be stored using a much more secure method, but this is only a demonstration script I've made to store login credentials and remember a user wishes to remain logged in using localStorage rather than sessionStorage. Could anyone show me how I might write this more efficiently plea...
Recently I had someone describe a "Time Machine" service to me; that is, a service that could be used to change how a chunk of code perceives time. Normally through calls to DateTime.Now and other DateTime statics, time is directly tied to the system clock. A Time Machine service is used instead of the static DateTime ...
I've implemented the following nub' or "give distinct elements of list" function: nub' :: (Eq a) => [a] -> [a] nub' [] = [] nub' xs = nubHelper xs [] nubHelper :: (Eq a) => [a] -> [a] -> [a] nubHelper [] acc = acc nubHelper (y:ys) acc = if(contains y acc) then nubHelper ys acc ...
This code basically saves an uploaded file to the server. I am wondering if there is anything that I can do to tighten this code up. I am very new to F# so I'm still having trouble breaking away from the C# way of doing things. /// Create file paths /// Returns a tuple (server path * link path * file number) let crea...
I was a TA for a first-year Java programming course this year. As a very simple example of iterables/iterators, I wrote the following code for the students. I am curious if any styling or other improvements can be made. import java.util.NoSuchElementException; import java.util.Iterator; public class Range implements I...
I'm trying to implement a template that takes a container as parameter. The template has a getnext method that cycles through the elements in the parameter. Take note that I'm not using C++11. Header: #pragma once template<template<class, class> class TContainer, class TObject> class cycle { public: explicit cycl...
If I have a number of different classes which manage certain tests. At the moment I have to launch each test individually which results in a lot of if statements. I wonder if there is a way of putting all of these in a loop to manage the launching of each test and retrieving of results more cleanly. Does anyone have a...
I have written a Java class to replace text in file. The file contains database configurations and is as follows: test.properties #local db.url=jdbc:oracle:thin:@localhost:test #db.user=testa #db.password=testa db.user=testb db.password=testb #db.user=testc #db.password=testc # is a comment character. Now db sche...
I wrote this code to handle logged in users. The session IDs will be stored in cookies. I would like to know if it's usable or if there are security problems. It uses a 64bit id and another 64bit validation ID. Perhaps this is a bad idea, but here's what I thought: if someone tries to carry a brute force attack and hap...
I had a rather large method in one public class that I refactored into 2 helper classes. The thing is though, that those 2 helper classes have dependencies. I refactored them into helper classes so I could mock and test them easily, which worked out perfectly. However, the thing is I don't want to have to register my h...
Resharper complain if you have code like this: border-width: 0px 1px 1px 0px; and insists that units should be removed from zeroes as they are redundant. They are redundant, that is absolutely true, but I don't like inconsistency that is introduced by removal of units. You get code like this border-width: 0 1px 1px 0;...
Problem: The fraction \$(\dfrac{49}{98})\$ is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that \$(\dfrac{49}{98}) = (\dfrac{4}{8})\$, which is correct, is obtained by cancelling the 9s. We shall consider fractions like, \$(\dfrac{30}{50}) = (\dfrac{3}{...
When it come to security I try to be to better as possible but I don't have the knowledge. According to what I read on-line my following code should be good but I could use some of your comment/critic/fixes Here is a simple class just to example how I would do a login. Does it look secure enough? class UserClass { pri...
Using this question as a base, and using some of the advice in the answers, I wanted to build out something that would be generic, thread-safe, and easy to use for at least one current and several future projects. The idea is to be able to call one function, passing a key and passing another function to generate the da...
I'm using the following structure: class Map { public List<List<Point>> points; public List<Base> bases; } Point and Base are over-normal sized classes (has more than 30 attributes). And I'm iterating this Map class like this: public static void calculateMatrix(Map map) { LineOfSight.LineOfSight los = new...
Should the following GetPhysicalFileLocation() method in the Car class have its own Service Layer? public class Car { public int id; public string model; public int year; public IList<Pic> lstCarPics; } Then we have the respective class: public class Pic { public string filename; public string ...
I've been working with PHP for a while now, but unfortunately haven't delved into the OO side of it until recently. I've been reading up on separation of concerns and OOP best practices, and I think I have an idea of what is expected, but there's always room to improve. At any rate, is this heading in the right direc...
Another piece of Roslyn-based code, this time a CodeFixProvider. I'm looking for feedback on Roslyn-specific code: Am I using the SemanticModel correctly? Are there any codeflows I have overlooked that might cause issues? Am I violating any best practices I'm unaware of? etc Analyzer namespace DiagnosticTools.Colle...
I'm new to OOP PHP and I created a simple input helper class. And was wondering if it's good? Are my dependencies good? Also the reason I'm not throwing an exception with the get method is that I will mainly use this class for form validation purposes. I'll take any suggestion for improvement! class Input { private...
I don't know that my title describes the code I want reviewed. Hopefully the code is explanatory. I have an abstract parent class with two children. The parent listens to some hardware notifications and, when the appropriate hardware is connected/removed/fried in butter etc.., raises an event to its children who perfor...
I have implemented stochastic gradient descent in matlab and I would like to compare my results with another source but the error I am getting is higher (I am using squared error). I am worried I am misunderstanding the algorithm or have a bug. I have done trial and error parameter tuning, and am quite confident I have...
This gallery uses the Orbit gallery from the Foundation framework (version 3). I've set it up so that on smaller screens it appears as an accordion. It works just fine, but is there a more concise way this could've been written? Perhaps in an object oriented way? The script: function activateSlider() { if (window....
Given a "folder" which contains many "files," each file contains a time-table of trains, which stations they halt on and what time, per day. File-1 for day-1 Train1 [station1, <1 - 3> ] [station2, <5 - 6> ] Train2 [station1, <10 - 12>] [station3, <15 - 18>] File-2 for day-2 Train1 [station1, <11 - 4> ]...
I have to update a class property with the method name and then call a method that executes some code based on this property. The code is the same in both methods, but I am not seeing a way to remove this code duplication. I am trying to avoid using a parameter. public function register(){ $this->operation = __FUNC...
from time import time def baseRandom(): return hash(str(time())) def randFromZero(maximum): return baseRandom() % maximum def randRange(minimum, maximum): return randFromZero(maximum - minimum) + minimum I ask what's wrong because it seems so simple and stupid. This is something I just thought up one da...
I've benchmarked my program, and have discovered that the single function taking the most time is the one that does the following. Takes string that is a delimited list, and splits it into individual strings (Within the program, the individual strings are called statements) Looks at the individual strings, compares th...
Background information I've been asked to write a little Perl script that allows genomic data to be screened against reference files in order to determine locations of specific mutations. The input file format look like this (information are tab-separated). In the script it's referred to as Funestus_NON_SYN.txt. KB6693...
I have finally finished creating my first real project. It's just a simple music player that can provides the user with the latest music from any site (as long as it contains MP3 files) he provides in the settings file. It can play it, download it and has an simple settings file from which the user can: add/change si...
\0 / \ a b-a-t-s /|\ m s t which contains [am, as, at, bat, bats] The goal I'm trying to reach is to iterate through the trie to find if there's a next word or not, then if so get that word. I would like to know your opinion on my approach. The goal for this is that, at any point in the trie if there is a nod...
Please treat this as a interview at a top tech firm, and share your thoughts on how you think I did. Be honest, and leave no stone unturned. Problem: Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: Only one letter can be changed at ...
I'm wondering what the best way of initializing variables so that I don't over use the garbage collector with a for-loop. Assuming the variable is only used inside the for-loop. Is it better to declare the variable outside of the for-loop? public void foo() { String tempName; for (Person person : personList) ...
Write a function that takes two parameters: a String representing a text document an integer providing the number of items to return Implement the function such that it returns a list of Strings ordered by word frequency, the most frequently occurring word first. Runtime not to exceed \$O(n)\$ I decided to use a ...
From the command line, I can easily find the path to rubygems.rb $ gem which rubygems /usr/lib/ruby/1.9.1/rubygems.rb and from a Ruby script I can also do this require 'rubygems/commands/which_command' wc = Gem::Commands::WhichCommand.new puts wc.find_paths 'rubygems', $LOAD_PATH However is a simpler way available to...
145 is a curious number, as \$1! + 4! + 5! = 1 + 24 + 120 = 145\$. Find the sum of all numbers which are equal to the sum of the factorial of their digits. Note: as \$1! = 1\$ and \$2! = 2\$ are not sums they are not included. I can't figure out a fair way to optimize the upper bound from the information given in t...
So, generally when I write iOS code, I will start with a lot of calls to NSLog, which is a macro that with print the string you send it to the console. There's a few problems with this. First of all, whether you know it or not, you can see what's being printed to an iOS device's console even on apps you downloaded from...
I wrote this program to match square brackets as part of a Brainf**k interpreter. I'm aware that it gets caught in an infinite loop if brackets are entered like this: ][. Are there any performance improvements I can make? Should I change any variable names? Are there other syntax errors that will break the code? How c...
In the last 2 years or so, I've learned a great deal about how to write better Scala code, but I know that I've barely scratched the surface. This is part of a library that I've been using. It has evolved a great deal since the first version and I'm curious to see how many mistakes I'm still making. I am particularly c...
I'm creating a Space Invaders game, and graphics sprites in it are defined as 2D arrays of colors. It seems like it's going to be cumbersome declaring these arrays the way I currently am: //This creates an inverting red/blue cross animation public Sprite myFirstAnimation() { Sprite frame1 = new Sprite(new Color[,]...