All Questions

-1
votes
1answer
2k views

Calculating an employee's bonus

How can I improve this? ...
2
votes
1answer
82 views

genContent plugin

This is a plugin for inserting content, which is for fallback for CSS generated content for IE Please review and suggest optimization tips and or improvement of code. See the TODO in code and offer ...
2
votes
1answer
6k views

XECryption encryption and decryption script

The encryption script: ...
1
vote
1answer
381 views

Book catalog demo using Knockout, jQuery, and JSON

I know this is a lot of code, but I'm not looking for any kind of detailed review of the code. I'm just hoping some nice Javascript guru can give it a once over and offer any needed advice for using ...
4
votes
1answer
884 views

Single word CAS tagged pointer for algorithms susceptible to the ABA problem

I've been looking for a solution to the ABA problem for a lock-free stack. Searching the Web revealed patented and complicated hazard pointers and tagged pointers using double compare-and-swap (DCAS, ...
5
votes
2answers
586 views

just implemented multiprocessing and queue demo, wonder if there are any improvements?

i will give a list of urls, and want to make multi processes to fetch certain url's web content, and quit if all the urls are all fetched. here is my implementation, and not sure if it's the right ...
2
votes
3answers
310 views

Is “int2rgb” an OK method name?

All colors can be represented by an int, and often you want to get the individual red, green and blue values from that int. I ...
0
votes
1answer
1k views

Moving average of a data series

How can I rework the code up that ema(x, 5) returns the data now in emaout? I'm trying to enclose everything in one def. Right ...
2
votes
1answer
7k views
1
vote
4answers
2k views

STL matrix chain multiplication

Please provide positive and not-so-positive feedback on style, clarity, or any other additional feedback you would like to provide. ...
1
vote
1answer
2k views

Custom timer code needs reviewing for thread safety

I've created a custom timer to satisfy the following requirements: Millisecond accuracy I want the tick event handler to only be called once the current tick handler has completed (much like the ...
3
votes
1answer
2k views

Very slow Python Combination Generator

I have the following function: ...
43
votes
3answers
14k views

shared_ptr and FILE for wrapping cstdio (update: also dlfcn.h)

Even in the presence of <fstream>, there may be reason for using the <cstdio> file interface. I was wondering if ...
1
vote
2answers
142 views

Refactor 2 regular expressions in Javascript into 1 statement

I have the following code, which replaces " " <-- Spaces with "-" <-- Dash. Because some of the title text will be returned with more spaces, it converts it into 3 dashes. Examples of ...
6
votes
4answers
465 views

Simplifying ToString() implementation

Any ideas? ...
1
vote
2answers
874 views

Efficiently working out the nearest weekend

Is this an efficient way to do this? the code is designed to find the nearest friday, without passing Sunday. If it is already past Friday, the start date should equal now. ...
2
votes
2answers
129 views

Comparing each property to the same value

My code keeps some int value about the date range, and there is a method to check if all of it is zero. Is there a better way to do it than doing this? ...
5
votes
2answers
1k views

Optimizing a Fire and Forget page tracker

I have a bit of code that came from Egg Head Cafe a long while ago and it's been working great. But I ran the entire site through Redgate's Profiler. and it came up as the biggest hot spot in my code. ...
11
votes
5answers
4k views

T-SQL statement to breakdown UserAgent information

I have a table that contains the UserAgent string and a Count of how many times its seen. The T-SQL below is used to give a ...
3
votes
1answer
1k views

Passing anonymous functions and getting variables from an outer scope

I'm doing something quite strange. I'm trying to create a tiny system for creating templates inline in PHP, so that I can refactor by creating multiple templates in the original script, and ...
2
votes
1answer
163 views

jQuery callbacks optimization

I have a lot of repeatable blocks of code and want to optimize/simplify them: ...
4
votes
4answers
3k views

Singleton Decorator

I've written a class that makes writing singletons easy. The class is meant to be used as a decorator (example below). I'd like to see your thoughts about the code, the documentation, and everything ...
-1
votes
1answer
65 views

Localhost Mail() issues

I am trying to send mail via the mail() method, but I am doing it on my localhost, which does not appear to have a SMTP server running. I think the code is fine, ...
-1
votes
1answer
182 views

Javascript widget patterns and merging configurations

I'm volunteering some time to work on an open-data project, which I've started a repo out here for: https://github.com/0xdeadcafe/Open-Hamilton/blob/master/whereare.js The general idea is you'll ...
3
votes
2answers
98 views

Upvote distribution SEDE query

There is a 1-to-many relationship between the posts table and the votes table, and they join on ...
1
vote
3answers
14k views

Stack class in C++

Please review this: ...
8
votes
4answers
25k views

Doubly linked list in C++

Please, review the code: ...
4
votes
3answers
29k views

Circular linked list

Please review this: ...
1
vote
1answer
2k views

Lazy computation of primes in Haskell

I wanted to give Haskell a try, and I started with a simple exercise I found here. Write isPrime :: Integer -> Bool, which determines whether a given ...
2
votes
1answer
106 views

Matching and enumerating the results of a quiz [closed]

I was told that I might get some feed back about the code below. I'm learning and need some criticism. My initial question was how to save users answers and tally them up to display number correct/...
3
votes
2answers
1k views

Class library for processing credit cards

I am developing a class library for processing credit cards. There is a thought in management in the short-term future to look for a new credit card processor. So I want to write once and use ...
1
vote
1answer
3k views

Properly creating a Task to poll and dispatch child tasks with cancellation for each

I'm creating a dispatcher class - which is itself a long running task which can be cancelled at anytime by the user. This Task will poll the database to see if there is any work that needs to be done,...
2
votes
1answer
432 views

Simultaneously searching listings by attributes such as category, title, postcode

Is the code below safe from SQL injection? ...
2
votes
1answer
113 views

Using one function to go from one element to another

After I made a change to the html structure for a project, I found myself having to change many jquery selectors in many places. To avoid this problem in the future I decided to make a simple ...
3
votes
1answer
550 views

Getting an array from one property of an associative array best practice

I have an array of objects eg. [ array( 'id' => 1, 'name' => "simon" ), ... ] and I need to get an array of IDs eg. [1,2,3,4,5]; Currently I'm doing this: ...
0
votes
1answer
115 views

Better JS Contact Parser

For a site I wrote this JS contact parser. It simply reads contacts and parses links if a known service is identified. Could this be made more compact? How about robustness? (it cannot handle ...
1
vote
1answer
2k views

Javascript get item in object code

So I have some Javascript code that resembles the following: ...
6
votes
1answer
1k views

Optimizing a search for list of artists in iTunes library

I'm trying to get a list of all artists on an iPhone / iPod touch music library. The best way I've found has been to group by artists (the convenience constructor on MPMediaQuery) and to iterate over ...
5
votes
1answer
279 views

Wrapper around a Python API for creating user interfaces

I am writing a wrapper around the GeUserArea class of Cinema 4D's Python API to enable creating user interfaces using an object orientated interface. I've already ...
6
votes
3answers
3k views

FSA (finite state automaton) in Scala

I'm a beginning Scala programmer with a strong background in functional programming (ML, Haskell, Scheme) and I've just written my first Scala program. It is an implementation of a FSA (finite state ...
-1
votes
2answers
284 views

My language, gecho [closed]

I wrote a language in C, dubbed gecho. The code can be found here. I'm writing this for a purely educational reason (not for school at all) and I just hope to make ...
1
vote
1answer
5k views

Serialization/Unserialization of a list of strings - C++

Are there any issues with below implementation? Input: from STDIN, a list of strings Output: serialize to a file called "out.txt" and then unserialize into a list of strings, and output to STDOUT ...
2
votes
2answers
5k views

Passing a member function in pthread_create

I have to use a C++ member function in pthread_create. Also, the member function needs to be able to get the argument. So, I have implemented a launcher function, which with help of a launcher object ...
4
votes
4answers
3k views

File parsing code in C++

I'm processing about 3.5gb/15minutes, and I was wondering if I could get this down to a better time... Note that this is for a very specific CSV file, so I am not concerned about generality - only ...
7
votes
3answers
42k views

Sorting algorithms implemented in C++

Implemented Bubble Sort, Insertion Sort, Selection Sort, Quick Sort, Merge Sort and Radix Sort https://code.google.com/p/medicine-cpp/source/browse/trunk/cpp/sorting/SortingAlgorithms.cpp ...
4
votes
1answer
947 views

Wrapping bound methods

I've written this small class in Python that wraps bound methods but does not prevent the deletion of self. Do you have any thoughts on my code? Do you think I handle errors appropriately? Is it ...
4
votes
1answer
18k views

Linked List implementation in C++

I'm learning to implement linked list. I've implemented sorting with merge sort, reversing etc... LinkedList.cpp ...
4
votes
1answer
1k views

Javascript graph skeleton implementation

I started implementing a graph drawing application in javascript and < canvas > element, and i just wanted to hear your thought on the progress so far. I'm very open to suggestions and i'm very ...
2
votes
1answer
2k views

Optimization of region of interest (ROI) drawing in the image

I'm drawing rectangular ROI region by darkening the area outside of it as in this image: But image.MakeTransparent takes too much time. What is the best way to ...
2
votes
1answer
1k views

BFT/DFT/Topological graph implementation

I am trying to learn graphs and implement in code. Can you please review my code and give me feedback? Source code ...

15 30 50 per page