Skip to content

Instantly share code, notes, and snippets.

View timburks's full-sized avatar
🌞
summer

Tim Burks timburks

🌞
summer
View GitHub Profile
Nice to meet you.
Hey, can I call you Joe?
Thank you.
Thank you, Gwen. Thank you. Thank you.
(load "TouchJSON")
(system "curl http://openradar.appspot.com/api/radars > radars.json")
(set d ((CJSONDeserializer deserializer) deserializeAsDictionary:(NSData dataWithContentsOfFile:"radars.json") error:nil))
(set radars (d "result"))
(puts (radars description))
(puts (radars count))
@timburks
timburks / gist:31796
Created December 4, 2008 00:55
Nuke task to build standalone "tool" executables
;; use this to create all the linking and assembly tasks to build a standalone "tool" executable
(macro tool-tasks
(unless (and @arch (@arch length))
(set @arch (list (NSString stringWithShellCommand:"arch"))))
(unless @tool_extras
(set @tool_extras ""))
;; executable architecture-specific executable
(set @tool_executables (NSMutableArray array))
#!/usr/local/bin/nush
(function append-to-file (filename text)
(unless ((NSFileManager defaultManager) fileExistsAtPath:filename)
((NSFileManager defaultManager) createFileAtPath:filename contents:nil attributes:nil))
(set handle (NSFileHandle fileHandleForWritingAtPath:filename))
(handle seekToEndOfFile)
(handle writeData:((+ text "\n") dataUsingEncoding:NSUTF8StringEncoding))
(handle closeFile))
#import <Nunja/Nunja.h>
#import "NuMongoDB.h"
#import "JSON.h"
@interface ServerDelegate : NunjaDefaultDelegate
{
}
@end
@implementation ServerDelegate
@timburks
timburks / gist:735843
Created December 10, 2010 05:58
Tokyo Cabinet BSON store prototype
(load "NuTokyo")
(load "NuMongoDB") ;; for BSON wrapper
;; Tokyo Cabinet BSON document store example.
;; stores documents in a HashDB and builds indexes using BTreeDBs.
;; clear all files
(system "rm hashdb; rm permalinkindexdb; rm dateindexdb")
;; hashdb is used to store all objects
@timburks
timburks / pantomime-pop3.nu
Created February 2, 2011 04:51
Sending and receiving mail with Pantomime.
#!/usr/local/bin/nush
# pantomime-pop3.nu
(load "Pantomime")
(class PantomimePOP3Client is NSObject
(ivar (id) pop3 (id) user (BOOL) running)
(ivar-accessors)
(- (void) run is
@timburks
timburks / skpsmtp.nu
Created February 2, 2011 05:41
Sending mail with SKPSMTPClient
(load "SKPSMTP")
(class SKPSMTPClient is NSObject
(ivar (id) smtp (id) user (BOOL) running)
(ivar-accessors)
(- (void) sendMessage:(id) message is
(set @smtp (SKPSMTPMessage new))
(@smtp setFromEmail:(@user username:))
(@smtp setToEmail:(@user username:))
@timburks
timburks / crop.nu
Created March 1, 2011 06:56
AppKit image cropping
(import Cocoa)
(set data (NSData dataWithContentsOfFile:"iphone-screenshot.png"))
(set image ((NSImage alloc) initWithData:data))
(set oldsize (image size))
(cond ((eq oldsize '(640 960))
(set newsize '(640 920)))
;; add more as needed
(else (puts "unknown size")
@timburks
timburks / gist:2411759
Created April 18, 2012 07:33
Check out that Bluetooth LE setup time. This is with a Wahoo Blue HR and an iPhone 4S using CoreBluetooth.
2012-04-18 00:17:57.771 HRM[1137:707] Launching
2012-04-18 00:17:57.820 HRM[1137:707] Retrieved peripheral: 1 - (
"<CBConcretePeripheral: 0x1431a0>"
)
2012-04-18 00:17:57.850 HRM[1137:707] connected
2012-04-18 00:17:59.839 HRM[1137:707] Service found with UUID: Generic
Access Profile
2012-04-18 00:17:59.841 HRM[1137:707] Service found with UUID: Generic
Attribute Profile
2012-04-18 00:17:59.844 HRM[1137:707] Service found with UUID: Unknown (<180a>)