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
#!/bin/bash | |
### BEGIN INIT INFO | |
# Provides: APPLICATION | |
# Required-Start: $all | |
# Required-Stop: $network $local_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Start the APPLICATION unicorns at boot | |
# Description: Enable APPLICATION at boot time. | |
### END INIT INFO |
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
gem "resque", :require => "resque/server" |
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
HDCP MASTER KEY (MIRROR THIS TEXT!) | |
This is a forty times forty element matrix of fifty-six bit | |
hexadecimal numbers. | |
To generate a source key, take a forty-bit number that (in | |
binary) consists of twenty ones and twenty zeroes; this is | |
the source KSV. Add together those twenty rows of the matrix | |
that correspond to the ones in the KSV (with the lowest bit | |
in the KSV corresponding to the first row), taking all elements |
OlderNewer