Skip to content

Instantly share code, notes, and snippets.

View girasquid's full-sized avatar
🦐

Luke Hutscal girasquid

🦐
View GitHub Profile
@girasquid
girasquid / gist:1063871
Created July 4, 2011 20:14
Nag the admins when someone leaves a pdb.set_trace() in production
from django.conf import settings
from django.core.mail import mail_admins
def pdb_replacement():
import inspect
current_frame = inspect.currentframe()
info = inspect.getframeinfo(current_frame.f_back.f_back)
mail_admins("pdb left in %s" % info[0], "%s, line #%s" % (info[0], info[1]))
return
def converse(body)
link_to body, '#', :class => 'converse'
end
def converse(body)
link_to body, '#', :class => 'converse'
end
# encoding: utf-8
from bottle import route, request, run, redirect, get, post
@get('/')
def home():
return """
<form action='' method='post'>
<input type='hidden' name='things' value='éøéóí' />
Some unicodé!
<input type='submit' />
## How to create a user in Authlogic
User.create(:username => 'foo', :password => 'bar', :password_confirmation => 'bar')
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
python -m smtpd -n -c DebuggingServer localhost:1025
/*
* Sweet sugar for jQuery's $.data API.
* http://yehudakatz.com/2009/04/20/evented-programming-with-jquery/
*
* Instead of this:
*
* $("#foo").data("foo"); // Get foo
* $("#foo").data("foo", 'bar'); // Set foo
*
* Do this:
<% if @chapter == 'first' %>
<p>Welcome to your adventure page. This is where you'll be able to see what all has happened in the story, in addition to being able to work through it (at your own pace, of course).</p>
<p>The first thing you should do is probably go check out <%= link_to "the Mine", :controller => :mine, :action => :index %>.</p>
<% end %>
def set_chapter
@chapter = nil
if current_user
progress = current_user.progress.split(':')
if progress.first == params[:controller] and progress.second == params[:action]
@chapter = progress.third
end
end
@chapter
end