Skip to content

Instantly share code, notes, and snippets.

tags() {
dir=$1
if [[ "$dir" == "" ]]; then
dir='.'
fi
if [[ ! -d $dir ]]; then
echo $'\e[1;31m'Error: $dir is not a directory.$'\e[0m'
return 1
fi
#!/usr/bin/env ruby
File.open( 'report.txt', 'w' ) do |io|
io.puts <<-EOI
Dear Karla,
You're fucked, please quit.
Regards,
The Internet
13:31:08 1.0 ~/work/gems/rubysl-dl $ wc -l `find . -iname '*.rb'`
193 ./ext/rubysl/dl/extconf.rb
49 ./ext/rubysl/dl/install.rb
225 ./ext/rubysl/dl/lib/dl/import.rb
149 ./ext/rubysl/dl/lib/dl/struct.rb
245 ./ext/rubysl/dl/lib/dl/types.rb
25 ./ext/rubysl/dl/lib/dl/win32.rb
69 ./ext/rubysl/dl/mkcall.rb
63 ./ext/rubysl/dl/mkcallback.rb
25 ./ext/rubysl/dl/mkcbtable.rb
class User
# other stuff
def own_and_reviewed_jobs
( jobs + Job.where( reviewer: self ) ).uniq
end
end
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.macports.gpg-agent</string>
<!-- Please uncomment on 10.4; OnDemand doesn't work properly there. -->
<!--
<key>OnDemand</key>
09:39:14 ~/work/r4.2.0 $ rails c
Loading development environment (Rails 4.2.0)
[1] pry(main)> f = Foo.first
Foo Load (0.3ms) SELECT "foos".* FROM "foos" ORDER BY "foos"."id" ASC LIMIT 1
=> #<Foo:0x007fa18bf146c0 id: 1, name: "Jason", age: 44, created_at: Wed, 07 Jan 2015 01:52:26 UTC +00:00, updated_at: Wed, 07 Jan 2015 01:59:01 UTC +00:00>
[2] pry(main)> show-source f.wee
From: /Users/jk/work/r4.2.0/app/models/foo.rb @ line 7:
Owner: Foo
Visibility: public
@smathy
smathy / pry.rb
Last active August 29, 2015 14:14
[20] pry(main)> class Foo < ActiveRecord::Base
[20] pry(main)* end
=> nil
[21] pry(main)> f = Foo.new phone_numbers: {"dario" => "12345"}
=> #<Foo:0x007fc69ba76228 id: nil, name: nil, phone_numbers: "{\"dario\"=>\"12345\"}", created_at: nil, updated_at: nil>
[22] pry(main)> f.phone_numbers.class
=> String
[23] pry(main)> class Foo < ActiveRecord::Base
[23] pry(main)* serialize :phone_numbers
[23] pry(main)* end
@smathy
smathy / irb.rb
Last active August 29, 2015 14:14
12:18:33 ~/work/r42 $ rails c
Loading development environment (Rails 4.2.0)
irb(main):001:0> app.foos_path
=> "/foos"
irb(main):002:0> app.foos_url
=> "http://www.example.com/foos"
irb(main):003:0>
@smathy
smathy / -
Created February 16, 2015 23:15
15:14:47 master ~/work/r42 $ ag "(def|alias).*assert_not_includes" `bundle list --paths`
/Users/jk/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/test_case.rb
81: alias :assert_not_includes :refute_includes
@smathy
smathy / -
Created February 25, 2015 05:04
[76] pry(main)> class FooBar < ActiveRecord::Base
[76] pry(main)* scope :broken, -> { "UH OH" }
[76] pry(main)* end
=> :broken
[77] pry(main)> FooBar.broken.where name: "NOPE!"
NoMethodError: undefined method `where' for "UH OH":String
from (pry):65:in `__pry__'