Skip to content

Instantly share code, notes, and snippets.

View indirect's full-sized avatar

André Arko indirect

View GitHub Profile
@indirect
indirect / fix_mail_keyboard_shortcuts.rb
Created August 8, 2011 07:39
fix Mail keyboard shortcuts containing > in Lion
#!/usr/bin/env ruby
require 'rubygems'
require 'plist'
# This is a fix for the bug filed as Radar #1288404 with Apple.
# http://openradar.appspot.com/radar?id=1288404
# So, in Snow Leopard, I always set up Mail.app to have keyboard shortucts
# for my "From" email addresses. You can create your own in the Keyboard
# system preference pane by entering your email address (like "Andre Arko
@indirect
indirect / .bashrc
Created September 5, 2011 02:22
install OS X system gem binaries without sudo (with RVM)
# Add this code to make sure `gem install` works before `rvm use`.
function gem {
local result;
if [ $1 == "install" ]; then
shift;
command gem "install" "-n/Library/Ruby/Gems/1.8/bin" "$@";
result="$?";
else
command gem "$@";
result="$?";
@indirect
indirect / snippet.rb
Created November 17, 2011 17:44
Rack middleware so NewRelic shows time as ruby
# This adds a request header so NewRelic knows when the middleware stack
# started processing. Hopefully this means we'll get better metrics, split
# between actual request queueing and time spent in the middlewares.
module Plex
class MiddlewareStart
def initialize(app)
@app = app
end
def call(env)
@indirect
indirect / uri.js
Created April 22, 2012 03:33 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@indirect
indirect / .gitconfig
Created April 26, 2012 06:34
git track command that doesn't hurt my brain
[alias]
# git current-branch => master
current-branch = "!git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/^* //'"
# git track origin/master => branch master set up to track remote branch origin/master
track = "!git branch --set-upstream `git current-branch`"
@indirect
indirect / boot.rb.diff
Created June 12, 2012 00:09
monkeypatch Rails 2.3.14 for Ruby 1.9.3
diff --git a/config/boot.rb b/config/boot.rb
index 69b1a51..2c979cf 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -61,12 +61,30 @@ module Rails
require 'initializer'
end
+ def monkeypatch_helpers
+ require "active_support"
@indirect
indirect / source.rake
Created June 13, 2012 06:56
rake tasks to remove trailing whitespace and tabs from your codebase
namespace :source do
def find_and_replace_in_source_files(find, replace)
puts "Search and replace #{find.inspect} => #{replace.inspect}"
files = %w[ .autotest .rspec .rvmrc Gemfile Procfile config.ru ].select{|f| File.exist?(f) }
directories = %w[app config lib public script spec test] # exclude bin, db, doc, log, and tmp
directories.each do |d|
files += Dir[File.join(d, "**/*.{rb,rake,haml,erb,builder,js,coffee,css,scss}")]
end
@indirect
indirect / aliases.sh
Created June 14, 2012 20:36
Make and cd into a directory
# make and cd to a directory
function mcd {
mkdir -p "$@"
cd "$@"
}
@indirect
indirect / gist:3190503
Created July 27, 2012 21:16
Safari Keyword Search settings
{
"Default": "http://www.google.com/search?q=@@@",
"a": "http://www.amazon.com/exec/obidos/search-handle-url/index%3Dblended%26field-keywords%3D@@@",
"cl": "http://sfbay.craigslist.org/search/sss?query=@@@",
"d": "http://www.demonoid.me/files/?category=0&subcategory=All&quality=All&seeded=0&external=2&query=@@@&uid=0&sort=",
"down": "http://downforeveryoneorjustme.com/@@@",
"e": "http://search.ebay.com/search/search.dll?satitle=@@@",
"f": "http://www.fandango.com/GlobalSearch.aspx?q=@@@",
"faq": "http://www.gamefaqs.com/search/index.html?platform=0&s=s&game=@@@",
"g": "http://www.google.com/search?q=@@@",
@indirect
indirect / semantic_summary.rb
Created July 30, 2012 10:08 — forked from chriseppstein/semantic_summary.rb
This ruby script will summarize the html5 semantic structure of a webpage so that you can more easily ensure the page is correct.
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
url = ARGV[0]
class Document < Nokogiri::XML::SAX::Document
SEMANTIC_CONTAINERS = %w(body article section nav aside hgroup header footer)
COUNT_ELEMENTS = %w(p a)