Skip to content

Instantly share code, notes, and snippets.

View chriskau's full-sized avatar

Chris Kau chriskau

  • Silicon Valley, CA
View GitHub Profile
@chriskau
chriskau / gist:1148422
Created August 16, 2011 04:07 — forked from mikeash/gist:837409
Block-based URL connection
// NSURLConnection wrapper
// like NSURLConnection, requires a runloop, callbacks happen in runloop that set up load
@interface LDURLLoader : NSObject
{
NSURLConnection *_connection;
NSTimeInterval _timeout;
NSTimer *_timeoutTimer;
NSURLResponse *_response;
long long _responseLengthEstimate;
NSMutableData *_accumulatedData;
@chriskau
chriskau / NSData+CommonDigest.h
Created August 16, 2011 04:09 — forked from 0xced/NSData+CommonDigest.h
NSData+CommonDigest: The most elegant NSData category for cryptographic hash functions
/*
Licensed under the MIT License
Copyright (c) 2011 Cédric Luthi
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
@chriskau
chriskau / gist:1255571
Created October 1, 2011 03:58
Obj-c Source Batch License Changer
#!/usr/bin/python
import re
import os
import pprint
import subprocess
import time
import Levenshtein
########################################################################
@chriskau
chriskau / vim7.3_mac_install.rb
Created May 17, 2012 20:27 — forked from sirupsen/vim7.3_mac_install.rb
Script to install Vim 7.3 with ruby support for Mac OS X Lion
# requires root permissions in /usr/bin/
star = String.new
8.times { star += "*" }
Star = "\n#{star * 3}\n"
def newblock string
puts "\n#{Star}#{string}#{Star}\n"
end
@chriskau
chriskau / gist:de4bea112eabd95d75115e5e918b5afe
Created February 12, 2018 16:53 — forked from nl5887/gist:9eaad4faac9bf8852092
Creating an animated gif of currently active window in Core Foundation (OSX).
long windowId = kCGNullWindowID;
CGRect *temp = new CGRect;
// get all windows on the current screen
CFArrayRef windowList = CGWindowListCopyWindowInfo(kCGWindowListOptionAll | kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
// find the current window, that will be the first one on layer 0
CFIndex windowNum = CFArrayGetCount(windowList);
for (int i=0;i<(int)windowNum;i++) {
CFDictionaryRef info = (CFDictionaryRef)CFArrayGetValueAtIndex(windowList, i);