Skip to content

Instantly share code, notes, and snippets.

View nrrb's full-sized avatar
🤔

Nicholas Bennett nrrb

🤔
View GitHub Profile
@nrrb
nrrb / ImageTile_Locations.pde
Created May 29, 2011 03:30
Subtiling a rectangle with an image, preserving image ratio (language: Processing)
/***********************************************************************************
***********************************************************************************
**
** Author: Nick Bennett
** Email: nick@tothebe.at
** Github: https://github.com/tothebeat
**
** Image Tile - Arbitrary File
** Date Created: October 16, 2009
**
@nrrb
nrrb / AllInOne.py
Last active November 30, 2019 06:47
My first Python script. Replicating and enhancing functionality of a Processing (Java) applet.
from TileImageClass import TileableImage
from TiledImageClass import TiledImage
import random
import Image
#import ImageDraw
import time
target_size = 256
tile_size = 64
image_source_folder = "./images/"
import os
import shutil
import sys
# SEARCH_PATH = '.'
# DESTINATION_PATH = ''
def find_files_by_extension(search_path, extension):
all_files = []
for root, dirs, files in os.walk(search_path):
@nrrb
nrrb / mandelbrot_text.py
Created March 30, 2012 19:32
Mandelbrot set fractal rendering in text mode
def draw_fractal(n_columns=40, n_rows=20,
min_real=-1.5, min_imag=-1.0, max_real=1.0, max_imag=1.0,
max_iterations=200, render_chars = 'abcdefghijklmnopqrstuvw '):
'''
This renders a Mandelbrot set fractal in text mode.
http://en.wikipedia.org/wiki/Mandelbrot_set
Defaults:
def draw_fractal(n_columns=80, n_rows=40,
@nrrb
nrrb / selenium_basics.py
Created April 16, 2012 22:18
Selenium stuffs
from selenium import webdriver
profile = webdriver.FirefoxProfile()
# Set proxy settings to manual
profile.set_preference('network.proxy.type', 1)
# Set proxy to Tor client on localhost
profile.set_preference('network.proxy.socks', '127.0.0.1')
profile.set_preference('network.proxy.socks_port', 9050)
# Disable all images from loading, speeds page loading
# http://kb.mozillazine.org/Permissions.default.image
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
import simplejson
import requests
# How many revisions are returned by each API call
# Keep this at 1 due to https://bugzilla.wikimedia.org/show_bug.cgi?id=29223
rvlimit=1
@nrrb
nrrb / index.html
Created May 8, 2012 05:12 — forked from bunkat/index.html
Simple Scatter Chart Example
<!DOCTYPE html>
<html>
<head>
<title>The d3 test</title>
<style>
.chart {
shape-rendering: crispEdges;
}
.main text {
@nrrb
nrrb / debugwin.py
Created July 1, 2012 10:58 — forked from williame/debugwin.py
can watch variables; opens a window that continuously updates as the variable changes value
import sys, threading, Queue, weakref
try:
import Tkinter
_has_tk = True
_debug_win = None
except ImportError:
# quietly disable ourselves
_has_tk = False
@nrrb
nrrb / kiva_api.py
Created July 22, 2012 22:34
Kiva API
import json
import unicodecsv
import requests
loan_ids_path = './loan_ids.csv'
# Kiva requests, but does not require, that developers use
# an app_id parameter in API requests.
APP_ID = 'edu.northwestern.nick'
NUM_API_CALLS = 0
@nrrb
nrrb / .bashrc
Created August 12, 2012 22:43
my bashrc
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
# Reset
Color_Off='\e[0m' # Text Reset
# Regular Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow