All Questions

Filter by
Sorted by
Tagged with
4
votes
1answer
196 views

First Common Lisp vector math code

I'm studying Common Lisp on my own. Coming from C++, Common Lisp feels kind of strange sometimes. I'd like to get some feedback on what I understood so far. For learning purposes, I wrote this simple ...
4
votes
2answers
383 views

Calculating sun rise/set time at various places on Earth

This is the algorithm for calculating sun rise/set time at various places on Earth. I took it as an example of multiple functions inside of one top function. This is Ver 0.3: ...
5
votes
2answers
905 views

How can I optimize this array.each in ruby?

I'm trying to optimize this bit of code and I thought I'd throw it out here to see if anyone has any ideas. I've been testing the performance using ...
3
votes
3answers
4k views

Recursively find all objects of type System.Web.UI.Pair in an object array

I have an object array that contains various types of objects (primitives, strings, other object arrays) at arbitrary levels of nesting. I need to pull all objects of type ...
7
votes
2answers
110 views

Expanding a working query without adding multiple join statements?

I have the following tables set up: t_users table: ...
3
votes
2answers
19k views

Student marks report

I want to display a table similar to this: This table is generated from three tables depending on the student ID: I don't want the table to depend on fixed values. For example, I should be ...
3
votes
2answers
408 views

Showing an item in a shopping cart

I'm updating and old project from jQuery 1.4 to jQuery 1.7. Can this be simplified, thus reducing the amount of code, and perhaps in such reduction, have it improved? Having the following code: <...
11
votes
1answer
6k views

Timer to poll a Delegate

This is a followup to this where I was initially using a single thread and Thread.Sleep() to poll a delegate. I was recommended to use a timer and the ...
12
votes
1answer
2k views

Hexadecimal converter using a switch statement

I need some help improving my code and wondering if I there is a better way to do the following: ...
3
votes
1answer
331 views

Finding the biggest product of two integers formed by the digits 1-9

The question was, which is the biggest product you can make from the digits of 1 to 9 (which is 9642*87531, BTW). It is pretty clear that one number starts with 9 and the other with 8, and that you ...
8
votes
3answers
5k views

Approximate String Matching Interview Question

I was working on the challenge Save Humanity from Interviewstreet for a while then gave up, solved a few other challenges, and have come back to it again. The code below generates the correct ...
2
votes
1answer
248 views

Call Action every X cycles

I want to call an Action every X cycles (in my case, to a transaction commit every 100 records), so I do: ...
1
vote
6answers
369 views

Calling a FormatCurrency function on multiple textboses

I have a function called FormatCurrency() which I would like to call on each of the following elements: ...
3
votes
2answers
1k views

jQuery Drawer with Tab

I am putting together an animated drawer from scratch for use but also as a learning experience as I am not very strong with jQuery and would really like to get better. I am hoping that someone here ...
3
votes
2answers
2k views

var that = this; Keeping a class in scope of nested functions [closed]

I've been using this syntax alot recently to keep my class in scope of nested functions. It seems to work well in small to moderately sized class but I'm starting to wonder how efficient it actually ...
1
vote
1answer
3k views

Element-comparison NumPy matrix

I need a NumPy matrix with comparisons among all elements in a sequence: ...
2
votes
1answer
814 views

Is it correct to use delegates as properties?

I need to create a class with two properties: LogOutput ExceptionOutput These properties (of type ...
3
votes
1answer
285 views

Minecraft auto-backup utility

I live in a country where an electricity blackout happens after every hour, which corrupts the Minecraft save files, so I came up with this auto backup utility which backs up the %appData%.minecraft\...
5
votes
1answer
15k views

Polling loop to run in a background thread

I came up with the idea of a small utility class that will poll some delegate until the response received meets some condition, upon which it will notify the main thread which can take the appropriate ...
3
votes
3answers
4k views

Delayed dispatcher invoke

I knocked this up quickly to allow delayed Invoke on the dispatcher. Along with canceling the existing invocation and replacing with a new one, this allows ...
7
votes
1answer
2k views

MySQLi DB library - quality/security review?

This libray was written quite some time ago, and it has so far been used in all sorts of small-ish projects. I'm about to base a more complex, security (Access Control) related, open-source project ...
1
vote
1answer
1k views

Backbone.js App approach not very scalable - nested views

I'm creating a Backbone App, and although everything seems to work i'm afraid i might need to refactor very soon if I keep adding functionalities and views with this approach. I'm using Parse in the ...
2
votes
1answer
1k views

What improvements are needed in this class to fill DropDown using PetaPoco?

Below is the class which I am using to fill multiple DropDowns on ASP.NET Page Load event: ...
5
votes
2answers
16k views

.hasScroll function, checking if a scrollbar is visible in an element

I have constructed a function that checks whether an element has a scrollbar or not, and can also check individual axes. I don't know if this works in all major browsers and am unsure about the ...
1
vote
1answer
289 views

Why my listview style change when I loop the javascript twice? [closed]

I develop an android native application using phonegap and jquery mobile. I've made a function to create a listview style dynamically using looping for... When I ...
1
vote
1answer
594 views

Combining multiple jQuery animations?

I have a couple of jQuery animations running in a sequence after certain resources are loaded: ...
5
votes
1answer
384 views

iterative copy-tree in lisp

The common lisp function copy-tree is often implemented in a recursive way, and thus is prone to stack overflow. Here is my attempt at writing an iterative version, one-pass, no stack, no ...
1
vote
1answer
80 views

Attributes with special behaviour in Python

What is the common practice to implement attributes that have side effects in Python? I wrote the following class which supposed to save singletons when a variable is going to get a certain value. The ...
1
vote
1answer
305 views

Extracting Multiple Associative arrays in PHP

...
2
votes
2answers
127 views

Can anyone improve my multidimensional array more distinctive?

What I've been working on is some kind of function that can take basically any well constructed multi-dimensional array and remove any and all duplicates within matching key sets. The particular ...
13
votes
3answers
4k views

What do you think of this improvement of Linq's GroupBy method?

Linq already has a set of GroupBy methods for enumerable, which returns IEnumerable<IGrouping<TKey, TSource>>. I dislike this return type because it ...
1
vote
1answer
553 views

Improving a shortcode replacement routine PHP and regex

I am using wordpress to allow a client to enter a curriculum vitae and have it output the correct and consistent html formatting: So I have a plain text box custom field and am having them enter in ...
4
votes
1answer
160 views

Counting the number of days worked for all commiters to a git repo

I wrote this script to collect evidence of the number of days worked for the purpose of claiming some government tax credits. I'm looking for some ways to clean it up. I'm especially wondering if ...
1
vote
1answer
243 views

Converting Bash commands into Windows cmd commands

I have the following code that converts a couple of bash commands into Windows cmd commands, as well as adding some commands. This is only my second day programming ...
1
vote
1answer
2k views

PHP Class to Represent a Type Collection

Here is my attempt at a PHP class to be used as a base class for typed collections. My goals with this are: to be able to access collection members with foreach to be able to access collection ...
5
votes
1answer
5k views

Perform SHA-256 on input

This code is intended to take input as a string, do a SHA-256 hash on the string, and return the result. It works correctly for the standard test vectors (test code included at the bottom). I'm ...
2
votes
1answer
411 views

Creating boilerplate for jQuery plugins

I've been writing some smaller jQuery plugins lately, and I've been thinking of writing up some boilerplate that I can use when writing new ones. I have code that works (for now), but I want to share ...
10
votes
3answers
16k views

Java Date formatter

The (real life) problem Following my question on SO, I found out that printing a Java Date() in a custom format is quite tedious: ...
2
votes
1answer
727 views

PHP form XSS vulnerability

I'd like to ask if this PHP/HTML code has any flaws which can be exploited by the potential aggressor: ...
1
vote
1answer
4k views

Tackling the TSP with a genetic algorithm

This is my first go at genetic algorithms, using PyGame for the visual representation. Is there a way to improve the speed of the code? Click to place a point, press ↑ to start looking for the ...
2
votes
1answer
539 views

Write a typo correction program with Levenshtein distance algorithm

I'm building a typo correction program. This is the function, which compute the levenshtein distance between two words (a dictionnary word and an input word). I will call this function many times, so ...
7
votes
2answers
10k views

File Async writer using Tasks or new features of .Net 4.5?

This code was posted as answer to Async file writer in .Net 3.5. How would it be done better using Tasks or new features in .Net 4.5? ...
2
votes
1answer
340 views

My implementation of javascript class library

I'm reading a book called JavaScript Web Applications. In first chapter, it introduces an implementation of class library. Here's an intermediate version: ...
7
votes
3answers
8k views

Console calculator

I am a newbie programmer learning some C++. One of the exercises in my book asked me to write a basic console calculator that takes 2 numbers and an operation as input. I have done so and the program ...
3
votes
3answers
813 views

Simple randomization program

I'm a few months into learning C++ programming and I want to know if I'm moving generally in the right direction or not with the following code. This is the most advanced thing I've created so far, ...
3
votes
1answer
229 views

Improving readability of 3d math in Java

Doing graphics in Java, I find myself writing lines like these regularly: Vector3f b = mid.add( a.mult(yOffset + length / 2) ).add( up.cross(a).mult(xOffset) ); ...
4
votes
4answers
923 views

Javascript A* pathfinding function for tile-based game optimisation

Below are the bunch of functions which I wrote to determine paths between give coordinates of a square tile-based game. It permits paths between tiles in 4 directions (i.e. not 8 directions/diagonal ...
2
votes
1answer
2k views

Click textbox to show answer and highlight related text

Is this JavaScript code robust? It is for an interactive book about a card game. When the reader clicks on the checkbox, an answer is revealed and related text is highlighted. I need to get this right ...
9
votes
1answer
218 views

Redundant `let`s in list monadic code [closed]

There is a function with bunch of a redundant lets and s inside a list monad. ...
4
votes
2answers
65k views

Deleting a node from a binary search tree

I have read about it at a few places and tried to write my own version. I would like to get it reviewed. ...

15 30 50 per page