Skip to content

Instantly share code, notes, and snippets.

@tehprofessor
tehprofessor / error_pages.rb
Created May 14, 2012 16:53 — forked from corny/error_pages.rb
Custom error pages
#
# Usage:
# class ApplicationController < ActionController::Base
# include ErrorPages
# end
#
require 'active_support/core_ext/array/extract_options'
module ErrorPages
extend ActiveSupport::Concern
@tehprofessor
tehprofessor / sinatra_before_filter.rb
Created April 14, 2012 20:07
Sinatra before filter selection using path + http method as qualifier
# As always, I hope I didn't reinvent the wheel or do something stupid... If I have please let me know!
#
# I'm currently using this with async_sinatra; haven't tested it without (sorry!)
#
# Example method usage:
#
# before_filter [[:apost, "/users/?"] do
# require_login
# end
@tehprofessor
tehprofessor / gist:2128162
Created March 19, 2012 23:08
NewRelic OpenPGP Server Down (Alternative Method)
PGP.net goes down from time to time, and incase it does you can use this to add the NewRelic key:
wget -O - http://download.newrelic.com/548C16BF.gpg | apt-key add -
@tehprofessor
tehprofessor / archive.rb
Created March 11, 2012 03:53
Archiving Audio Stream in Ruby
require 'net/http'
require 'uri'
url = URI.parse('http://stream.kpsu.org:8080/listen')
# This thread is used to kill the recording thread after the
# designated amount of time.
timelimit = Thread.new do
# running_time_in_seconds is how many seconds the clip should be
# one hour = 3600 seconds