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
irb_context.echo = false # or true |
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 'zlib' | |
require 'rubygems' | |
i = Zlib::Inflate.new | |
f = File.open "Marshal.4.8.Z" | |
data = i.inflate f.read | |
gems = Marshal.load data |
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 DownloadsController < ApplicationController | |
def show | |
if @current_user | |
send_file "#{Rails.root}/downloads/test.pdf" | |
else | |
render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false | |
end | |
end | |
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 DownloadsController < ApplicationController | |
DOWNLOAD_EXPIRY = 30.minutes | |
DOWNLOAD_SECRET = "MYSECRET" | |
def show | |
download = Download.find(params[:id]) | |
# download.file_path - get the path to the file, relative to the downloads directory | |
serve_file(download.file_path) | |
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 'rubygems' | |
begin | |
require "ap" | |
IRB::Irb.class_eval do | |
def output_value | |
ap @context.last_value | |
end | |
end | |
rescue LoadError => e |
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
matt@foo:~/$ ls -lh *.tmp | |
-rw-r--r-- 1 matt matt 176M 2010-07-14 11:45 file.tmp | |
matt@foo:~/$ time sha1sum file.tmp | |
b67e8d00cdce9de8c04b6514ba329da81693f936 file.tmp | |
real 0m0.806s | |
user 0m0.750s | |
sys 0m0.040s | |
matt@foo:~/$ time ruby -r "digest/sha1" -e 'puts Digest::SHA1.file("file.tmp")' | |
b67e8d00cdce9de8c04b6514ba329da81693f936 |
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 "rubygems" | |
require "tinder" | |
require "ap" | |
# Edit to match your campfire details | |
campfire = Tinder::Campfire.new "YOUR_SUBDOMAIN", :token => "YOUR_CAMPFIRE_API_TOKEN" | |
room = campfire.find_room_by_name "YOUR_CAMPFIRE_ROOM" | |
messages = [] |
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
module ApplicationHelper | |
# Facebook Like button | |
def like_button_tag(url) | |
content_tag :iframe, nil, { :'data-url' => "http://www.facebook.com/plugins/like.php?href=#{URI::escape(url)}&layout=standard&show_faces=false&width=400&action=like&colorscheme=light&height=35", | |
:scrolling => "no", | |
:frameborder => "0", | |
:style => "border:none; overflow:hidden; width:400px; height:35px;", | |
:allowTransparency => "true" } | |
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
~/Programming/fooproject[master]% gem install faraday | |
Successfully installed fakutori-san-0.1.0 | |
1 gem installed |
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
~/Programming/foobar[master]% gem install faraday -V | |
GET http://rubygems.org/latest_specs.4.8.gz | |
302 Found | |
GET http://production.s3.rubygems.org/latest_specs.4.8.gz | |
304 Not Modified | |
Installing gem fakutori-san-0.1.0 | |
/Users/matt/.rvm/gems/ruby-1.9.2-p0/gems/fakutori-san-0.1.0/.gitignore | |
/Users/matt/.rvm/gems/ruby-1.9.2-p0/gems/fakutori-san-0.1.0/.kick | |
/Users/matt/.rvm/gems/ruby-1.9.2-p0/gems/fakutori-san-0.1.0/MIT-LICENSE | |
/Users/matt/.rvm/gems/ruby-1.9.2-p0/gems/fakutori-san-0.1.0/README.rdoc |