Skip to content

Instantly share code, notes, and snippets.

View DanBrink91's full-sized avatar
🤹‍♂️
Juggling some side projects

Dan Brinkman DanBrink91

🤹‍♂️
Juggling some side projects
View GitHub Profile
#! /usr/bin/python
import Image
source = Image.open("test.jpg")
img = source.load()
width = source.size[0]
height = source.size[1]
#! /usr/bin/python
import Image
def average_pixel(x, y, img):
sum_ = [0, 0, 0]
count_ = 0
for y_ in xrange(y-1, y+1):
if y_ >= 0 and y_ <= height:
for x_ in xrange(x-1, x+1):
#! /usr/bin/python
import Image
source = Image.open("less3.png")
img = source.load()
width = source.size[0]
height = source.size[1]
def total_color_difference(pixel, other_pixel):
@DanBrink91
DanBrink91 / less_color.py
Created August 25, 2013 02:15
reduce the amount of colors in an image
#! /usr/bin/python
import Image
source = Image.open("test.jpg")
img = source.load()
width = source.size[0]
height = source.size[1]
reduction_factor =50 # Higher number means less color
@DanBrink91
DanBrink91 / titles.py
Created December 4, 2013 22:58
Countin Words
import json
from collections import Counter
json_data = open('reddits.json')
data = json.load(json_data)
common_words = set(['a', 'about', 'above', 'across', 'after', 'afterwards', 'again', 'against', 'all', 'almost', 'alone', 'along', 'already', 'also', 'although', 'always', 'am', 'among', 'amongst', 'amoungst', 'amount', 'an', 'and', 'another', 'any', 'anyhow', 'anyone', 'anything', 'anyway', 'anywhere', 'are', 'around', 'as', 'at', 'back', 'be', 'became', 'because', 'become', 'becomes', 'becoming', 'been', 'before', 'beforehand', 'behind', 'being', 'below', 'beside', 'besides', 'between', 'beyond', 'bill', 'both', 'bottom', 'but', 'by', 'call', 'can', 'cannot', 'cant', 'co', 'computer', 'con', 'could', 'couldnt', 'cry', 'de', 'describe', 'detail', 'did', 'do', 'done', 'down', 'due', 'during', 'each', 'eg', 'eight', 'either', 'eleven', 'else', 'elsewhere', 'empty', 'enough', 'etc', 'even', 'ever', 'every', 'everyone', 'everything', 'everywhere', 'except', 'few', 'fifteen', 'fifty', 'fill', 'find', 'fire', '
import json
import math
from collections import Counter
sentence = "look at this beautiful piece of grass"
json_data = open('reddits.json')
data = json.load(json_data)
stop_words = set(['a', 'about', 'above', 'across', 'after', 'afterwards', 'again', 'against', 'all', 'almost', 'alone', 'along', 'already', 'also', 'although', 'always', 'am', 'among', 'amongst', 'amoungst', 'amount', 'an', 'and', 'another', 'any', 'anyhow', 'anyone', 'anything', 'anyway', 'anywhere', 'are', 'around', 'as', 'at', 'back', 'be', 'became', 'because', 'become', 'becomes', 'becoming', 'been', 'before', 'beforehand', 'behind', 'being', 'below', 'beside', 'besides', 'between', 'beyond', 'bill', 'both', 'bottom', 'but', 'by', 'call', 'can', 'cannot', 'cant', 'co', 'computer', 'con', 'could', 'couldnt', 'cry', 'de', 'describe', 'detail', 'did', 'do', 'done', 'down', 'due', 'during', 'each', 'eg', 'eight', 'either', 'eleven', 'else', 'elsewhere', 'empty', 'enough', 'etc', 'even', 'ever', 'every', 'everyone', 'everything', 'everywhere', '
import requests
r = requests.get('http://api.openweathermap.org/data/2.5/weather?q=Orland,FL')
print r.json()
@DanBrink91
DanBrink91 / titles.py
Created January 10, 2014 23:16
Calculate which subreddit a title(sentence) should be posted to based on previous titles
import json
import math
from collections import Counter
sentence = "I love this game"
json_data = open('reddits.json')
data = json.load(json_data)
stop_words = set(['a', 'about', 'above', 'across', 'after', 'afterwards', 'again', 'against', 'all', 'almost', 'alone', 'along', 'already', 'also', 'although', 'always', 'am', 'among', 'amongst', 'amoungst', 'amount', 'an', 'and', 'another', 'any', 'anyhow', 'anyone', 'anything', 'anyway', 'anywhere', 'are', 'around', 'as', 'at', 'back', 'be', 'became', 'because', 'become', 'becomes', 'becoming', 'been', 'before', 'beforehand', 'behind', 'being', 'below', 'beside', 'besides', 'between', 'beyond', 'bill', 'both', 'bottom', 'but', 'by', 'call', 'can', 'cannot', 'cant', 'co', 'computer', 'con', 'could', 'couldnt', 'cry', 'de', 'describe', 'detail', 'did', 'do', 'done', 'down', 'due', 'during', 'each', 'eg', 'eight', 'either', 'eleven', 'else', 'elsewhere', 'empty', 'enough', 'etc', 'even', 'ever', 'every', 'everyone', 'everything', 'everywhere', 'except', 'few', 'fi
@DanBrink91
DanBrink91 / subreddits.py
Created January 11, 2014 19:29
scrapping reddit
# Grab some subreddits' titles
import requests
from time import sleep
import json
# Get top 25 subreddits
r = requests.get(r'http://www.reddit.com/subreddits/popular/.json')
subs = {}
data = r.json()
@DanBrink91
DanBrink91 / glitch.js
Created January 14, 2014 01:28
Half-assed glitching attempt
var reader = new FileReader();
var canvas, ctx;
var base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var changes = document.getElementById("changes").value;
var initChange = document.getElementById("initChange").value;
document.getElementById("changes").addEventListener('change', function(e)
{
changes = this.value;
createCanvas(glitch(reader.result));
}, false);