All Questions

23
votes
3answers
2k views

Project Euler Problem 2 in Clojure

I am in the process of learning Clojure. I am fairly new to functional programming and would like to know if my code smells or if there are any performance implications with my approach. ...
14
votes
7answers
2k views

Personal website, done after one week of learning HTML and CSS

I've just started learning CSS/HTML a week ago and I made a quick site today. It looks pretty good, but I think that I reused/wrote some really messy CSS. This is because I haven't used the ...
5
votes
2answers
420 views

User error logging

I have created this code for user error logging, and I am wondering if there is anything that can be improved. The point is that this error handler would ONLY catch user errors created in-code by ...
3
votes
3answers
646 views

Initializing a window in Cocoa

This is some of the code I have: ...
19
votes
7answers
21k views

Function for removing forbidden characters

...
9
votes
5answers
716 views

Resolving a link - follow-up

Similar piece of code to that I recently posted as: Resolving a link I have another piece of code which cannot be as easily extracted out into a method: ...
14
votes
4answers
398 views

Finding subtuple in larger collection?

I've got a flat array of < 1000 items and I need to find the indices of a smaller tuple/array within the array. The tuple to find can be a varying length (generally between 2 and 5 items, order is ...
23
votes
4answers
13k views

Interface for unit of work pattern and repository pattern

I'm trying to design a well defined yet simple interface for the unit of work and repository patterns. My UoW's are exposed to services and services then "get repositories" that it needs to query. I ...
36
votes
6answers
3k views

Resolving a link

How can I clean this up? ...
15
votes
5answers
1k views

Twitter client portfolio website

I'm creating some sort of "portfolio" website for my self (a ton of placeholder content right now...) and I was wondering if I could improve the semantics of the HTML5 any further, especially the <...
25
votes
6answers
2k views

Formatter class

In our production code, we cannot use Boost or C++0x. Formatting strings using sprintf or stringstream is annoying in this case,...
43
votes
5answers
13k views

Thread-Safe and Lock-Free - Queue Implementation

I was trying to create a lock-free queue implementation in Java, mainly for personal learning. The queue should be a general one, allowing any number of readers and/or writers concurrently. Would you ...
10
votes
1answer
2k views

Php/Doctrine array hydration

According to the Doctrine docs, you should use Array hydration rather than record hydration when retrieving data for read-only purposes. Unfortunately, this means I have to use array syntax (as ...
25
votes
3answers
18k views

Calculate a median

I got this as an implementation of "get me the median of those values". But it sort of doesn't feel right (too long, too many branch points) so I thought I'll post it here to see what you think. <...
13
votes
1answer
727 views

Quasi-random sequences: how to improve style and tests?

The requirements for this one were (original SO question): Generate a random-ish sequence of items. Sequence should have each item N times. Sequence shouldn't have serial runs longer than a given ...
8
votes
1answer
2k views

Randomly sampling a population and keeping means: tidy up, generalize, document?

This is part from an answer to a Stack Overflow question. The OP needed a way to perform calculations on samples from a population, but was hitting memory errors due to keeping samples in memory. ...
3
votes
5answers
10k views

Avoiding null in variable assignment

I want to get empty string or the string value of the object Which code you will use and why? value = object.to_s or this ...
32
votes
8answers
16k 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 ...
7
votes
1answer
425 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 ...
30
votes
3answers
12k 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 ...
7
votes
1answer
699 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 ...
24
votes
3answers
802 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 ...
71
votes
8answers
207k 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 ...
20
votes
3answers
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 ...
19
votes
3answers
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 ...
9
votes
5answers
944 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 ...
11
votes
5answers
2k views

Simple ASP.NET C# class design

Here's a class I'm designing: ...
12
votes
1answer
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 ...
9
votes
1answer
682 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: ...
16
votes
7answers
2k views

Parsing a file for a game

Is this code good enough, or is it stinky? ...
23
votes
5answers
20k 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: ...
43
votes
7answers
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: ...
15
votes
3answers
998 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 ...
7
votes
1answer
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 ...
18
votes
2answers
574 views

A take on DB Abstraction - PHP / MySql

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 ...
12
votes
2answers
614 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). ...
15
votes
1answer
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 ...
13
votes
4answers
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 ...
11
votes
2answers
362 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? ...
22
votes
4answers
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 ...
23
votes
5answers
14k 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 ...
13
votes
4answers
493 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 ...
13
votes
3answers
1k views

Fetching tweets

I have written this (truncated) code to fetch some tweets: ...
12
votes
2answers
666 views

HTTP request path parser

I have written a method to tokenize HTTP request paths such as /employee/23/edit: ...
8
votes
2answers
822 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 ...
19
votes
2answers
748 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 ...
7
votes
2answers
2k 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 ...
67
votes
9answers
28k views

Implementing a Singleton pattern in C#

Is this the best way to implement this pattern in C#? ...
7
votes
2answers
456 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 ...
12
votes
2answers
5k 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? ...

15 30 50 per page