Skip to content

Instantly share code, notes, and snippets.

View retr0h's full-sized avatar
💭
(✖╭╮✖)

נυαη נυαηѕση retr0h

💭
(✖╭╮✖)
  • Los Angeles, CA
  • 04:03 (UTC -12:00)
View GitHub Profile
##
# Start daemons.
config.after_initialize do
unless $0.match(/rake/) or (defined? DaemonMemcache and DaemonMemcache.instance.running?)
DaemonMemcache.instance.start rescue nil
at_exit do
DaemonMemcache.instance.stop rescue nil
end
end
end
require 'singleton'
begin
require 'daemon_controller'
rescue LoadError
raise('FATAL: sudo gem install FooBarWidget-daemon_controller -s http://gems.github.com')
end
##
# sudo port install memcached
class DaemonMemcache
@retr0h
retr0h / gist:32421
Created December 5, 2008 18:00 — forked from jashmenn/gist:6206
# == WHAT
# Simple script for growl notifications in irssi
#
# == WHO
# Nate Murray 2008
#
# == CONFIG
# /SET growl_on_regex [regex]
# /SET growl_channel_regex [regex]
#
@retr0h
retr0h / gist:66008
Created February 17, 2009 21:47 — forked from amikula/gist:65995
# Module for re-running commands from the history in irb and its ilk (script/console)
# Usage:
# history => view the history
# history 7 => rerun line 7 in the history
# history /foo/ => rerun the last line in the history matching /foo/
#
# Just add this code into your ~/.irbrc.
# NOTE: Readline support is required for this to work.
module HistoryRepeats
class << self
@retr0h
retr0h / gist:68809
Created February 23, 2009 05:03
ActionMailer Timeouts
### lib/ruby_ext.rb
Net::SMTP.class_eval do
def initialize_with_timeouts(*args)
initialize_without_timeouts(*args)
@open_timeout = Emailer::OpenTimeout
@read_timeout = Emailer::ReadTimeout
end
alias_method_chain :initialize, :timeouts
end
### lib/tasks/app.rake
begin
require 'vlad'
Vlad.load :scm => :git, :web => :apache
rescue LoadError
puts $!
end
### Extending 'vlad:update' with 'gems:geminstaller'
namespace :spec do
desc "Report uncovered view templates."
task :missing_view_templates => :environment do
EXTENSION = ENV['extention'] || 'haml'
APP_VIEWS_DIR = File.join('app', 'views')
SPEC_VIEWS_DIR = File.join('spec', 'views')
Dir[File.join(Rails.root, "#{APP_VIEWS_DIR}/**/*.html.#{EXTENSION}")].each do |file|
file.match(%r{^#{File.join(Rails.root, APP_VIEWS_DIR)}/(.*)\.html.#{EXTENSION}$})
puts $1 unless File.exists?(File.join(Rails.root, SPEC_VIEWS_DIR, "#{$1}.html.#{EXTENSION}_spec.rb"))
##
# Rack configuration for use with Phusion Passenger.
#
# Updated with Blake's suggestions from: http://gist.github.com/98711
log = File.new('log/sinatra.log', 'a')
$stdout.reopen(log)
$stderr.reopen(log)
require 'YOUR_APPLICATION'
CONTENT_TYPES = {:html => 'text/html', :css => 'text/css', :js => 'application/javascript'}
before do
request_uri = case request.env['REQUEST_URI']
when /\.css$/ : :css
when /\.js$/ : :js
else :html
end
content_type CONTENT_TYPES[request_uri], :charset => 'utf-8'
end
get '/:stylesheet.css' do
sass params[:stylesheet].to_sym
end