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
#!/usr/bin/env python | |
from os import rename, listdir | |
badprefix = "IMG" | |
fnames = listdir('.') | |
print(fnames) | |
for fname in fnames: | |
if fname.startswith(badprefix): | |
rename(fname, fname.replace(badprefix, 'long_exposure', 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
# http://www.reddit.com/r/tinycode/comments/169ri9/ray_tracer_in_140_sloc_of_python_with_picture/ | |
from math import sqrt, pow, pi | |
from PIL import Image | |
class Vector( object ): | |
def __init__(self,x,y,z): | |
self.x = x | |
self.y = y |
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 neighbors(point): | |
x,y = point | |
yield x + 1, y | |
yield x - 1, y | |
yield x, y + 1 | |
yield x, y - 1 | |
yield x + 1, y + 1 | |
yield x + 1, y - 1 | |
yield x - 1, y + 1 | |
yield x - 1, y - 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
var tilesize = 16; | |
var _string = included_file_to_string("/test.json"); | |
var result = json_decode(_string); | |
var height = ds_map_find_value(result,"height"); | |
var width = ds_map_find_value(result,"width"); | |
var tilesets_list = ds_map_find_value(result,"tilesets"); | |
tilesets_map = ds_list_find_value(tilesets_list,0); | |
var image_width = ds_map_find_value(tilesets_map,"imagewidth") / tilesize; | |
var image_height = ds_map_find_value(tilesets_map,"imageheight") / tilesize; | |
var data_list = ds_map_find_value(result,"data"); |
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
import random | |
random.seed() | |
def chance(_n): | |
return random.randint(1,_n) == _n | |
a=0 | |
for i in range(10000): | |
if (chance(10)): | |
a=a+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
import pprint | |
pp = pprint.PrettyPrinter(indent=4) | |
with open('test.txt', 'r') as listFile: | |
lines = listFile.read().split("\n") | |
with open('out.py', 'a') as outFile: | |
outFile.write(pprint.pformat(lines)) |
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
import tweepy | |
from bs4 import BeautifulSoup | |
import httplib2 | |
from urllib2 import urlopen | |
from random import choice | |
import random | |
import json | |
random.seed() | |
consumer_key='' |
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
import tweepy | |
import flickrapi | |
from bs4 import BeautifulSoup | |
from urllib2 import urlopen | |
from random import choice | |
import random | |
import xml.etree.ElementTree as ET | |
random.seed() | |
consumer_key='' | |
consumer_secret='' |
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
import tweepy | |
from urllib import urlopen | |
from random import randrange | |
from random import choice | |
consumer_key='' | |
consumer_secret='' | |
access_token_key='' | |
access_token_secret='' | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) |
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
#TODO: what about a string with < or > ? what about with </a> ? etc | |
#https://www.google.ca/#q=hat+%22stand+man+'dog'+%22 | |
# hat "stand man 'dog' " | |
my_string = "hat \"stand man 'dog' \"" | |
print("String:") | |
print(my_string) | |
google_string = my_string.replace('"',"%22").replace(" ","%20") | |
print("Google String:") |