Skip to content

Instantly share code, notes, and snippets.

Avatar

Kyle McDonald kylemcdonald

View GitHub Profile
View gist:e453d907b0dd25e8093d
### 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 Aug 29, 2015
Playing with path optimization ideas.
View main.cpp
#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 Aug 29, 2015
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
View Matlab.pde
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 Jun 25, 2014
Records video from your webcam whenever you are visiting a specific site.
View BrowseCapture.scpt
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 Aug 29, 2015
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.
View spotify-scrape.py
#!/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 Sep 2, 2014
Form response to recruiting emails.
View recruiting
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 Aug 29, 2015
liberator variations: the englishman
View englishman.md

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 Sep 24, 2014
Shows anything sent over POST.
View show_post.py
#!/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 Aug 29, 2015
Keystone check script for Processing.
@kylemcdonald
kylemcdonald / gcd.cpp
Last active Aug 29, 2015
Grand central dispatch examples courtesy of @HalfdanJ
View gcd.cpp
// 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
});