All Questions

Filter by
Sorted by
Tagged with
11
votes
4answers
65k views

Different way of writing multiple click functions

I have the following .click() functions: ...
55
votes
8answers
34k views

Efficiently checking if a number is divisible by 3

I'm looking for code review, best practices and optimizations. ...
31
votes
8answers
45k views

Using a for-loop or sleeping to wait for short intervals of time

I need to wait for short intervals of time in my program, but I really don't want to include unistd.h just to use sleep, so I'm ...
22
votes
3answers
11k views

Returning status codes from business layer

This is what I've been doing so far in my business layer to return error messages to the user. ...
13
votes
1answer
8k views

Solving 15 puzzle

I'm trying to solve 15 puzzle using A* algorithm, but something really bad goes on in my get_solution() function that ruins performance. I guess there is a too much ...
42
votes
2answers
871 views

Tool for creating CodeReview questions

To download the tool and for usage instructions, see the follow up to this question Description I have realized that there's a whole bunch of code I want to have reviewed, but copying file by file, ...
12
votes
1answer
1k views

Responsive/adaptive website code

I have all these functions that work together to create functionality on a page. Is the structure of these functions OK? Can I do anything to speed this up or make my code better? I'm not exactly ...
20
votes
6answers
11k views

Optimize Conway's Game of Life

I have coded up an implementation of Conway's Game of Life and I have a performance bottleneck in it which I wish to be optimized. The main logic is in the Universe ...
8
votes
6answers
11k views

Variable declaration closer to usage Vs Declaring at the top of Method [closed]

As part of our sprints, we do peer review each others code. Here is the code that I am reviewing. ...
10
votes
3answers
3k views

Converting between data and presentation types

Below is how I'm solving the problem of converting between data and presentation types, I'd like to know if that's a good way to go about it, and if not, what would be a better way to go about it. I ...
16
votes
8answers
4k views

Project Euler Problem #4 - Palindromic number

The problem is as follows: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made ...
11
votes
3answers
3k views

Initializing immutable objects with a nested builder

I need to initialize several parameters of an object but I also wanted to make it immutable. At the same time I don't want the constructor to take all several parameters because some of them are ...
30
votes
2answers
1k views

Dynamically call lambda based on stream input

Some context: I have code that looks like this (minor issue noted here): ...
13
votes
4answers
26k views

Printing star greater symbol in Java

I need to print this in Java, but I feel that my code is too big: * ** *** **** *** ** * ...
8
votes
3answers
254 views

Toggle any application feature ON or OFF

When testing or debugging applications it'd be often useful to be able to run it without certain features like committing things to the database, saving files, sending emails, reading files, executing ...
6
votes
1answer
2k views

OOP-style FizzBuzz program in PHP

I've tried to write a configurable OOP-style FizzBuzz program in PHP for learning purposes. I hope everything is quite easy to understand. What do you think of the overall architecture? Are OOP ...
6
votes
0answers
399 views

Sieve32FastV2 - A fast parallel Sieve of Eratosthenes

I’ve created a much cleaner, better designed version to my parallel sieve. I’ve implemented most of EBrown’s micro-optimizations but also revamped the code on my own (that is not in direct response ...
4
votes
2answers
4k views

Hashing passwords in PHP

When hashing a password, I understand it is best not to use functions such as SHA1 or MD5. This function is working fine and I want to know if it can be improved to increase site security. ...
2
votes
2answers
1k views

Critique sanitized user email PHP Script

So, I have a basic 'contact us' form that i have built, and I do some jQuery checking first (that a phone number is only numbers, email address doesn't contain unneeded characters, etc), but I also ...
13
votes
1answer
2k views

Stream that opens an HTTP GET and then acts like a normal C++ istream

Needed a quick stream to get JSON objects. ...
9
votes
2answers
10k views

How can I quickly find unique list items?

I use the loop-every-single-list-item approach to filter out unique elements in a given list, which tends to be very inefficient way as a list grow in size, or as function call frequency increases. ...
8
votes
1answer
1k views

Critique Request: PHP Request-Method Class

I'm working on a general Requestmethod class which sanitizes and recasts the input of users in an automatic fashion. I've also tried to do array-access in cookies. ...
5
votes
2answers
117 views

A Simple Cluster Generator v0.2

[NOTE] This question can be depreciated in favor of version 0.3. This is a code revision of a previous post and works well. Code has been reworked to be far more clear and concise, thanks to ...
5
votes
1answer
276 views

PDF Script Tool - adds JavaScripts to PDF files

This is a Windows Forms application that adds JavaScripts to PDF files. It supports multiple files at the same time. Right now, the only supported script is a "time-stamp on print" script, but any ...
4
votes
0answers
121 views

C++ string Formatter Again Part-4

Previously asked here. The code is now available on GitHub. Since the previous review I have added unit tests. Since it is big it will come in a couple of parts. Part 1 | Part 2 | Part 3 | Part 4 ...
21
votes
2answers
1k views

Calculating Luhn-algorithm checksum digit

Today I decided to learn some basic Haskell, and for starters I made a program for calculating the checksum of a Swedish personal identification number. It uses the Luhn-algorithm, aka. ...
13
votes
4answers
1k views

Multithreaded Mandelbrot Generator

I built one of these long ago, and it got lost when I reformatted my SSD (sad day) so here is the new version. It is very multithreaded, spawning numCores - 1 ...
8
votes
2answers
2k views

Enforcing set environment variables

Context I have a node.js application that uses many other modules and libraries. Some of these modules pull details from process environment variables, such as URL's for databases, credentials, and ...
7
votes
1answer
5k views

Yii exception usage

I've never used a framework before, so I wanted to see if this fairly simple scenario was done correctly or could be improved: ...
7
votes
2answers
366 views

Prime generator for SPOJ

I have written code to solve the prime generator problem. I am given an input which contains in the first line the number of test cases, and for each test case, I am given a range and I have to print ...
6
votes
2answers
174 views

Adding links to tags on StackExchange sites

This Greasemonkey script adds links to tags on StackExchange sites which allow for activating, deactivating and ignoring favorite and related tags by using UI components. Since JavaScript is not my ...
6
votes
3answers
2k views

Efficiency of Project Euler problem 35

The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, ...
6
votes
5answers
1k views

Macro for allocation in C

As we all know, the syntax of allocating memory is a bit clunky in C. The recommended way is: int *p; int n=10; p = malloc(n*sizeof *p); You can use ...
6
votes
1answer
250 views

Comb Sort in VBA

Playing off Robust Bubble Sort in VBA and as suggested by @Henrik, I took a look at comb sort and tried to create an algorithm based on the documentation solely on Wikipedia. Basically, the first ...
6
votes
1answer
1k views

Swap items of a linked list in pairs

Here is the source of the question: GitHub Given a singly linked list, swap the list items in pairs (reconnect the pointers, not simply swap the values). For example: Before: A->B->C->D ...
6
votes
1answer
328 views

MVC - Control Module - Version 2

All models are in the model namespace and follow a naming convention. This makes it easy to consolidate control into cType() as shown below. All control passes ...
5
votes
1answer
726 views

Recursive Breadth First Search for Knights Tour

This was written as an experiment in performance, based on another question here on CodeReview. Input into the algorithm is the number of squares on one edge of the chess board, the point of origin, ...
5
votes
1answer
494 views

UTF-8 encoding/decoding

I have two functions, a collection of possible error codes, and a unit-testing framework. The parsing of a character into its unary prefix and payload is handled by a few named functions and macros <...
5
votes
1answer
568 views

Shell POSIX OpenSSL file decryption script

Tonight, I tried to write a Bash OpenSSL file decryption script. Encryption script will follow in highly similar manner, so I think it's not necessary now. Let's suppose we have an encrypted large ...
4
votes
1answer
72 views

Nisse Server: Part 3 Stream Layer

Getting close to a release of generic server. Nisse Server: Part 1 Helper Functions Nisse Server: Part 2 Socket Layer Here is the stream layer code. This basically provides a ...
4
votes
2answers
94 views

Nisse Server: Part 2 Socket Layer

Getting close to a release of generic server. Nisse Server: Part 1 Helper Functions Here is the socket layer code. This has previously been reviewed here. But there have been some changes. Socket.h ...
3
votes
1answer
218 views

Sieve32, a simple 32 bit sieve returning IEnumerable<uint> using C#

What a difference 1 bit makes! This very fast, simple sieve of Eratosthenes quickly finds 32 bit primes. It uses a memory efficient BitArray for odd numbers – but ...
1
vote
2answers
275 views

My included in every script file

Right now I'm finishing my very first web application, and I will buy my first domain name in my life shortly. My project is about a personal website that I'm going to upload every application I ...
1
vote
1answer
130 views

contact.php file

This is my contact.php file which has only 2 functionalities: Response with the default page if it is requested by the get method Process the message posted by the ...
67
votes
9answers
28k views

Implementing a Singleton pattern in C#

Is this the best way to implement this pattern in C#? ...
15
votes
5answers
111k views

Try catch statement in VBA using the standard VBA error handling statements

The code below is pretty self explanatory: just copy and paste it all into a module and run it, it provides a few use cases and many explanatory comments in the text. (It works but I'm interested to ...
28
votes
2answers
48k views

Custom iterator for a linked list class

I have made a LinkedList class. This is a singly-linked-list and I want to make a forward_iterator for this class without using ...
24
votes
9answers
3k views

Is this FizzBuzz Swift-y?

...
9
votes
1answer
13k views

K-Mean with Numpy

I have implemented the K-Mean clustering Algorithm in Numpy: ...
54
votes
9answers
12k views

Project Euler problem 1 in Python - Multiples of 3 and 5

I'd like suggestions for optimizing this brute force solution to problem 1. The algorithm currently checks every integer between 3 and 1000. I'd like to cut as many unnecessary calls to ...

15 30 50 per page