Skip to content

Instantly share code, notes, and snippets.

View gist:75040
From - Fri Mar 06 14:44:01 2009
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00800000
X-Mozilla-Keys:
Message-ID: <49B17CF4.9070509@lists.distilledb.com>
Date: Fri, 06 Mar 2009 14:43:48 -0500
From: johnf.git@lists.distilledb.com
Reply-To: johnf.git@lists.distilledb.com
User-Agent: Thunderbird 2.0.0.19 (X11/20090105)
MIME-Version: 1.0
View gist:75464
# Removes all Unicode BOMs from files and converts Windows CRLF to Unix LF.
find . -type f | \
while read line; \
do \
hd "$line" | grep -q 'ef bb bf' && echo "$line"; \
done | \
while read line; \
do \
echo [[[ $line; \
View gist:213403
[johnf@genesis][2009/10/19|09:54:27]
[/tmp/tmp-dev]> git fetch
[johnf@genesis][2009/10/19|09:54:40]
[/tmp/tmp-dev]> git config --add remote.origin.fetch refs/apple/banana
# ('apple' is a user I collaborate with who's got several branches, one of which is 'banana'.)
[johnf@genesis][2009/10/19|09:55:36]
[/tmp/tmp-dev]> git fetch
From git@67.23.22.87:fruitbasket.git
* branch refs/apple/banana -> FETCH_HEAD
@fj
fj / hint.rb
Created Nov 25, 2009
Phone riddle for Karl Leswing. See karl.rb for more details.
View hint.rb
;&Bh&A&&AAHBMM#HABBM##BH#Airr;::::;Xr:,,..:::;rriSi:.,:,,,,,,,,,::;::;;;rrsrriS29h;rr:r;:,r@@@@@@@#MM##MMMMB
:S@BX&GhMBHABMMAAHHAAA&2i32sr;:::::ir,.,,.;ss;,,:;S;,,:,,,,,,,,:::::;;;rrrsiisS23hr,.,,:,r@@@@@@#MBBMMBHHHHA
r;@@X2h92Ssii5isssssssir,;95r;;;::,:Xr::;;is;;r;:rr:,,:::,,,.,,:::::rs;;rrsiisS2Xhr.,,..i@@@@@@MhG&&&AG&hhAA
r:H@s;iirrrSS5SS52XXX9&i,,s3s;:::,,,r22XXsr;rrSSir;;::::::,,.,,,:;;;rrrrriSissSSXG; ,i@@@#@@@HG33hhhh&AAGA&
r:i@#&A&&AB#HABBHAHAAHMi,,:XSr;::::;r5A#&r:;rssiissrr;;;;::,.,,::;;;rrrrrsiisi223&hA&@@@@@##A9X993h339GG&G&&
r:;#@B&ABHHBAAHHAAHHAAB5::,sXs;;;;s2h&G5r;;r;;rsiiSiiisrr;:,,,,:;;;;rrrsrrsrsi52hA#@@@@@#@@@BGGAAHBHBBBBMMMH
r:;A@B33322X332553hX52Gh;;,,22r;;i9h3s;::;r;,,,,:::::;rrrr:,,,,:;;rrrssrrsiii55ShAA@@##@#M#@@GGGG&G&AAHHAAHH
r:;9@Aisi;;ih5sssSSisi2hS;,.:3Sri32s;;;;;:::;;;;:::,,,,::r;:,,;rriiisr;;rrssS5S5&GX@@@@Mhi.s@@####@@@@@@@@@#
r;;9@MSrisiAHiiSissssii92;:,.;9s25r;rS2GG3X933hhXX33SSS;:;;::;ri33XSr;rrrrssssS2H2S@@#&,.. r@@@@@@@@@@@@@##
r;;A@BrriSABH33hhhG&M#AS5;:,..rXirr53XXX252
View merry-christmas.rb
# Merry Christmas!
open("/dev/dsp","wb"){|h|s=%q{d=["-KQW[UZbgu*HNT+]TNOOOTZ+cZTUUUUUZbagmssUZbagm
ss+wmpgja+KQW[dfnu","-KEKOINV[W*HBH+QHBCCCHN+WNHIIIIINVU[aUUINVU[aUU+YOR[^I+KEK
OXZbW","-W[acg vsc*TZ`+eaaaaa--vucavuca+eadsvs+W[dgvrtc","-K991LIL77777dIIIII--
LKKILKKI+Mad[ ^U+K991LHJK"].map{|l|l.unpack("C*").map{|c|[(c/6-4)*12/7-8,"012
35b"[c%6,1]. hex]}*4};y=32.chr;l="@"+[(m="Jnx4sn3sgd1")+"vnqkc!6sgd2Lnqc4gz
r4bnld;6/Ld s2dzqsg6qd2@bdhud6gdq2Khmf;77/Lds2du4@dqx4gdzqs6oqd2@ozqd4ghl
4qnnl,+Amc 2gdz++2 @udm 4z mc 2gdz 4@+u dm 2zm
c2mz+@stqd+r hmf",m+"E zq sg !6sgd2Sz u4@h nt q4qd hfm r; 6/Ld
View ipad-user-agent-string.txt
Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10
View nano.rb
class Nanomachine
class Nanoparticle
def add(p)
while more?
p << self
end
end
end
# Ruby 1.9 includes nicer support for warnings that you didn't get in 1.8.
View const_resolver.rb
# Given a constant's name of the form r = "One::Two::[...]::ThirtyFive",
# resolve its value.
sep = "::" # Doesn't appear that '::' is defined.
c = r.split(sep).inject(Object) { |memo, el| memo.const_get(el) }
# Usage:
module Foo
module Bar
Baz = 100
end
View foo.markdown

I'm trying to be diligent about checking my rake tasks with RSpec tests, but in the process of feeling my way around I seem to have hit a wall. I've got a really simple RSpec test that looks like this:

# ./test/meta_spec.rb
describe "Rake tasks" do
  require 'rake'
  
  before(:each) do
    @rake = Rake::Application.new
    @rake.load_rakefile  # => Error here!
    Rake.application = @rake
We couldn’t find that file to show.
You can’t perform that action at this time.