Skip to content

Instantly share code, notes, and snippets.

View wjessop's full-sized avatar
🤖

Will Jessop wjessop

🤖
View GitHub Profile
NoMethodError in Group#find
Showing /Users/will/Dropbox/www/finder/app/views/layouts/application.html.erb where line #37 raised:
undefined method `html_safe' for nil:NilClass
Extracted source (around line #37):
34: </script>
35:
36: <div id="wrapper">
<% content_for :some_section do %>
… Long section of view code
<% end # some_section %>
<% content_for :some_section do %>
… Long section of view code
<% end %>
… Create a file:
octobrain:~ will$ echo foo > /tmp/foo
… launch IRB:
octobrain:~ will$ irb
ruby-1.9.2-p0 > f = File.open('/tmp/foo')
=> #<File:/tmp/foo>
ruby-1.9.2-p0 > f.flock(File::LOCK_EX)
octobrain:~ will$ irb
ruby-1.9.2-p0 :001 > $stderr.puts "foo"
foo
=> nil
ruby-1.9.2-p0 :002 > $stderr.reopen(File.open("/dev/null", "w+"))
=> #<File:/dev/null>
ruby-1.9.2-p0 :003 > $stderr.puts "foo"
=> nil
ruby-1.9.2-p0 :004 >
# dir is an array of dir entries, eg: ['ar', 'fe', '4a', 'c9']
def delete_empty_dirs(dir)
begin
Dir.rmdir File.join(self.base_storage_path, dir.join('/'))
dir.pop
delete_empty_dirs(dir)
rescue SystemCallError
return
end
index 57b442a..8264475 100644
--- a/lib/trollop.rb
+++ b/lib/trollop.rb
@@ -362,7 +362,7 @@ class Parser
params = given_data[:params]
opts = @specs[sym]
- raise CommandlineError, "option '#{arg}' needs a parameter" if params.empty? && opts[:type] != :flag
+ raise CommandlineError, "option '#{arg}' needs a parameter" if params.empty? && opts[:type] != :flag and not opts[:allow_blank]
octobrain:~ will$ perl -e'use strict; print "foo\n" if false'
Bareword "false" not allowed while "strict subs" in use at -e line 1.
Execution of -e aborted due to compilation errors.
@wjessop
wjessop / create_posts.rb
Created May 30, 2011 18:52
Posts migration
class CreatePosts < ActiveRecord::Migration
def self.up
create_table :posts do |t|
t.string :title, :null => false
t.text :body
t.string :author, :null => false, :default => "Anonymous"
t.timestamps
end
GitHub SSH access is temporarily unavailable (0x04).
Check http://status.github.com for details.