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
#!/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
gem "resque", :require => "resque/server"
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
@matiaskorhonen
matiaskorhonen / HDCP MASTER KEY
Created September 14, 2010 16:18
HDCP MASTER KEY
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