Skip to content

Instantly share code, notes, and snippets.

View capitalist's full-sized avatar
🎯
Focusing

Joe Martinez capitalist

🎯
Focusing
View GitHub Profile
@mislav
mislav / instructions.md
Created June 25, 2010 16:54
Have some commands automatically run when you switch to or from a specific branch

Copy this script to ".git/hooks/post-checkout" in your repository and make it executable:

chmod +x .git/hooks/post-checkout

Tweak it at will. I'm refreshing the bundle and restarting the app server because the Gemfile is different on my "hosted" branch than on other branches.

@mrmemes-eth
mrmemes-eth / Gemfile
Created September 13, 2010 16:24
This terrible thing works
source 'http://rubygems.org'
gem 'bundler', '~> 1.0.0'
gem 'decent_exposure', '~> 1.0.0.rc1'
gem 'devise', '~> 1.1.2'
gem 'haml'
gem 'hassle', :git => 'git://github.com/Papipo/hassle.git'
gem 'pg'
gem 'rails', '3.0.0'
@ernie
ernie / verb.rb
Created November 18, 2010 02:04
One of the reasons I love MetaWhere (I may be biased :))
# Can this be done with strings? Sure. This feels much nicer to me, though.
class Verb < ActiveRecord::Base
belongs_to :verbable, :polymorphic => true
belongs_to :objectifiable, :polymorphic => true
scope :of_interest_to_user, lambda {|u|
where(
(:objectifiable_type.eq % 'User' & :objectifiable_id.eq % u.id) |
(:objectifiable_type.eq % 'Book' & :objectifiable_id.in % u.book_ids)
)
class QueryTracer < ActiveSupport::LogSubscriber
ACCEPT = %r{^(app|config|lib)}.freeze
FRAMES = 5
THRESHOLD = 300 # In ms
def sql(event)
return unless event.duration > THRESHOLD
callers = Rails.
backtrace_cleaner.
@caged
caged / stale.rb
Created January 4, 2011 20:11
Quick script to help you find and deal with old watched repos, forks and owned repos.
#!/usr/bin/env ruby
#
# Quick hack to help you find and deal with old watched repos, forks and owned repos.
#
# It will ask you to confirm once if you want to unwatch a repo.
#
# You can't unwatch your own repos, so they will need to be deleted.
# THIS SCRIPT WILL ASK YOU FOR CONFIRMATION TWICE BEFORE IT DELETES A REPO.
#
require 'rubygems'
diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim
index 07358b2..3b40da3 100644
--- a/ftplugin/ruby.vim
+++ b/ftplugin/ruby.vim
@@ -29,8 +29,11 @@ endif
if exists("loaded_matchit") && !exists("b:match_words")
let b:match_ignorecase = 0
+ " Go go gadget match! This ignores if, unless, while, and until if they come
+ " after non-spaces, meaning they're a post condition.
# Extend jQuery objects with Underscore collection methods.
#
# Each collection method comes in two flavors: one prefixed
# with _, which yields a bare DOM element, and one prefixed
# with $, which yields a jQuery-wrapped element.
#
# So if `this` is a jQuery object, instead of:
#
# _.max @, (el) -> $(el).height()
#
@fuba
fuba / default.js
Created May 31, 2011 16:36
dotjs-ify my greasemonkey user scripts
function GM_getValue (key) {
var value = localStorage.getItem('GM_'.key);
if ('undefined' == typeof(value)) {
return;
}
return value;
}
function GM_setValue (key, value) {
localStorage.setItem('GM_'.key, value);
# build scopes for owners, producers, and viewers. each scope can be used
# with one, or more, users. for example:
#
# Organization.with_owners(jane, john)
#
{
:owner => %w'owner',
:producer => %w'owner producer',
:viewer => %w'owner producer viewer'
}.each do |name, roles|
@webxl
webxl / grid.js
Created September 21, 2011 17:04
CSS prototyping bookmarklet
javascript:(function(){s1=document.createTextNode('.guidesOn::before { content:""; position:fixed; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAACxEAAAsRAX9kX5EAAAAZdEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjVJivzgAAAAyUlEQVRoQ%2B2abQqAIBBEPW1X6CzdqTv1RUFIipi2o72gPyXV7uybKci5wDZM8xI6dz%2Buvs6pP2Dq81GI2qiiiJkiOzQ97EGHTXUF9XUwYsaI2o1LjyqjpaYwiqDI2YFs2HtI9Wjx2Z0R%2B1ADdmB%2FC7taB0uzCSNqCqOImSIkeyW7xLXMZvqjdzJcS01hFEGRSnbe3miR7JVGgWRXcxkUQRFgj%2F8Y8htGtkJHL%2FvGaGtKd6bU9Z4C%2FCiEZDeCPahIa%2FbbDSNX433mVkIrV5rTnhDyAAAAAElFTkSuQmCC) 50% 0; z-index:1; top:0; right:0; bottom:0; left:0; opacity:.3; pointer-events:none; } * { -webkit-user-modify: read-write; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; } a { -webkit-user-modify: initial; }');s2=document.createTextNode('#a1_z { background-color: #fff; background-color: rgba(255,255,255,.8); float: left; position: fixed; z-index:2; padding: 3px; bo