1 2 3 4
<?php function getAge($birthdate) { return floor((time() - strtotime($birthdate))/(60*60*24*365.2425)); ...
PHP How to get age from given b...
by gordon0580.myopenid.com,
February 08, 2010 04:30,
No refactoring
1
$outputstr = preg_replace('/[-]{2,}/','-',trim(strtolower(str_replace(' ','-',preg_replace('/[^A-Z0-9- ]+/i','',$inputstr))),'-'));
PHP Trimming excess from string
by paulswansea.myopenid.com,
February 05, 2010 16:07,
No refactoring, tagged with php, regex, replace
I'm trying to get an input ...
1 2 3
;(function($) { $.fn.extend( ...
JavaScript filter selectbox with 3000+...
This is a little jQuery scr...
1 2 3 4
module Main where import Text.XML.HaXml ...
Haskell Code from a novice Haskell ...
It's a simple command-line ...
1 2 3 4
def self.capture_system(*args) args = args.flatten.compact.collect { |arg| arg.to_s } return false if args.blank? ...
Ruby Silencing current output, b...
by k776.myopenid.com,
February 03, 2010 02:34,
No refactoring, tagged with form, output, process, exec, system
Is there a shorter way to d...
1 2 3 4
def score(dice) count = [0,0,0,0,0,0] ...
Ruby Looking for other/better so...
# Greed is a dice game wher...
1 2 3 4
public class TelnetParser { public event EventHandler<TelnetCommandEventArgs> Command; ...
C# Created a Telnet Parser wit...
So I've was just using TDD ...
1 2 3 4
for y in 0...height for x in 0...width # BGR => RGB & miror y ...
Ruby Symplify few loops
I need to reformat .bmp dat...
1 2 3 4
def get_pos(rel_dates): """returns the positions of the dates closest to 25%, 50%, and 75%""" pos = [0] # first element ...
Python Return the indexes of speci...
The function takes an list ...
1 2 3 4
public static string ToFormattedList<T>(this HtmlHelper helper, IList<T> objectList, ListType listType, Func<T, string> valueReturn) { ...
C# ASP.Net MVC HTML List helper
by czemuja.myopenid.com,
January 25, 2010 23:55,
1 refactoring
I wanted to display list fr...
1 2 3 4
Private Sub cmdAddAmbassador_Click() ' Run when the user clicks the "<" button to add an ambassador to an event ...
VB.NET Many-to-many list box inter...
VBA, not VB.NET.
This is...
1 2 3 4
Number.prototype.mod = function(n) { return ((this%n)+n)%n; ...
JavaScript Business Days
by 3nz0,
January 23, 2010 21:51,
1 refactoring
Functions to add or substra...
1 2 3 4
import flash.display.BitmapData; import flash.geom.Rectangle; import flash.geom.Matrix; ...
ActionScript New to actionscript - Cam t...
by scott2010_h,
January 23, 2010 02:04,
No refactoring, tagged with flash, webcam, actionscript, clock
I know a lot of you are goi...
1 2 3 4
private static bool SetFolderBasedOnFirstStatus(PurchaseOrder po) { bool documentFinished = false; ...
C# Two methods, two enums.
I have these two very simil...
1 2 3 4
def scale_dates(dates): rel_dates = [] first_day = dates[0] ...
Python Scale data points with the ...
In order to print a chart t...
1 2 3 4
#include <fstream> using std::ofstream; #include <time.h> ...
C++ Game of Life
by vodkamilkshake,
January 22, 2010 08:29,
3 refactorings, tagged with C++, cpp, gameoflife, conway, game, algorithm
This is an implementation o...
1 2 3 4
module FancyDates (1..12).each do |mo| t = Time.mktime(1999,mo) ...
Ruby Cleaner way to define const...
This is code that lets you ...
1 2 3
Clip.find_by_sql(["select * from clips where not exists (select 'clip_id' from histories where histories.clip_id = clips.id and histories.user_id = ?) ORDER BY clips.created_at DESC LIMIT 20", user.id])
Ruby ActiveRecord find_by_sql
How can I turn this into so...
1 2 3
def rot_encode(s, offset=2) s.split('').map{ |char| (char.ord + offset).chr }.join end
Ruby rot encode
Rotation encoding with vari...
1 2 3 4
// handlePathChange() is called whenever the URI changes void MVCApplication::handlePathChange() ...
C++ Re-implementation of the AS...
by the-drow.myopenid.com,
January 15, 2010 19:54,
1 refactoring, tagged with C++, mvc, routing, asp.net-mvc-routing
I'm trying to re-implement ...
1 2 3 4
original_file = File.open('content1.txt', 'r') new_file = File.open('master1.txt', 'w') ...
Ruby Making email addresses out ...
I have a text file with jus...
1 2 3 4
?y{?8S8IRon_SoDZoP();I?y
5
5{?8S8IjcI(I$8DRoZI{I
...
PHP Need help with index.php
by gperiard.myopenid.com,
January 14, 2010 15:30,
3 refactorings
Hello, I need help with my ...
1 2 3 4
<?php /** ...
PHP GDLib Progressbar Class
by gwrtheyrn,
January 13, 2010 21:07,
No refactoring, tagged with php, gdlib, image, png, progressbar
A quick progressbar class u...
How to get age from given b...