Skip to content

Instantly share code, notes, and snippets.

View kylemcdonald's full-sized avatar

Kyle McDonald kylemcdonald

View GitHub Profile
### Keybase proof
I hereby claim:
* I am kylemcdonald on github.
* I am kylemcdonald (https://keybase.io/kylemcdonald) on keybase.
* I have a public key whose fingerprint is 50DA 00A9 1EB3 C84D 7A56 9FAD 3ACA C174 01F5 8612
To claim this, I am signing this object:
@kylemcdonald
kylemcdonald / main.cpp
Last active August 29, 2015 14:02
Playing with path optimization ideas.
#include "ofMain.h"
#include "ofxCv.h"
class ofApp : public ofBaseApp {
public:
void setup() {
bestDiff = 0;
swaps = 64 * 64;
n = 32;
for(int y = 0; y < n; y++) {
@kylemcdonald
kylemcdonald / Matlab.pde
Last active August 29, 2015 14:02
Lomb-Scargle periodogram for Processing, ported from Matlab code, so it's very idiosyncratic and non-idiomatic. Original code published in "Ice Ages and Astronomical Causes: Data, Spectral Analysis and Mechanisms" available at http://books.google.com/books?id=P8ideTkMQisC&pg=PA289&dq=spectral+lomb+scargle&hl=en
float[] hann(float[] x) {
int n = x.length;
float[] result = new float[n];
for(int i = 0; i < n; i++) {
float weight = .5 * (1 - cos((TWO_PI * i) / (n - 1)));
result[i] = x[i] * weight;
}
return result;
}
@kylemcdonald
kylemcdonald / BrowseCapture.scpt
Created June 25, 2014 23:40
Records video from your webcam whenever you are visiting a specific site.
global targetDomain
global folderName
-- options
set targetDomain to "dropcam.com"
set folderName to (path to desktop as text) & "Dropcam"
-- main code
global recordingFile
global newMovieRecording
@kylemcdonald
kylemcdonald / spotify-scrape.py
Last active August 29, 2015 14:05
Scrape a list of Spotify track IDs for JSON and preview URLs. Can handle very large lists of tracks by using subdirectories based on the track ID. Picks up where it lefts off. Ignores errors during downloading.
#!/usr/bin/env python
import json, urllib
import os.path
import subprocess
import argparse
from subprocess import call
parser = argparse.ArgumentParser(
description='Scrape a list of Spotify track IDs for JSON and preview URLs.')
@kylemcdonald
kylemcdonald / recruiting
Created September 2, 2014 19:51
Form response to recruiting emails.
MIME-Version: 1.0
Date: Tue, 2 Sep 2014 15:36:38 -0400
Subject: Re: Introducing ████████
From: Kyle McDonald <kyle@kylemcdonald.net>
To: ███████ █████ <███████@█████████.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
hi,
@kylemcdonald
kylemcdonald / englishman.md
Last active August 29, 2015 14:06
liberator variations: the englishman

Hello!

I've been asked to produce a print of this piece for an exhibition:

Unfortunately the image was made from a model that was only meant to be rendered, not printed.

@kylemcdonald
kylemcdonald / show_post.py
Created September 24, 2014 22:04
Shows anything sent over POST.
#!/usr/bin/python
import time
import BaseHTTPServer
import cgi
from pprint import pprint
HOST_NAME = 'localhost'
PORT_NUMBER = 9000
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
@kylemcdonald
kylemcdonald / 1024x768-grid.png
Last active August 29, 2015 14:07
Keystone check script for Processing.
1024x768-grid.png
@kylemcdonald
kylemcdonald / gcd.cpp
Last active August 29, 2015 14:07
Grand central dispatch examples courtesy of @HalfdanJ
// group of for loops with waiting
int m, n;
dispatch_group_t group = dispatch_group_create();
dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH,0), ^{
// before all parallel m
dispatch_apply(m, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^(size_t i) {
// parallel m code with i for index
});
// after all parallel m
});