Skip to content

Instantly share code, notes, and snippets.

View coderifous's full-sized avatar
💭
☕️

Jim Garvin coderifous

💭
☕️
View GitHub Profile
# This unfortunate hack is necessary because ActiveRecord doesn't provide any
# way (clean or otherwise) to circumvent the default_scope when preloading.
#
# Here's a closed-but-unresolved issue that goes into it a bit more:
#
# https://github.com/rails/rails/issues/11036
#
# Example usage:
#
# In this scenario, Product and User may have paranoid deletes, and a
@coderifous
coderifous / Gemfile
Created October 21, 2011 14:53
Test for broken deletes on habtm relations in Mongoid.
source "http://rubygems.org"
# Test passes with version 2.2.3
# gem "mongoid", "2.2.3"
# Test fails with version 2.3.2
gem "mongoid", "2.3.2"
@coderifous
coderifous / gist:1009128
Created June 5, 2011 16:30
SOAP XML "ping" response.
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns0="http://gov.fubar.services/XYZService/"
xmlns:ns1="http://gov.fubar.services/xyzreqeust"
xmlns:ns2="http://gov.fubar.services/xyzresponse"
xmlns:ns3="urn:herp:names:tc:derpy:derp:1.1">
<env:Body>
<ns0:getResponseTypeDef>
@coderifous
coderifous / Bundler aliases.bash
Created February 9, 2011 15:02
Handy aliases for frequently used bundler commands.
alias b='bundle'
# This gets used daily
alias be='b exec'
# Run this whenever there's an update to the Gemfile; regularly used.
alias bi='b install --path vendor'
# Run this the first time you add bundler to a project; rarely used.
alias binit='bi && b package && echo '\''vendor/ruby'\'' >> .gitignore'
@coderifous
coderifous / gist:570645
Created September 8, 2010 19:08
.vimperatorrc extras
" Makes cmd-l use vimperator instead of FF location bar
map <M-l> :o<Space>
" Makes cmd-f use vimperator instead of FF search
map <M-f> /
" Tab opening with vimperator
map <M-t> t
" Makes autocompletion show up automatically
(function(){
// easily digestable document ready
$(function(){
initializeFoo();
initializeBar();
initializeBaz();
});
// non global functions
# Rails Template: something_great.rb
# by Jim Garvin (coderifous)
#
# Useful gems and plugins
#
# * shoulda/mocha/factory girl
# * pacecar for lots of automatic scopes
# * haml
# * sprockets for javascript management
# * will paginate
#!/usr/bin/env ruby
# usage: ruby vcard_skidoosh.rb vcard.vcf
# outputs a bunch of asterisk commands to stdout.
# taste it.
# Cargo culters: look elsewhere for best practices and good coding principles
# Ripped from @rmm5t http://gist.github.com/32998
def format_number(n)
n = n.gsub(/\D/, '')[0...11]