# All Questions

61,506 questions
Filter by
Sorted by
Tagged with
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 ...
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: ...
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 ...
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 ...
110 views

### Expanding a working query without adding multiple join statements?

I have the following tables set up: t_users table: ...
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 ...
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: <...
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 ...
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: ...
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 ...
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 ...
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: ...
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: ...
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 ...
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 ...
3k views

### Element-comparison NumPy matrix

I need a NumPy matrix with comparisons among all elements in a sequence: ...
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 ...
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\...
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 ...
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 ...
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 ...
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 ...
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: ...
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 ...
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 ...
594 views

### Combining multiple jQuery animations?

I have a couple of jQuery animations running in a sequence after certain resources are loaded: ...
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 ...
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 ...
305 views

...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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: ...
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: ...
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 ...
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 ...
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? ...
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: ...
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 ...
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, ...
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) ); ...
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 ...
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 ...