Skip to content

Instantly share code, notes, and snippets.

View JRHeaton's full-sized avatar

John Heaton JRHeaton

View GitHub Profile
@JRHeaton
JRHeaton / yugiohlist.js
Last active May 30, 2024 16:32
Scrapes the current forbidden/limited list for Yu-Gi-Oh! cards and converts it to JSON.
var _ = require('underscore')
var cheerio = require('cheerio')
var request = require('request')
var println = console.log
request('http://www.yugioh-card.com/en/limited/', function (err, res, body) {
var $ = cheerio.load(body)
var cards = []
@JRHeaton
JRHeaton / failingrepl.swift
Created December 15, 2014 01:13
functional style repl
// see line 65 for program
// binary currying
func curry<T, U, V>(f: (T, U) -> V) -> T -> U -> V {
return { x in { y in f(x, y) }}
}
// binary uncurry
func uncurry<T, U, V>(f: T -> U -> V) -> (T, U) -> V {
return { f($0)($1) }
@JRHeaton
JRHeaton / FunctionComposition.swift
Last active August 29, 2015 14:11
Composing/partially applying unary/binary functions
// binary currying
func curry<T, U, V>(f: (T, U) -> V) -> T -> U -> V {
return { x in { y in f(x, y) }}
}
// binary uncurry
func uncurry<T, U, V>(f: T -> U -> V) -> (T, U) -> V {
return { f($0)($1) }
}
//
// GSAppDelegate.m
// Fart
//
// Created by John Heaton on 5/16/14.
// Copyright (c) 2014 John Heaton. All rights reserved.
//
#import "GSAppDelegate.h"
#import <AFNetworking/AFNetworking.h>
@JRHeaton
JRHeaton / MK.log
Last active August 29, 2015 13:59
********** Running Test: 'Multiple Inheritance' **********
[PASS] ~ [<Double>]
-- (tested with MKVirtualSource -> MKEndpoint -> MKObject.objectWithUniqueID)
[PASS] ~ [<Single>]
-- (tested with MKEndpoint -> MKObject.numberOfSources)
[PASS] ~ [<Direct>]
-- (tested with MKVirtualSource.virtualSourceNamed)
----------------------------------------------------------
********** Running Test: 'Native Module (Dylib)' **********
[PASS] ~ [<Module loads successfully>]

Keybase proof

I hereby claim:

  • I am jrheaton on github.
  • I am jrheaton (https://keybase.io/jrheaton) on keybase.
  • I have a public key whose fingerprint is F4FE ED5F 64EE EA6D 0FE2 03DC DE64 BE22 FCD9 0049

To claim this, I am signing this object:

JBP:~ John$ cat c.m
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <AppKit/AppKit.h>
int main() {
@autoreleasepool {
NSLog(@"%@", @[ (id)[NSColor blueColor].CGColor ]);
}
}JBP:~ John$ clang c.m -o c -framework Foundation -framework AppKit
#include <CoreFoundation/CoreFoundation.h>
void xcselect_trigger_install_request(const char *str) {
CFMutableDictionaryRef options;
CFStringRef toolNameKey, toolName;
CFDataRef optionsData;
options = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
toolNameKey = CFStringCreateWithCString(NULL, "tool-name", kCFStringEncodingMacRoman);
toolName = CFStringCreateWithCString(NULL, str, kCFStringEncodingMacRoman);
for(var i=0;i<client.numDevices;++i) {
var d = client.deviceAtIndex(i);
if(isLaunchpad(d)) {
d.reset();
for(var i=0;i<8;++i) {
for(var y=0;y<8;++y) {
d.wait(.05)
.sendMIDI([0x90, (y*16)+i, Math.floor(Math.random() * (127 - 20 + 1)) + 20])
- (void)analyzeImageWithCompletion:(void (^)())block {
NSParameterAssert(block);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
CFDataRef data = CGDataProviderCopyData(CGImageGetDataProvider(self.image.CGImage));
UInt8 *buf = (UInt8 *)CFDataGetBytePtr(data);
size_t width = CGImageGetWidth(self.image.CGImage);
size_t height = CGImageGetHeight(self.image.CGImage);