Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeff Kreeftmeijer jeffkreeftmeijer

View GitHub Profile
View sortable_list_without_javascript.rb
# index.html.erb
<ul id="projects">
<% @projects.each_with_index do |project, index| %>
<% content_tag_for :li, project do %>
<%= project.name %>
<%= button_to('up', :action => 'sort', :projects => @projects.swap(index, index -1)) if index > 0 %>
<%= button_to('down', :action => 'sort', :projects => @projects.swap(index, index +1)) if index < @projects.length - 1 %>
<% end %>
<% end %>
View gist:151904
** Invoke test (first_time)
** Execute test
** Invoke test_inner (first_time)
** Execute test_inner
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -I"lib:ext:bin:test" "/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/test_helper.rb" "test/test_nifty_authentication_generator.rb" "test/test_nifty_config_generator.rb" "test/test_nifty_layout_generator.rb" "test/test_nifty_scaffold_generator.rb"
/Library/Ruby/Gems/1.8/gems/rubigen-1.4.0/lib/rubigen/lookup.rb:9:in `const_missing_before_generators': stack level too deep (SystemStackError)
from /Library/Ruby/Gems/1.8/gems/rubigen-1.4.0/lib/rubigen/lookup.rb:13:in `const_missing_before_generators'
from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/rails_generator/lookup.rb:13:in `const_missing'
View array.rb
class Array
def swap(a,b)
swapped = self.clone
swapped[a], swapped[b] = self[b], self[a]
swapped
end
end
View gist:180231
<?xml version="1.0" encoding="utf-8"?>
<lfm status="ok">
<similarartists artist="Metallica">
<artist>
<name>Megadeth</name>
<mbid>a9044915-8be3-4c7e-b11f-9e2d2ea0a91e</mbid>
<match>100</match>
<url>www.last.fm/music/Megadeth</url>
<image size="small">http://userserve-ak.last.fm/serve/34/25013983.jpg</image>
<image size="medium">http://userserve-ak.last.fm/serve/64/25013983.jpg</image>
View gist:182893
/Applications/TextMate.app/Contents/SharedSupport/Support/lib/osx/plist.bundle: dlopen(/Applications/TextMate.app/Contents/SharedSupport/Support/lib/osx/plist.bundle, 9): no suitable image found.  Did find: (LoadError)
/Applications/TextMate.app/Contents/SharedSupport/Support/lib/osx/plist.bundle: no matching architecture in universal wrapper - /Applications/TextMate.app/Contents/SharedSupport/Support/lib/osx/plist.bundle
from /Applications/TextMate.app/Contents/SharedSupport/Support/lib/ui.rb:3
from /Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/RubyMate/stdin_dialog.rb:1:in `require'
from /Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/RubyMate/stdin_dialog.rb:1
View hashtagerize.rb
puts 'please type the text you want to #hashtagerize and press [ENTER]...'
open 'http://twitter.com/?status=#' << gets.split(' ').join(' #').gsub('#@', '@')
View hashtagerize.rb
puts 'please type the text you want to #hashtagerize and press [ENTER]...'
open 'http://twitter.com/?status=#' << gets.split(' ').collect { |word| word[0] == 64 ? word : "##{word}" }.join(' ')
View hashtagerize.rb
puts 'please type the text you want to #hashtagerize and press [ENTER]...'
open 'http://twitter.com/?status=' << gets.split(' ').collect { |word| word[0] == 64 ? word : "##{word}" }.join(' ')
View hashtagerize.rb
#!/usr/bin/ruby
require 'cgi'
# #Hashtagerize. The wet dream of hashtag-overusing-idiots out there.
# You know who you are. Stop it.
puts 'please type the text you want to #Hashtagerize and press [ENTER]...'
IO.popen 'open http://twitter.com/?status=' << CGI::escape(gets.split(' ').collect { |word| word[0] == 64 ? word : "##{word}" }.join(' '))
@jeffkreeftmeijer
jeffkreeftmeijer / hashtagerize.rb
Created Nov 26, 2009 — forked from matsimitsu/hashtagerize.rb
#Hashtagerize. The wet dream of hashtag-overusing-idiots out there.
View hashtagerize.rb
#!/usr/bin/ruby
require 'cgi'
# #Hashtagerize. The wet dream of hashtag-overusing-idiots out there.
# You know who you are. Stop it.
IO.popen 'open http://twitter.com/?status=' << CGI::escape(ARGV.collect { |word| word[0] == 64 ? word : "##{word}" }.join(' '))
You can’t perform that action at this time.