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 random | |
print('''Welcome to the Slot Machine Simulator | |
You'll start with $50. You'll be asked if you want to play. | |
Answer with yes/no. you can also use y/n | |
No case sensitivity in your answer. | |
For example you can answer with YEs, yEs, Y, nO, N. | |
To win you must get one of the following combinations: | |
BAR\tBAR\tBAR\t\tpays\t$250 | |
BELL\tBELL\tBELL/BAR\tpays\t$20 | |
PLUM\tPLUM\tPLUM/BAR\tpays\t$14 |
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/python | |
import argparse | |
import cgi | |
import math | |
import os | |
import sys | |
from PIL import Image | |
import pybloomfilter # https://github.com/axiak/pybloomfiltermmap |
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
""" | |
Using Jinja2 with Django 1.2 | |
Based on: http://djangosnippets.org/snippets/2063/ | |
To use: | |
* Add this template loader to settings: `TEMPLATE_LOADERS` | |
* Add template dirs to settings: `JINJA2_TEMPLATE_DIRS` | |
If in template debug mode - we fire the template rendered signal, which allows | |
debugging the context with the debug toolbar. Viewing source currently doesnt |
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
try: | |
from django.core.management import setup_environ | |
import settings | |
setup_environ(settings) | |
print 'imported django settings' | |
try: | |
exec_strs = ["from %s.models import *"%apps for apps in settings.INSTALLED_APPS ] | |
for x in exec_strs: | |
try: | |
exec(x) |
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 | |
import urllib2 | |
import cookielib | |
import re | |
import xml.dom as dom | |
import xml.dom.minidom as minidom | |
from BeautifulSoup import BeautifulSoup, Tag, Comment, NavigableString |
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 __future__ import with_statement | |
import os,sys | |
def find_condition(filename,condition): | |
with open(filename) as f: | |
for i in f: | |
i = i.strip() | |
data = i.split('|') | |
if condition == data[2]: | |
yield i |
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
javascript:(function(d,s,h,B,X,z,c,n,i,b,x,y,m,u,f,T,W,H,V,K){function Z(n){with(n=n.style)position='absolute',left=0,top=0,width=W,height=H,zIndex=1e6;return n}W=X*s,H=h*s;with(Z(n=d.createElement('div')))background='#ffe',opacity=0.7;Z(c=d.createElement('canvas')),c.width=W,c.height=H;d.body.insertBefore(c,d.body.firstChild),d.body.insertBefore(n,c);c=c.getContext('2d'),c.fillStyle='#000';i=X;while(--i>=0)z[i]=[];function R(){return 0|Math.random()*B.length}function r(x,y){c.fillRect(x*s+1,y*s+1,s-2,s-2)}function t(x,y,b){i=4;while(i--)r(x+(b&3),y+((b>>=2)&3)),b>>=2}function D(){n=h;while(--n>0){m=X;while(--m>=0){z[m][n]&&r(m,n)}}}function C(x,y,b){i=4;do{m=x+(b&3),n=y+((b>>=2)&3),b>>=2;}while(m>=0&&m<X&&n<h&&!z[m][n]&&--i);return i}function l(){if(!(T++%2510))if(C(x,y+1,b)){if(++V>3){i=4;while(i--)z[x+(b&3)][y+((b>>=2)&3)]=1,b>>=2;b=B[R()];x=4,y=V=0;}}else{V=0,++y};K==72?C(x-1,y,b)||x--:K==76?C(x+1,y,b)||x++:K==74?T=0:0;c.clearRect(0,0,W,H);D();t(x,y,b)}K=T=y=0,x=4,b=B[R()],d.addEventListener('keydown',fun |
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 | |
import hashlib | |
import sys | |
if __name__ == '__main__': | |
i = bytes(sys.argv[1],'utf8') | |
k = hashlib.md5(i).hexdigest() | |
print(k) |
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 python | |
import vobject | |
from cStringIO import StringIO | |
import os, sys, string | |
''' | |
Simple script to parse an Apple Addressbook export file and | |
turn it into a Mutt aliases file | |
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 python | |
# encoding: utf-8 | |
from twill import * | |
import urllib2,re | |
USERNAME = 'YOUR USERNAME' | |
PASSWORD = 'YOUR PASSWORD' | |
BLOG_LIST = [ |
NewerOlder