This file contains hidden or 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/sh | |
# create a txt file to write today's notes | |
DIRNAME="${HOME}/Documents/stuff_i_did/`date +%Y`/`date +%m`/" | |
FILENAME="${DIRNAME}`date +%Y-%m-%d`.txt" | |
mkdir -p $DIRNAME | |
if [ ! -f $FILENAME ]; then | |
echo "--- | |
# `whoami` did stuff today | |
- `date +%Y-%m-%d` |
This file contains hidden or 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 Spinner | |
def initialize printer=nil | |
@spinner = %w[| / - \\] | |
@count = 0 | |
@printer ||= $stderr | |
end | |
def print | |
@printer.print "\r"+@spinner[@count] | |
@count += 1 |
This file contains hidden or 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
task :test => "test:javascript" | |
namespace :test do | |
task :javascript, :expresso_args do |t, args| | |
node = `/usr/bin/env which node` | |
if node == "" | |
puts "Skipping JavaScript unit tests: no 'node' executable found." | |
puts "Please install node.js v0.4.0 or newer." | |
else | |
puts "Running JavaScript unit tests:" |
This file contains hidden or 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 'crypt/blowfish' | |
require 'base64' | |
# simple wrapper for blowfish encryption. Assumes all string IO in base64. | |
module Encryption | |
extend self | |
class NilKey < StandardError; end |
This file contains hidden or 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
#!/usr/bin/env ruby | |
filename = ARGV.pop | |
urls = [] | |
processing_method = {} | |
File.open filename do |f| | |
while l = f.gets | |
if l =~ /.* prism rails\[([0-9]+)\]: .* Processing .* \[([A-Z]+)\]/ | |
processing_method[$1] = $2 | |
end |
This file contains hidden or 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
# As used with CanCan and Devise | |
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
include ErrorResponseActions | |
rescue_from CanCan::AccessDenied, :with => :authorization_error | |
rescue_from ActiveRecord::RecordNotFound, :with => :resource_not_found | |
before_filter :authenticate! |
This file contains hidden or 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 ApplicationController < ActionController::Base | |
rescue_from ActiveRecord::RecordNotFound, :with => :resource_not_found | |
rescue_from ActionController::RoutingError, :with => :check_request_uri_and_method | |
rescue_from AbstractController::ActionNotFound, :with => :page_not_found | |
rescue_from ActionController::MethodNotAllowed, :with => :method_not_allowed |
This file contains hidden or 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 install hijack | |
ps aux | grep ruby | |
# andrew 10879 0.0 2.4 2538948 100668 ?? S 10:30AM 0:03.09 ruby .../node_modules/nack/bin/nack_worker .../config.ru /tmp/nack.56823.5122799426.sock | |
hijack 10879 |
This file contains hidden or 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
## https://gist.github.com/977188 | |
# | |
# If your workers are inactive for a long period of time, they'll | |
# lose their MySQL connection. | |
# | |
# This hack ensures we re-connect whenever a connection is lost. | |
# | |
# From: https://gist.github.com/238999 | |
# | |
# Added retrying to prevent infinite loop. |
This file contains hidden or 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
bash "install #{name} gems" do | |
cwd "/tmp/#{name}" | |
code <<-end_code | |
for gem_file in `ls *.gem` | |
do | |
gem install ./$gem_file | |
done | |
end_code | |
end |