All Questions

Filter by
Sorted by
Tagged with
32 votes
8 answers
20k views

is_numeric_array() is missing

I found that in PHP (or I probably can't find it) a proper is_numeric_array($array) function is missing. So I created one. The problem is that I don't think it's ...
user avatar
  • 856
9 votes
1 answer
446 views

Database method to query

I have a database class that in __construct() initialize a PDO connection and insert the instance into a $db private var. Now i'm working on a method that can be ...
user avatar
  • 856
33 votes
3 answers
16k views

Administration Elevation

I'm looking into Administration Elevation and I've come up with a solution that seems like it's perfectly sane, but I'm still in the dark about the professional methods to accomplish this. Is there a ...
user avatar
  • 1,186
8 votes
1 answer
708 views

Build menu from MS Word XML

I've recently assembled some jQuery that allows a user to build out a bulleted list in MS Word with hyperlinks and turn that into a HTML unordered list. Ideas for uses are website menu systems where ...
user avatar
  • 673
25 votes
3 answers
869 views

Music info model

I'm learning Django as I go. I know this model is missing user authentication, registration, comments/comment threading, and voting. But this is my starting code for my model. What are some of the ...
user avatar
  • 1,061
77 votes
8 answers
224k views

Getting/setting default values from my App.config

Imagine that I need a color palette for my Winforms application to have a consistent look. What I did was create a static helper class and helper methods that I can call from anywhere in my code, and ...
user avatar
21 votes
3 answers
16k views

Determining if a connection has been made to a communications device

I am unsure if my use of Monitor.Wait and Monitor.Pulse is correct. It seems to work alright, but there is a nagging doubt I am ...
user avatar
  • 343
21 votes
3 answers
4k views

Converting from polar coordinates to rectangular coordinates

This is performance critical. I measured and determined that using the sqrt is faster then using the cos method. I am aware ...
user avatar
  • 873
9 votes
5 answers
955 views

Update grid from source hierarchy

In this question I answered with this Linq. While it does what I was looking for, I am not sure how easy the linq queries are for others to follow. So I am looking for feedback on formating, what ...
user avatar
11 votes
5 answers
2k views

Simple ASP.NET C# class design

Here's a class I'm designing: ...
user avatar
13 votes
1 answer
2k views

ExtJS Grid Plugin

The code below is a plugin I wrote for Ext.grid.GridPanel, which basically allows you to have a bit more control over how rows are striped in the grid. By default ...
user avatar
  • 528
9 votes
1 answer
726 views

Parsing a game file

Note: This file is out of my hands. I cannot change the format or type of file I have to parse. Here is some sample data that I'm trying to parse. This is information for just one player: ...
user avatar
17 votes
7 answers
2k views

Parsing a file for a game

Is this code good enough, or is it stinky? ...
user avatar
25 votes
5 answers
46k views

Use of a regex stored inside a YAML file

I installed settingslogic and in the configuration file I put the regex for the email as follows: ...
user avatar
  • 785
45 votes
7 answers
2k views

Instantiating objects with many attributes

I have a class with quite a few attributes, most of which are known when I create an instance of the object. So I pass all the values in the constructor: ...
user avatar
  • 887
17 votes
3 answers
1k views

Using a navigation menu to help keep material organized

I'm working on a personal project to keep different snippets/examples/small projects of mine organized. I want to make the most of my page width, so I decided to write a navigation menu that slides ...
user avatar
  • 463
7 votes
1 answer
1k views

Object cache storage for Rails

I want to have fast cache in which I want to keep all my nomenclature data. I don't want to go with Memcached because I have to do serialize/de-serialize on each object which is slow. So I choose to ...
user avatar
  • 265
19 votes
2 answers
621 views

A take on DB Abstraction

It's a little bit more code but I wanted to show the full class. I highlight the points I'd like input after the source. I've cut comments since they where not in English and translated the important ...
user avatar
  • 1,536
14 votes
3 answers
669 views

Extracting a set of numbers from a file

I do most of my programming in C/C++ and Perl, but I currently learning Fortran. I began by coding up a simple program, something that took me < 5 minutes in Perl (see this thread from BioStar). ...
user avatar
15 votes
1 answer
2k views

Function for finding longest common path and formatting it along with filenames

This is a function I wrote yesterday and have tested with lots of input. It's been committed and is in use, but no review was done, so it seems like a good candidate for Code Review: it could be more ...
user avatar
  • 852
13 votes
4 answers
1k views

Counting the number of points that have both a larger theta and a larger radius than a given point

I don't like the fact that I am selecting all the points, even though I only care about the count of them. Which of the from parts should appear first, if it even ...
user avatar
  • 873
11 votes
2 answers
382 views

Is this a sufficient way to prevent script injections and other bad stuff in strings

Would this function be sufficient enough to remove all malicious code and foreign characters from a string? ...
user avatar
  • 213
27 votes
4 answers
2k views

Law of Demeter and data models?

Inspired by this question, but hopefully not a duplicate. I understand that the Law of Demeter is very useful in case of services interacting with other services, for example it's much easier to mock ...
user avatar
  • 598
23 votes
5 answers
21k views

Best way to pass parameters to Factory class?

So I have a series of objects, which I will call Impl1, Impl2, and Impl3. They each implement an interface, called IImpl. I have a Factory class who's task is to retrieve the ImplX which is ...
user avatar
  • 451
14 votes
4 answers
544 views

Subroutine to call other subroutines

I have a Perl application that allows the user to choose between two different formats for data output (and there will likely be more in the near future). In the heart of the algorithm, the code makes ...
user avatar
14 votes
3 answers
1k views

Fetching tweets

I have written this (truncated) code to fetch some tweets: ...
user avatar
14 votes
2 answers
863 views

HTTP request path parser

I have written a method to tokenize HTTP request paths such as /employee/23/edit: ...
user avatar
  • 529
8 votes
2 answers
835 views

Extracting nodes from a graph database

I'm new to Postgres and PostGIS, but not to geospatial applications. I have a table loaded up with graph data in the form of links (edges). The link database has about 60,000,000 rows. I am trying to ...
user avatar
  • 524
19 votes
2 answers
772 views

Cleaning up class creation / extension

I was wondering for quite some time how to clean up the below code without blowing it up any further. The extension of the classes is the main concern here, it looks a bit too much like magic. That's ...
user avatar
7 votes
2 answers
3k views

Loop with enclosing items every 'n' steps

I'm listing elements with a foreach, and I would like to enclose items in something tag n by ...
user avatar
  • 267
67 votes
9 answers
29k views

Implementing a Singleton pattern in C#

Is this the best way to implement this pattern in C#? ...
user avatar
  • 772
8 votes
2 answers
482 views

Pagination plugin

This plugin is written in jQuery and is made to support the codeigniter framework. It is an ajax powered table pagination plugin designed to provide only that. You should be able to use almost any ...
user avatar
  • 477
13 votes
2 answers
6k views

Implementation of a PID Controller

I've implemented a PID controller, but seeing as I'm not an expert in control theory, have I missed any edge cases? ...
user avatar
17 votes
2 answers
4k views

Shamos-Hoey algorithm for checking the self-intersection of a closed shape

I implemented the Shamos-Hoey algorithm to check if a closed shape is self-intersected. Is this algorithm ok in terms of performance? ...
user avatar
  • 397
19 votes
3 answers
2k views

Shuffling algorithm for a "guess that tune" game

I'm making a "guess that tune" game in Visual Basic 6 that is supposed to play each song in a random order: ...
user avatar
6 votes
2 answers
829 views

PHP/Doctrine bootstrap for review

Here's my bootstrap.php for my PHP/MySQL/Doctrine app. It's my first PHP app so I'm interested in learning from the experience of others how this could be improved ...
user avatar
  • 887
7 votes
2 answers
1k views

Critique My Codeigniter Custom CMS Pages Model

I am currently developing a custom CMS being built on top of Codeigniter and was wondering if you can spot any flaws in my page fetching model code. The page fetching model is not entirely complete ...
user avatar
12 votes
4 answers
320 views

Test case for a caching library

This shows a test case for an old caching library that I use for a project. It features simple save/load/delete functions (sadly static calls) but what I want to focus on is the test code written for ...
user avatar
  • 1,536
16 votes
1 answer
1k views

Emacs Etags Shortcut Functions

A few functions to let me manage TAGS files more easily. Typically, my projects contain at least one sub-folder. I got sick of manually updating, so I wrote this to help me update a single TAGS file ...
user avatar
  • 2,173
23 votes
5 answers
2k views

Generating CSV strings for various 3rd party utilities

I'm generating CSV strings for various 3rd party utilities and this section of code gets repeated in many classes. Is there a better way to generate this string? ...
user avatar
21 votes
4 answers
3k views

Custom checksum algorithm

A while back, I reverse-engineered a checksum algorithm from an MMO used to check the validity of an item that's linked to chat (similar to WoW). The idea is that if the checksum is invalid then the ...
user avatar
  • 1,874
9 votes
2 answers
1k views

Comparing data in 2 tables on different servers with CHECKSUM

So I've had a problem where I need to compare data in 2 different tables on two different servers. Now, I know MySQL supports CHECKSUM TABLES, but from my testing ...
user avatar
  • 714
29 votes
2 answers
38k views

CodeIgniter Active Record Subqueries

I use CodeIgniter at work, and one of our model files had a lot of subqueries in it. I originally had to manually write each subquery, and wondered if I could use active records instead. So, to make ...
user avatar
  • 730
34 votes
11 answers
3k views

Too many loops in Drawing App

I have a method that has a lot of loops: ...
user avatar
61 votes
10 answers
4k views

Using separate functions for Project Euler 1

I started programming with Java and C++, so I'm used to having a 'main' function that calls other functions that do the actual work. At university I was always told that doing actual computation in ...
user avatar
  • 871
27 votes
4 answers
2k views

PHP Autoloader Library

Basically, I had written this class a little while ago to ease autoloading of our local libraries. The premise is that everything is split by packages into multiple layers of sub-packages. Classes ...
user avatar
  • 714
56 votes
9 answers
13k 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 ...
user avatar
39 votes
5 answers
10k views

Database connection in constructor and destructor

I am playing with different ways to do database interaction in PHP, and one of the ideas I have been playing with is connecting to the DB in the constructor and disconnecting in the destructor. This ...
user avatar
13 votes
2 answers
1k views

PHP mcrypt AES encryption wrapper

There are two keys: the main is aes128 and the second is XTEA, used just for randomization of data inside the AES. Randomization is done with secret random key that is not know even if someone knows ...
user avatar
6 votes
1 answer
741 views

AES encryption wrapper

After taking into account answers for my questions here and here I created (well may-be) improved version of my wrapper. The key issue was what if an attacker is knowing what is encoded - he might ...
user avatar
  • 379

15 30 50 per page