Skip to content

Instantly share code, notes, and snippets.

import re
from jinja2 import Markup
from SOMEOTHERLIBRARYFOROTHERSTUFF import format_user_input
def strip_auth_tokens(value):
from classlet.models import auth_token_re
return auth_token_re.sub(u'', value)
@brandonbloom
brandonbloom / Notification.rb
Created August 26, 2011 08:27
Demonstration of with_scope for class methods which operate on scoped records
class Notification < ActiveRecord::Base
belongs_to :user
scope :for_user, lambda { |user| where(:user_id => user.id) }
scope :unexpired, where('expired_at is null')
delf self.expire!
with_scope do
@brandonbloom
brandonbloom / cancan.rb
Created August 30, 2011 22:48 — forked from clyfe/cancan.rb
Monkey patch for cancan issue #327
# monkey-patch https://github.com/ryanb/cancan/issues/327
# put in Rails.root/config/initializers/cancan.rb
module CanCan
module ModelAdapters
class ActiveRecordAdapter
private
# fix nested imbrication
def merge_conditions(sql, conditions_hash, behavior)
if conditions_hash.blank?
queue = []
providerA = (args...) ->
console.log args
providerB = (args...) ->
alert args
doRequest = (args...) ->
queue.push args
ABAP
filter remove_matches ^\*
extension abap
3rd_gen_scale 5.00
ADSO/IDSM
filter remove_matches ^\s*\*[\+\!]
extension adso
3rd_gen_scale 3.00
AMPLE
filter remove_matches ^\s*//
" Configure plugin loading.
" This `filetype` dance is to correctly handle various
" environments and their defaults for file type detection
" and a weird OS X bug which causes a non-zero exit code.
filetype on
filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
filetype plugin indent on
syntax on
set fuoptions=maxvert,maxhorz
" Enforce line length
highlight OverLength ctermbg=lightred ctermfg=black guibg=#ffd5d5
match OverLength /\%80v.\+/
set guifont=Droid\ Sans\ Mono:h13,Consolas:h14
" Highlight all instances of the word under the cursor.
- ['foo', 'bar']
- ['a', 'b']
#!/bin/bash
export APP_ENV=$1
shift
if [ -z "$APP_ENV" ]; then
echo "Usage: $(basename $0) APP_ENV [ARGUMENTS...]"
echo "ARGUMENTS are forwarded to $(which env)"
exit 1
fi