Skip to content

Instantly share code, notes, and snippets.

View wjlafrance's full-sized avatar
🐶
Wondering if Github is becoming a social network.

William LaFrance wjlafrance

🐶
Wondering if Github is becoming a social network.
View GitHub Profile
@wjlafrance
wjlafrance / gist:5158147
Last active December 14, 2015 22:28
I opened a file in Interface Builder!
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="2844" systemVersion="12C60" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" useAutolayout="YES" initialViewController="2">
+ <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="3084" systemVersion="12C60" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" useAutolayout="YES" initialViewController="2">
<dependencies>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1930"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="2083"/>
</dependencies>
//
// WJLSideBySideToAnaglyphFilter.h
//
// Copyright (c) 2013 William LaFrance
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@wjlafrance
wjlafrance / NSObject+Switch.h
Created April 4, 2013 23:59
Switching on objects
//
// NSObject+Switch.h
//
#import <Foundation/Foundation.h>
@interface NSObject (Switch)
- (void)switch:(NSDictionary *)cases default:(void (^)(id obj))defaultBlock;
Fri Apr 12 19:16:32 2013
panic(cpu 2 caller 0xffffff800dab7e95): Kernel trap at 0xffffff800daa3742, type 14=page fault, registers:
CR0: 0x0000000080010033, CR2: 0x0000000020000038, CR3: 0x000000005073302e, CR4: 0x00000000000606e0
RAX: 0x0000000000000000, RBX: 0xffffff8027b9d5a0, RCX: 0x0000000000000000, RDX: 0x0000000020000000
RSP: 0xffffff81de883450, RBP: 0xffffff81de8834a0, RSI: 0x0000000000000040, RDI: 0x000000000018952d
R8: 0xffffff804ca9a258, R9: 0x0000000000002000, R10: 0x0000000000000000, R11: 0x0000000105111000
R12: 0xffffff81de883770, R13: 0xffffff804ca9a200, R14: 0x00000001717d7000, R15: 0xffffffffffffffbf
RFL: 0x0000000000010246, RIP: 0xffffff800daa3742, CS: 0x0000000000000008, SS: 0x0000000000000000
Fault CR2: 0x0000000020000038, Error code: 0x0000000000000000, Fault CPU: 0x2
@wjlafrance
wjlafrance / gist:5499508
Created May 2, 2013 01:01
find the bottom turtle
int i = 0;
id turtle = sender;
do {
turtle = [turtle superview];
NSLog(@"turtle %d: %@", i++, turtle);
} while (turtle != nil);
NSLog(@"reached the bottom turtle");
@wjlafrance
wjlafrance / cleanmem.c
Created May 2, 2013 01:49
Does your compiler clean up after you?
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
void heapTest() {
int heapsize = 1024 * 1024; // 1MB
uint8_t *data = malloc(heapsize);
for (int i = 0; i < heapsize; i++) {
if (data[i] != 0) {
printf("unclean heap\n");
@wjlafrance
wjlafrance / gist:5541744
Created May 8, 2013 16:40
Take the diff of the latest commit (difference between HEAD and the prior commit) and put it in patch.txt. Useful for code reviews and stuff.
git diff `git log -n1 --skip 1 | grep commit | awk '{print $2}'` HEAD > patch.txt
@wjlafrance
wjlafrance / rng.asm
Last active December 21, 2015 18:19
; $ nasm -f macho rng.asm && ld -macosx_version_min 10.7 -e _main -lc -o rng rng.o && ./rng
BITS 32
%define sys_exit 1
%define EXIT_SUCCESS 0
; ----------------------------------------
section .text
/**
* Creates a dispatch_once style singleton.
*
* SINGLETON(NSString *awesomeString)
* awesomeString = [NSString stringWithFormat:@"%@ %@", @"composed", @"string"];
* SINGLETON_END(awesomeString)
*/
#define SINGLETON(name) static name; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{
#define SINGLETON_END(name) }); return name;
@wjlafrance
wjlafrance / gist:8396473
Created January 13, 2014 08:18
Can't trace route to Battle.net
[02:14:32] [lafrance@defiant ~]$ traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 64 hops max, 52 byte packets
1 10.0.1.1 (10.0.1.1) 1.562 ms 1.041 ms 0.851 ms
2 10.135.192.1 (10.135.192.1) 8.983 ms 11.382 ms 7.915 ms
3 dtr01ftbgwi-tge-0-6-0-3.ftbg.wi.charter.com (96.34.25.58) 7.827 ms 9.392 ms 9.210 ms
4 crr01ftbgwi-bue-4.ftbg.wi.charter.com (96.34.18.108) 15.835 ms 18.028 ms 11.863 ms
5 crr01euclwi-bue-1.eucl.wi.charter.com (96.34.16.77) 15.964 ms 23.221 ms 25.005 ms
6 bbr01euclwi-bue-4.eucl.wi.charter.com (96.34.2.4) 26.253 ms 15.519 ms 15.766 ms
7 bbr02euclwi-bue-5.eucl.wi.charter.com (96.34.0.7) 19.720 ms 17.853 ms 17.133 ms
8 bbr01chcgil-bue-1.chcg.il.charter.com (96.34.0.9) 28.908 ms 27.110 ms 23.751 ms