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
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
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
""" | |
A decorator for management commands (or any class method) to ensure that there is | |
only ever one process running the method at any one time. | |
Requires lockfile - (pip install lockfile) | |
Author: Ross Lawley | |
""" | |
import time |
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
/** | |
* Bind and Trigger custom and native events in Prototype | |
* @author Juriy Zaytsev (kangax) | |
* @author Benjamin Lupton (balupton) | |
* @copyright MIT license | |
**/ | |
(function(){ | |
var eventMatchers = { | |
'HTMLEvents': /^(?:load|unload|abort|error|select|hashchange|popstate|change|submit|reset|focus|blur|resize|scroll)$/, |
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
/* Grid */ | |
html:before, html:after { | |
content: ""; | |
position: absolute; | |
top: 0; | |
right: 0; | |
pointer-events: none; | |
/* change to px if you get a scrollbar */ |
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
"""GitHub flavoured markdown: because normal markdown has some vicious | |
gotchas. | |
Further reading on the gotchas: | |
http://blog.stackoverflow.com/2009/10/markdown-one-year-later/ | |
This is a Python port of GitHub code, taken from | |
https://gist.github.com/901706 | |
To run the tests, install nose ($ easy_install nose) then: |
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.core.handlers.base import BaseHandler | |
from django.test.client import RequestFactory | |
class RequestMock(RequestFactory): | |
def request(self, **request): | |
"Construct a generic request object." | |
request = RequestFactory.request(self, **request) | |
handler = BaseHandler() | |
handler.load_middleware() | |
for middleware_method in handler._request_middleware: |
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 http://baagoe.com/en/RandomMusings/javascript/ | |
function Alea() { | |
return (function(args) { | |
// Johannes Baagøe <[email protected]>, 2010 | |
var s0 = 0; | |
var s1 = 0; | |
var s2 = 0; | |
var c = 1; | |
if (args.length == 0) { |
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
/usr/bin/cpp -P -undef -Wundef -std=c99 -nostdinc -Wtrigraphs -fdollars-in-identifiers -C < foo.js |
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
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
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
import inspect | |
def marmoset_patch(func, s, r): | |
source = inspect.getsource(func).replace(s, r) | |
exec source in func.func_globals | |
func.func_code = func.func_globals[func.__name__].func_code | |
def foo(): | |
print 1 | |
print 2 |
OlderNewer