This file contains hidden or 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 file downloader for Pythonista by OMZ Software | |
# By: EJM Software ---- http://ejm.cloudvent.net | |
# Source: https://gist.github.com/89edf288a15fde45682a | |
# ***************************************** | |
# This simple script uses the requests module to download files | |
# and the ui module to show a progress bar | |
# You can use this bookmarklet to download files from Safari: | |
# javascript:window.location='pythonista://filedownloader?action=run&argv='+encodeURIComponent(document.location.href); | |
import ui, console, clipboard, sys, requests, zipfile |
This file contains hidden or 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
memo = {1:1} | |
def fact(n): | |
global memo | |
if not n in memo: | |
if n > max(memo) + 500: | |
fact(min(n, max(memo)+500)) | |
memo[n] = n * fact(n-1) | |
return memo[n] | |
if __name__ == "__main__": |
This file contains hidden or 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 random import randint, choice | |
RIGHT,LEFT,UP,DOWN = 'right','left','up','down' | |
DIRECTIONS = { | |
'r': RIGHT, | |
'l': LEFT, | |
'u': UP, | |
'd': DOWN | |
} | |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
import scene | |
keyboard_layouts = ( | |
''' | |
q w e r t y u i o p del | |
a s d f g h j k l return | |
z x c v b n m , . shift | |
.?123 space .?123 |
This file contains hidden or 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 random import randint | |
class Die(object): | |
def __init__(self, sides=None): | |
if isinstance(sides, int): | |
self.sides = sides | |
else: | |
self.sides = 6 | |
def roll(self): | |
return randint(1, self.sides) | |
class Dice(object): |
This file contains hidden or 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 splice(l, index = 0, length = 1, *args): | |
temp = l[index:index + length-1] | |
del l[index:index + length-1] | |
for i in range(len(args)): | |
l.insert(index+i, args[i]) | |
return temp | |
def fSelect(): | |
'''Allows user to select file | |
and returns the full path''' | |
import os |
This file contains hidden or 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
class Board(list): | |
def __init__(self): | |
for i in range(9): | |
self.append('-') | |
def isWin(self): | |
''' | |
Returns true if either player is winning else returns false | |
''' | |
# check if any of the rows has winning combination | |
for i in range(3): |
This file contains hidden or 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
class game: | |
def __init__(self): | |
#Set up variables | |
self.items = {"map":[-1,-1], "knife":[2,0], "scissors":[2,0]} | |
self.coords = [0,0] | |
self.locations = [ | |
["You are in a large open field. There is a house to the south and the field extends to the east.", | |
"You are in a large open field. The field extends to the west and a dense forest surrounds you.", | |
"", | |
"You are surrounded by trees. There appears to be more light to the east.", |
This file contains hidden or 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
prompts = [ | |
["You enter a dark room with two doors. Do you want to: (1) Go through the east door or (2) Go through the west door.", 2, 3], | |
["You died."], | |
["You are in a room with a big green troll. Do you want to: (1) Attack him or (2)Go through the west door.", 1, 0], | |
["You are on a balcony. Do you want to: (1) Go inside or (2) jump off the balcony", 0, 1] | |
] | |
situation = 0 | |
while situation != 1: |
This file contains hidden or 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 random import randint | |
max = randint(1, 1000) | |
number = randint(0, max) | |
guess = -1 | |
print "I'm thinking of a number between 0 and %d!" %max | |
while True: | |
try: | |
guess = int(raw_input("Guess a Number: ")) | |
if guess==number: | |
print "Correct!" |