This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alert('something'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
include Benchmark | |
def with_require | |
fork { require 'rake' } | |
end | |
def without_require | |
fork {} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
close all | |
% read the building picture | |
I1 = imread('IMG_5380.JPG'); | |
% correct the rotation | |
I2 = imrotate(I1, -90); | |
% crop it to the area of interest | |
I3 = imcrop(I2,[378.5 0.5 948 814]); | |
% focus on an roi to isolate just the sky from the building... | |
rp = [0 815;70 815;251 435;570 363;949 657;949 0;0 0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# genhtml.rb | |
require 'rubygems' | |
require 'xml/libxml' | |
require 'libxslt' | |
xml_file = ARGV[0] | |
stylesheet_doc = XML::Document.file('homework.xsi') | |
stylesheet = LibXSLT::XSLT::Stylesheet.new(stylesheet_doc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inspired by the protovis library pv.Scale.linear().range() | |
# adapted from rspec codebase | |
def let(name, scale_function) | |
Kernel.send :define_method, name do |p| | |
scale_function.call(p) | |
end | |
end | |
# returns a mapping function from the desired domain (x1,x2) to the desired range (y1,y2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<foo> | |
<bar @mike="hi"> | |
<ug>what</ug> | |
<ug>who</ug> | |
</bar> | |
</foo> | |
> foo.bar.mike # = "hi" | |
> foo.bar.ug # = ["what", "who] | |
> foo.bar.ug[0] # = "what" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# testing rakefile | |
task :default do | |
sh('exit 1') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def hexbytes | |
self.bytes.to_a.map {|c| c.to_s(16).upcase}.join | |
end | |
def hexchars | |
self.chars.to_a.map {|c| c.hexbytes} | |
end | |
def unicodechars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I use pushd and popd to maintain a directory stack and so I like being able to navigate | |
# around the stack with the cursor keys. Here's how: | |
# 1) pushd <new dir> | |
# 2) use CTRL+UP, CTRL+LEFT or CTRL+RIGHT as follows: | |
# bind ctrl + cursor keys: | |
# left = prev; right = next; up = list | |
bind '"\e[1;5A":"dirs\C-m"' | |
bind '"\e[1;5D":"pushd -0 2>/dev/null\C-m"' | |
bind '"\e[1;5C":"pushd +1 2>/dev/null\C-m"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'http://rubygems.org' | |
# your gems here. | |
group :development do | |
# from http://beginrescueend.com/support/troubleshooting/ | |
# requires running: | |
# $ rvm reinstall 1.9.3 --patch debug --force-autoconf | |
# | |
# my platform section below may be debatable (lots of ways to skin the cat) but the crucial part |
OlderNewer