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

How to get age from given b...

Avatar Talk
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 ...

E4bd1595f34e7e03765eda6ed65bf6bb Talk
1
2
3
;(function($) {
        $.fn.extend(
...

JavaScript filter selectbox with 3000+...

by akarzim, February 03, 2010 23:05, 1 refactoring, tagged with jquery, dom, speed, select

This is a little jQuery scr...

0018abed2b5e8b460993ed915adc0d11 Talk
1
2
3
4
module Main where

import Text.XML.HaXml
...

Haskell Code from a novice Haskell ...

by jaewon.mp, February 03, 2010 10:21, No refactoring, tagged with haskell, HaXml, xml

It's a simple command-line ...

2f9c571c7d57b6e2170eae9a372e24b8 Talk
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...

74198b06bc9e68739debfe6c23e070d3 Talk
1
2
3
4
def score(dice)
  
  count = [0,0,0,0,0,0]
...

Ruby Looking for other/better so...

by websymphony.blogspot.com, February 02, 2010 21:42, 9 refactorings, tagged with dice game, ruby

# Greed is a dice game wher...

D7b8e44d9c430f24a9426725d4c33480 Talk
1
2
3
4
public class TelnetParser
    {
        public event EventHandler<TelnetCommandEventArgs> Command;
...

C# Created a Telnet Parser wit...

by Killersponge, February 02, 2010 12:01, 1 refactoring, tagged with Telnet, TDD, C#

So I've was just using TDD ...

B20991026b45ee0d77e9bbb2b6776097 Talk
1
2
3
4
for y in 0...height
  for x in 0...width
    # BGR => RGB & miror y
...

Ruby Symplify few loops

by darkleo.myopenid.com, January 30, 2010 20:36, 6 refactorings, tagged with ruby, short

I need to reformat .bmp dat...

61f1b34f172ee1fbc1af42ab3ce0eca9 Talk
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...

by Tafkas, January 28, 2010 19:53, 2 refactorings, tagged with dates, python, relative position

The function takes an list ...

693a4661eaa71435ce5ebe61de64c5a4 Talk
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...

Df5b3718dcbe9055cc6672d8715fcf4f Talk
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...

by Nathan, January 25, 2010 13:56, 2 refactorings, tagged with microsoft access, many-to-many, vba

VBA, not VB.NET.

This is...

D5145c421cd25af6fa577c15219add90 Talk
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...

Fa876f707d4e3f879985bfd748c6f0d7 Talk
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...

B05a78cd33eb6b85c70d7f88d042d813 Talk
1
2
3
4
private static bool SetFolderBasedOnFirstStatus(PurchaseOrder po)
{
    bool documentFinished = false;
...

C# Two methods, two enums.

by mrgrande.livejournal.com, January 22, 2010 20:24, 1 refactoring, tagged with C#, enum

I have these two very simil...

Avatar Talk
1
2
3
4
def scale_dates(dates):
    rel_dates = []
    first_day = dates[0]
...

Python Scale data points with the ...

by Tafkas, January 22, 2010 12:55, 2 refactorings, tagged with python, date, timestamp

In order to print a chart t...

693a4661eaa71435ce5ebe61de64c5a4 Talk
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...

73465ace35a83efec10235c119800304 Talk
1
2
3
4
module FancyDates
  (1..12).each do |mo| 
    t = Time.mktime(1999,mo)
...

Ruby Cleaner way to define const...

by erikpukinskis.myopenid.com, January 19, 2010 20:45, 3 refactorings, tagged with ruby, DateTime

This is code that lets you ...

6015f1c7d2c5057f668f4951f3303b28 Talk
1
2
3
4
function redim_img(apodimg)
{
...

JavaScript pb resize image

by mr6686, January 19, 2010 18:47, 8 refactorings, tagged with resize, image

As a noob in js I ask help ...

3a09c0954a8ee7951398becbb5553f37 Talk
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

by David, January 17, 2010 20:52, 5 refactorings, tagged with activerecord, rails, ruby, sql, short

How can I turn this into so...

Avatar Talk
1
2
3
def rot_encode(s, offset=2)
   s.split('').map{ |char| (char.ord + offset).chr }.join
end  

Ruby rot encode

by Sam Figueroa, January 17, 2010 11:44, 5 refactorings, tagged with rot, rotation, encode, strings

Rotation encoding with vari...

45596033957b2b6d7ef8fe6545e0b7e7 Talk
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 ...

Avatar Talk
1
2
3
4
original_file = File.open('content1.txt', 'r')
new_file = File.open('master1.txt', 'w')

...

Ruby Making email addresses out ...

by vire7, January 15, 2010 17:46, 1 refactoring, tagged with ruby, text, output

I have a text file with jus...

87f4477dced7fcff3ac2154e88d53210 Talk
1
2
3
4
101.times do |n|

  next if n == 0
...

Ruby Fizz Buzz

by jhindle, January 15, 2010 13:08, 8 refactorings, tagged with fizzbuzz, short

Wrote a Fizz Buzz http://en...

6bff7d5313e73334ef0edc691a7564f7 Talk
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 ...

D50bc8b234a652f0d7e5d51ce523e992 Talk
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...

D3bd7339e1941bc25c05110b69a82721 Talk