Skip to content

Instantly share code, notes, and snippets.

View ColtonPhillips's full-sized avatar

Colton Phillips ColtonPhillips

View GitHub Profile
@ColtonPhillips
ColtonPhillips / tweeper.py
Created July 22, 2014 11:35
How to tweet dot com
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)
@ColtonPhillips
ColtonPhillips / flickrtweepr.py
Last active August 29, 2015 14:04
Use a python bot to post your flickr pictures to twitter
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=''
@ColtonPhillips
ColtonPhillips / youtube-tweeter.py
Created July 22, 2014 14:59
Flings out links super neat like.
import tweepy
from bs4 import BeautifulSoup
import httplib2
from urllib2 import urlopen
from random import choice
import random
import json
random.seed()
consumer_key=''
@ColtonPhillips
ColtonPhillips / lister.py
Last active August 29, 2015 14:05
Creates a pythonic list of strings from a simple text file, in attempts to save time for certain tasks.
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))
@ColtonPhillips
ColtonPhillips / chance.py
Created August 21, 2014 05:09
A one in N chance that something happens. Lol. So random.
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
@ColtonPhillips
ColtonPhillips / json_decode_tiled.gml
Created August 26, 2014 08:09
Load a Tiled JSON file into GML and make them tiles in the game. This took me so fricking long.
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");
@ColtonPhillips
ColtonPhillips / gol.py
Created September 4, 2014 22:58
Conti's Game of Chince (An implementation of the GOL that I took from a Youtube video
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
@ColtonPhillips
ColtonPhillips / raytracer.py
Created October 18, 2014 06:20
A raytracer I found from reddit
# 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
@ColtonPhillips
ColtonPhillips / quick_rename.py
Created October 21, 2014 09:49
I just wanted a script to rename my JPEG files that my camera created, so it would look better when I upload to flickr.
#!/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))
@ColtonPhillips
ColtonPhillips / rgb2ycbcr.py
Created June 29, 2015 05:44
Converts rgb to ycbcr (YUV - Luminance + Chromanance)
#http://www.picturetopeople.org/p2p/picture_to_people_colors.p2p/color_converter?color_space=RGB&color_channel1=0&color_channel2=0&color_channel3=0
#https://msdn.microsoft.com/en-us/library/ff635643.aspx
#rgb range - [0,255]
#y range - [0,255]
#cb,cr range - [-128,127]
import sys
import time
#r = int(sys.argv[1])