Skip to content

Instantly share code, notes, and snippets.

View JRHeaton's full-sized avatar

John Heaton JRHeaton

View GitHub Profile
- (void)analyzeImageWithCompletion:(void (^)(NSArray *values))block {
NSParameterAssert(block);
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);
NSMutableArray *amps = [NSMutableArray array];
@JRHeaton
JRHeaton / gist:6861209
Last active December 24, 2015 20:49
This code subscribes to all currently connected midi devices, listens to the messages they're sending to the computer, and if uses pitch bend messages as scrolling instructions. Try it, it works great! TODO: have continuous scrolling when position is held.
//
// main.c
// midiscroll
//
// Created by John Heaton on 10/6/13.
// Copyright (c) 2013 John Heaton. All rights reserved.
//
#include <CoreFoundation/CoreFoundation.h>
#include <CoreMIDI/CoreMIDI.h>
@JRHeaton
JRHeaton / gist:5228935
Last active December 15, 2015 08:09
10 minute hack to get the launchpad to give me sexy feedback
//
// main.c
// lpfeedback
//
// Created by John Heaton on 3/23/13.
// Copyright (c) 2013 John Heaton. All rights reserved.
//
#include <CoreFoundation/CoreFoundation.h>
#include <CoreMIDI/CoreMIDI.h>
@JRHeaton
JRHeaton / jmp_opcode.c
Created May 31, 2012 05:56
Generate opcode for intel jmp
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
typedef unsigned char byte_t;
typedef struct {
byte_t inst;
byte_t dest[4];
} jmp_inst_t;
@JRHeaton
JRHeaton / gist:2176057
Created March 23, 2012 22:53
binary search for a friend
#include <stdio.h>
#include <stdlib.h>
typedef unsigned char byte;
byte *memfnd(char *buffer, size_t buflen, char *pattern, size_t patlen) {
if(!buffer || !pattern || !buflen || !patlen || patlen > buflen)
return NULL;
for(unsigned long i=0;i<buflen;++i) {
@JRHeaton
JRHeaton / gist:1964177
Created March 3, 2012 03:36
markthatmessage mac beta
/* MarkThatMessage v0.1 beta for OS X
* Designed for use with Messages beta
*
* John Heaton
* [email protected]
* http://github.com/Gojohnnyboi
*/
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
@JRHeaton
JRHeaton / gist:1434228
Created December 5, 2011 16:40
would love some help here
Making all for tweak Locktopus...
Preprocessing Locktopus.xm...
Compiling Locktopus.xm...
In file included from Locktopus.xm:4:
./include/Locktopus/LPApplicationIconController.h:4: error: expected `:' before ‘class’
./include/Locktopus/LPApplicationIconController.h:4: error: expected identifier before ‘class’
./include/Locktopus/LPApplicationIconController.h:4: error: expected `:' before ‘SBApplicationIcon’
./include/Locktopus/LPApplicationIconController.h:4: error: ‘SBIconView’ has not been declared
./include/Locktopus/LPApplicationIconController.h:5: error: expected unqualified-id before ‘class’
./include/Locktopus/LPApplicationIconController.h:7: error: expected unqualified-id before ‘interface’
#include <stdio.h>
#include <sys/stat.h>
int main() {
printf("struct stat (%d bytes)\n\t"
"dev_t = %d;\n\t"
"ino_t = %d;\n\t"
"mode_t = %d;\n\t"
"nlink_t = %d;\n\t"
"uid_t = %d;\n\t"
//
// AMDevice.m
// Can I Jailbreak?
//
// Created by John Heaton on 10/1/11.
// Copyright 2011 GJB Software. All rights reserved.
//
#import "AMDevice.h"
@JRHeaton
JRHeaton / lszip.c
Created May 17, 2011 23:13
List files in a zip archive
#include <stdio.h>
#include <stdint.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
int main(int argc, const char *argv[]) {
struct stat st;