Skip to content

Instantly share code, notes, and snippets.

View girasquid's full-sized avatar
🦐

Luke Hutscal girasquid

🦐
View GitHub Profile
@girasquid
girasquid / middleware.py
Created December 23, 2009 21:45
Basic, quick profiling middleware.
from django.http import HttpResponse
from cStringIO import StringIO
import cProfile, pstats, sys
from django.db import connection
class ProfileMiddleware():
def process_view(self, request, callback, callback_args, callback_kwargs):
if 'profile' in request.GET:
self.profiler = cProfile.Profile()
args = (request,) + callback_args
## I'm not sure where I found this, or who to attribute it to. Thanks, whoever you are!
import sys
import time
import socket
import marshal
# the dumbest code you will ever see. i love it.
def server():
<% 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
/*
* 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:
python -m smtpd -n -c DebuggingServer localhost:1025
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)]/"
}
## How to create a user in Authlogic
User.create(:username => 'foo', :password => 'bar', :password_confirmation => 'bar')
@girasquid
girasquid / Controllers.as
Last active September 17, 2015 02:21
Kinda-bad multi-controller helper library, loosely modelled off KeyActionBinder but simpler. Supports XBone, PS3 DS, and Logitech F310 (DirectInput mode) on OS X.
package controllers {
import com.junkbyte.console.ConsoleChannel;
import flash.events.GameInputEvent;
import flash.ui.GameInput;
import flash.ui.GameInputDevice;
public class Controllers {
private static const channel:ConsoleChannel = new ConsoleChannel("Controllers");
private static var _input:GameInput;
# 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' />