Skip to content

Instantly share code, notes, and snippets.

View wuputah's full-sized avatar
🐘

Jonathan Dance (JD) wuputah

🐘
View GitHub Profile
tell application "Google Chrome"
set aWin to make new window with properties {mode:"incognito"}
tell aWin
make new tab with properties {URL:"http://www.wuputah.com"}
close tab 1
end tell
activate
end tell
>> def fact(n, r)
> if n < 2
> r
> else
> fact(n-1, n*r)
> end
> end
=> nil
>> fact(8720, 1)
=> 42190895430181916664979031806056928246303353451535636903773271316751702454531800280700498288825191072312390610447587954346720269259692495920127490654583176499074215852936506326556512651275020902681028408186164876934018066277852504002354904436539580624158841854584430580553205445678489279798415237578251015457819238211230996395174721526160166715453429700539475407302042107727975081050340508488865545782567001627527256801478522173103429539485321166200911428966344400772272969303858818597878181807615411366351182083258934467160969229226144067176912092520864697527038515938049590698544346189637434543160878992587889412988150063728225782549842240447124939040852245676989331855076443880183502308022073971744344239015274826387293786227930235969158940115582665264215146994173722360461092488599138170809222943662940806837299667841141685770580124593359987397203021073274581159074540783199754953227439324551958425260235
require 'my_bouncer'
require 'my_app'
use MyBouncer
run MyApp
#!/usr/bin/env ruby
require 'rubygems'
['json', 'cloudapp_api'].each do |gem|
begin
require gem
rescue LoadError
puts "You need to install #{gem}: gem install #{gem}"
exit!(1)
end
# confirm you can access the internet
if [[ ! $(curl -Is http://www.google.com/ | head -n 1) =~ "200 OK" ]]; then
echo "Your Internet seems broken. Press Ctrl-C to abort or enter to continue."
read
fi
# make 2 partitions on the disk.
parted -s /dev/sda mktable msdos
parted -s /dev/sda mkpart primary 0% 100m
parted -s /dev/sda mkpart primary 100m 100%
# t1 and t2 are Time objects
>> Benchmark.realtime { 1_000_000.times { 1000*(t2-t1) }}
=> 1.562801266
>> Benchmark.realtime { 1_000_000.times { t2-t1 }}
=> 1.014025201
>> Benchmark.realtime { 1_000_000.times { Time.now; Time.now } }
=> 2.133374417
>> Benchmark.realtime { 1_000_000.times { }}
=> 0.069858542
@wuputah
wuputah / later.rb
Created September 17, 2012 05:51
Later: a simple thread proxy
# +Later+ is a typical object proxy built around a Thread. You pass it a block
# and it will start performing that task in a Thread. Later, you can call any
# method on the object and it will proxy the call to the return value from
# +Thread#value+ (which joins the thread).
#
# Example:
#
# data = [
# Later { open("http://google.com") },
# Later { open("http://duckduckgo.com") },
#!/bin/bash
# ./clone-db COLOR from-app to-app plan
#
# example:
# ./clone-db COBALT my-production-app my-staging-app crane
#
# The COLOR is used for a grep on your config var output, so make sure it's unique.
color=$1
src=$2
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2856 jd 20 0 1874m 1.3g 61m S 2.0 16.3 184:50.28 firefox
<%
require 'cgi'
require 'uri'
begin
uri = URI.parse(ENV["DATABASE_URL"])
rescue URI::InvalidURIError
raise "Invalid DATABASE_URL"
end