Skip to content

Instantly share code, notes, and snippets.

View trptcolin's full-sized avatar

Colin Jones trptcolin

View GitHub Profile
def valid_phone
[self.home_phone, self.mobile_phone, self.work_phone].each do |phone|
if !phone.blank?
return phone
end
end
return ''
end
module Kernel
def collate(*methods)
methods.map {|m| send(m)}
end
end
first, last = User.collate :first, :last # => [#<User id: 1 name: "Pat">, #<User id: 85 name: "Joe">]
avg, max, min = [4, 3, 1, 5, 2].collate :avg, :max, :min # => [3.0, 5, 1]
(ns bktree)
(defn root [distance-fn] {:distance-fn distance-fn :children {} :matches []})
(defn new-node [term] {:term term :children {} :matches []})
(defn insert
([element node]
(insert element node (:distance-fn node)))
([element node distance-fn]
@trptcolin
trptcolin / about.md
Created August 11, 2011 00:36 — forked from fogus/about.md
Programming Achievements: How to Level Up as a Developer
$( document ).ready( function() {
var $body = $('body');
var setBodyScale = function() {
var scaleFactor = 0.35,
scaleSource = $body.width(),
maxScale = 600,
minScale = 30;
var fontSize = scaleSource * scaleFactor;
#!/usr/bin/env ruby
require 'thread'
require 'rubygems'
require 'typhoeus'
mutex = Mutex.new
100000.times do |t|
@trptcolin
trptcolin / about.md
Created April 11, 2012 20:14 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@trptcolin
trptcolin / bf.c
Created May 10, 2012 01:17 — forked from fogus/bf.c
#include <stdio.h>
char b[30000],z[9999],*p=b,c,*a,i;
f(char*r,int s)
{
while(c=*a++)
{
if(!s)
{
(c-62)?(c-60)?(c-43)?(c-45)?(c-46)?(c-44)?0:(*p=getchar()):putchar(*p):--*p:++*p:--p:++p;
if(c==91)f(a,!*p);