Skip to content

Instantly share code, notes, and snippets.

View cbarrett's full-sized avatar
🏴
Revolting

Colin Barrett cbarrett

🏴
Revolting
View GitHub Profile
@cbarrett
cbarrett / NiceURLConnection.m
Created May 31, 2009 05:01
A sketch for an implementation of a better NSURLConnection, NiceURLConnection
// by Colin Barrett (colin at springs and struts dot com)
// I release this sketch to the community under the MIT License.
// No really this is just a sketch I haven't even compiled it or anything.
// Other ides:
// - Failure & success completion selectors ?
// - Single delegate method called on both success and failure.
@interface NiceURLConnection : NSURLConnection {
@cbarrett
cbarrett / run.sh
Created November 30, 2009 23:05
I'm going through the Crenshaw tutorial http://compilers.iecc.com/crenshaw/ but translating from TurboPascal/68K to Python/x86. I've only just begun: I just finished the second section of the tutorial, but I have found this helpful. Works on Snow Leopard
#!/bin/sh
# (c) 2009 Colin Barrett <[email protected]>
# MIT Licensed.
echo ' .cstring
format_string:
.asciz "Result: %d\\n"
.text
.globl _main
_main:
% cat main.py
from config import config, set_config, print_config
print "1: %s" % (config)
set_config({'hello': 'world'})
print "3: %s" % (config)
print_config()
% cat config.py
config = None
@cbarrett
cbarrett / BLOCK bself macro
Created March 16, 2011 04:25
I think this was it. I stopped using it because it made Xcode 3 put all errors or warnings for the block on the line of the macro invocation; total nonstarter.
#define BLOCK(...) ({ __block __typeof__(self) bself = self; __VA_ARGS__(); )}
@cbarrett
cbarrett / .gitignore
Created April 4, 2011 05:35
adium multi nightly changes
.DS_Store
% ls -lah .dropbox ~
total 89776
drwxr-xr-x 11 cbarrett staff 374B May 13 11:40 .
drwxr-xr-x+ 56 cbarrett staff 1.9K Apr 20 18:54 ..
-rw-r--r-- 1 cbarrett staff 33K May 13 11:40 config.db
-rw-r--r-- 1 cbarrett staff 3B May 3 17:29 dropbox.pid
-rw------- 1 cbarrett staff 8.0M May 13 11:40 filecache.db
drwxr-xr-x 5 cbarrett staff 170B Feb 28 2010 finderplugin
-rw-r--r-- 1 cbarrett staff 73B May 3 17:30 host.db
-rw-r--r-- 1 cbarrett staff 24B Aug 23 2010 ignore.db
@cbarrett
cbarrett / SSMutableIndexPathSet.h
Created July 19, 2011 18:04
Represent a set of index paths
//
// SSMutableIndexPathSet.h
// MutableIndexPathSet Test
//
// Created by Colin Barrett on 11/19/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@cbarrett
cbarrett / gist:1157321
Created August 19, 2011 16:53
zsh vcs_info example
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable hg
zstyle ':vcs_info:hg*' formats "%F{green}%b%f"
zstyle ':vcs_info:hg*' actionformats "%F{red}%a%f %F{green}%b%f"
zstyle ':vcs_info:hg*+set-message:*' hooks no-default-branch
function +vi-no-default-branch() {
[[ "${hook_com[branch_orig]}" != "default" ]] && return 0
ret=1
@cbarrett
cbarrett / gist:1642401
Created January 19, 2012 20:31
Had this laying around for quite a while -- really useful and kind of dumb it's not built in...
// stringByAddingPercentEscapesUsingEncoding is pretty conservative about escaping characters, which is fine most of the time. This method however escapes *all special characters*, allowing any arbitrary string to be used when building any part of a URL.
// (c) 2011 Springs & Struts. Released under MIT-style license. See: http://www.opensource.org/licenses/mit-license.php
@interface NSString (SSURLEscaping)
- (NSString *)ss_stringByEscapingAllURLCharactersForRealWithEncoding:(NSStringEncoding)encoding;
@end
@implementation NSString (SSURLEscaping)
- (NSString *)ss_stringByEscapingAllURLCharactersForRealWithEncoding:(NSStringEncoding)encoding
tell application "Terminal"
open (path to desktop folder)
end tell