This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% 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 %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python -m smtpd -n -c DebuggingServer localhost:1025 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)]/" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## How to create a user in Authlogic | |
User.create(:username => 'foo', :password => 'bar', :password_confirmation => 'bar') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' /> |