This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
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] |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/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| |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
#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); |