Skip to content

Instantly share code, notes, and snippets.

View AndersonFirmino's full-sized avatar
🐍
📜 🎼 🎮 🐧 🦆

Anderson Araujo AndersonFirmino

🐍
📜 🎼 🎮 🐧 🦆
View GitHub Profile
@banksean
banksean / mersenne-twister.js
Created February 10, 2010 16:24
a Mersenne Twister implementation in javascript. Makes up for Math.random() not letting you specify a seed value.
/*
I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace
so it's better encapsulated. Now you can have multiple random number generators
and they won't stomp all over eachother's state.
If you want to use this as a substitute for Math.random(), use the random()
method like so:
var m = new MersenneTwister();
@sanxiyn
sanxiyn / lisp.c
Created August 14, 2010 04:16
Lisp
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
enum type {
NIL,
@ejconlon
ejconlon / trampoline.py
Created January 30, 2011 05:03
Tail-Recursion helper in Python
#!/usr/bin/env python
"""
Tail-Recursion helper in Python.
Inspired by the trampoline function at
http://jasonmbaker.com/tail-recursion-in-python-using-pysistence
Tail-recursive functions return calls to tail-recursive functions
(themselves, most of the time). For example, this is tail-recursive:
@kennethreitz
kennethreitz / 0_urllib2.py
Created May 16, 2011 00:17
urllib2 vs requests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
@andrewwatts
andrewwatts / underscore_dict.py
Created October 24, 2011 04:18
a dict that forces keys, which are likely camelCase, into under score keys.
class underscore_dict(dict):
"""
a dict like object that forces key to be pythonic and follow the underscore
convention.
eg::
>>> d = underscore_dict(dict(myKey='my_value'))
>>> print d
'my_key': 'my_value'}
@cemk
cemk / linebreak.py
Created October 29, 2011 14:52
Creating linebreaks and paragraphs in Jinja2/Flask à la Django Style
import re
from jinja2 import evalcontextfilter, Markup, escape
@app.template_filter()
@evalcontextfilter
def linebreaks(eval_ctx, value):
"""Converts newlines into <p> and <br />s."""
value = re.sub(r'\r\n|\r|\n', '\n', value) # normalize newlines
paras = re.split('\n{2,}', value)
@smebberson
smebberson / .gitignore
Created January 9, 2012 06:46
Express simple authentication example
node_modules
*.swp
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@sanchitgangwar
sanchitgangwar / snake.py
Created March 22, 2012 12:38
Snakes Game using Python
# SNAKES GAME
# Use ARROW KEYS to play, SPACE BAR for pausing/resuming and Esc Key for exiting
import curses
from curses import KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN
from random import randint
curses.initscr()
win = curses.newwin(20, 60, 0, 0)
@madevelopers
madevelopers / qunit-template.html
Created March 25, 2012 06:39
HTML: qunit template
<html>
<head>
<title>Untitled Test</title>
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script type="text/javascript" src="tests.js"></script>
</head>