Skip to content

Instantly share code, notes, and snippets.

View PatrickTulskie's full-sized avatar

Patrick Tulskie PatrickTulskie

View GitHub Profile
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
require 'benchmark'
require 'pp'
require 'active_record'
require 'sequel'
require 'data_mapper'
@start = Date.parse("2012-12-01")
@end = Date.parse("2012-12-31")
ActiveRecord::Base.establish_connection(adapter: 'mysql2', database: 'escobar_development', cast: false, username: 'root', password: nil, pool: 5, timeout: 5000)
@PatrickTulskie
PatrickTulskie / Folder Preferences
Created August 11, 2011 18:47 — forked from chrisyour/Folder Preferences
Show hidden files and hidden folders (except .git) in your TextMate project drawer
# Want to show hidden files and folders in your TextMate project drawer? Simple, just modify the file and folder patterns in TextMate's preferences.
# Instructions:
# Go to TextMate > Preferences...
# Click Advanced
# Select Folder References
# Replace the following:
# File Pattern
@PatrickTulskie
PatrickTulskie / caveatPatchor.js
Created July 29, 2011 18:53 — forked from protocool/caveatPatchor.js
Sample Propane caveatPatchor.js file
/**
Sample Propane caveatPatchor.js file based on tmm1's avatar hack.
You'll need at least version 1.1.1 to experiment with this:
http://propaneapp.com/appcast/Propane.1.1.1.zip
Once I'm sure exposing this hack-injection point doesn't cause problems
I'll do an official auto-updating version.
As of version 1.1.1, Propane will load and execute the contents of
@PatrickTulskie
PatrickTulskie / resque_retry.rb
Created July 25, 2011 19:15 — forked from clemens/resque_retry.rb
Retry failed Resque jobs in Ruby
# inspired by http://ariejan.net/2010/08/23/resque-how-to-requeue-failed-jobs
# retry all failed Resque jobs except the ones that have already been retried
# This is, for instance, useful if you have already retried some jobs via the web interface.
Resque::Failure.count.times do |i|
Resque::Failure.requeue(i) unless Resque::Failure.all(i, 1)['retried_at'].present?
end
# retry all :)
Resque::Failure.count.times do |i|
upstream unicorn {
server unix:/var/www/example/current/tmp/sockets/unicorn.sock;
}
server {
listen 80;
server_name example.org www.example.org;
access_log /var/log/nginx/example.access.log;
location / {
root /var/www/example/current/public/;
if (-f $request_filename) {
require 'rubygems'
require 'eventmachine'
require 'em-websocket'
require 'json'
class Connection
attr_accessor :socket, :user_id
def initialize(socket, user_id)
@socket = socket
# Taken and Modified from => \
# http://t-a-w.blogspot.com/2010/05/very-simple-parallelization-with-ruby.html
require "rubygems"
require "active_support"
require 'thread'
def Exception.ignoring_exceptions
begin
yield
before "deploy", :start_serenading
after "deploy", :stop_serenading
desc "Start serenading"
task :start_serenading do
fork {`afplay '/path/to/rollout.mp3'`} rescue nil
end
desc "Stop serenading"
task :stop_serenading do
# An extension to the Hash class to inspect what it is made of
class Hash
def whatami
keys.inject({}) do |hash, key|
hash[key] = case self[key].class.to_s
when "Hash"
self[key].whatami
when "Array"
self[key].map do |item|