Skip to content

Instantly share code, notes, and snippets.

View coleww's full-sized avatar

Cole Willsea coleww

  • (=^.^=)
  • Berkeley, CA
View GitHub Profile
@coleww
coleww / gist:7713436
Created November 29, 2013 23:41
Haiku Ebooks NaNoGenMo snapshot
Baby I can teach / you how to be a player / like I'm bellamy
Written by @glamglam___
Carries apartment / in sex in the city is / perfect I want it
Written by @ShannonJF_
When I'm like getting / ready and you're bugging me / I'm the biggest bitch
Written by @DeborahMercedes
I have the worst head / ache and playing a game with / Collin did not help
@coleww
coleww / gist:8379123
Created January 12, 2014 00:58
4'33"
puts "the performance is beginning now"
sleep 255
puts "the performance has ended"
@coleww
coleww / gist:9403691
Last active August 29, 2015 13:57
Do two lines intersect? Processing/Java
//adapted from http://wiki.processing.org/w/Line-Line_intersection
//I do not understand how or why this works.
boolean intersects(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) {
float bx = x2 - x1;
float by = y2 - y1;
float dx = x4 - x3;
float dy = y4 - y3;
float b_dot_d_perp = bx * dy - by * dx;
@coleww
coleww / gist:9404486
Created March 7, 2014 02:55
Color picker for Processing
//TIRED OF INT(RANDOM(0, 255)) ALL OVER THE PLACE?
//get an array of colors from an image
//takes path to image, num of colors to grab, and whether to pick an even distribution or at random
color[] pickColors(String path, int numColors, boolean ordered) {
color[] colors = new color[numColors];
PImage img = loadImage(path);
img.loadPixels();
int numPixels = img.width * img.height;
@coleww
coleww / gist:9438486
Created March 8, 2014 20:38
pixel array wrapper for haxing the canvas pixels
//dealing with the pixel data from the canvas is a pain
//gotta multiply everything by four everywhere all the time
//made an object to wrap up all that badness
//a "pixel" is a 4 element array. 0 => R, 1 => G, 2 => B, 3 => A
var PixelArray = root.PixelArray = function(ctx, w, h){
this._pixels = ctx.getImageData(0, 0, w, h).data;
this.w = w;
this.h = h;
this.numPixels = this._pixels.length / 4;
@coleww
coleww / drums.js
Created March 29, 2014 20:42
probabilistic web audio drum machine
var samples = {
kick: new Wad({source: '/samples/kick.wav'}),
chh: new Wad({source: '/samples/chh.wav'}),
snare: new Wad({source: '/samples/snare.wav'}),
ohh: new Wad({source: '/samples/ohh.wav'}),
cym: new Wad({source: '/samples/cym.wav'}),
shkr: new Wad({source: '/samples/shkr.wav'}),
ltom: new Wad({source: '/samples/ltom.wav'}),
mtom: new Wad({source: '/samples/mtom.wav'}),
htom: new Wad({source: '/samples/htom.wav'}),
@coleww
coleww / gist:10149906
Last active August 29, 2015 13:58
nothing but script tags
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$(function(){
$("<title>").text("JAVASCRIPT PARTY").appendTo($("head"));
$("<div>").addClass("container").css({
"margin": "25px",
"width": "500px",
"border": "1px black solid",
"padding": "15px",
@coleww
coleww / gist:11376678
Created April 28, 2014 16:14
as an agile scrum developer...
i would like to be issued a ticket,
and then click on a link,
which opens related files in sublime text,
and also opens related comps,
and opens a hipchat private message with the related lead,
and pulls from develop
and checks out a new branch named with my initials and part of the issue title,
@coleww
coleww / gist:61bd87e71ee2d40b2db7
Created May 27, 2014 23:44
net art project # 7

buy large quantity of branded consumer goods that are branded with cartoon mascots or somesuch advertising atrocities

  1. cheez its
  2. kool aid
  3. cheetos
  4. other stuff
  5. things

acquire a color printer.

# GIT THEORY
* git status is modified to append an index before each filename
cole@machine:~/PROJECTS/gtr-bf$ gs
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# 0 - TEST.MD