Skip to content

Instantly share code, notes, and snippets.

View matiaskorhonen's full-sized avatar

Matias Korhonen matiaskorhonen

View GitHub Profile
irb_context.echo = false # or true
require 'zlib'
require 'rubygems'
i = Zlib::Inflate.new
f = File.open "Marshal.4.8.Z"
data = i.inflate f.read
gems = Marshal.load data
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
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)
require 'rubygems'
begin
require "ap"
IRB::Irb.class_eval do
def output_value
ap @context.last_value
end
end
rescue LoadError => e
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
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)}&amp;layout=standard&amp;show_faces=false&amp;width=400&amp;action=like&amp;colorscheme=light&amp;height=35",
:scrolling => "no",
:frameborder => "0",
:style => "border:none; overflow:hidden; width:400px; height:35px;",
:allowTransparency => "true" }
end
~/Programming/fooproject[master]% gem install faraday
Successfully installed fakutori-san-0.1.0
1 gem installed
@matiaskorhonen
matiaskorhonen / gist:706413
Created November 19, 2010 11:47
gem install -V
~/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