Skip to content

Instantly share code, notes, and snippets.

View danpalmer's full-sized avatar

Dan Palmer danpalmer

View GitHub Profile
objc_msgSend(robot, "moveForward:", 100);
robot.moveForward(100);
[robot moveForward:100];
server {
listen 80;
server_name statusboard.danpalmer.me;
access_log /path/to/logs/access.log;
error_log /path/to/logs/error.log;
location /
{
description "node.js server for StatusBoard GoSquared endpoint"
author "Dan Palmer - http://danpalmer.me/"
start on startup
stop on shutdown
respawn
respawn limit 20 5
limit nofile 32768 32768
// Transform this:
{
visitors.total: [
{
timestamp: 1365548400,
value: 1
},
{
timestamp: 1365548700,
value: 2
@danpalmer
danpalmer / Main.hs
Last active December 16, 2015 01:49
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Applicative
import Snap.Core
import Snap.Util.FileServe
import Snap.Http.Server
import Data.ByteString
import Data.Maybe
describe(@"MyClass", ^{
it(@"should do something", ^AsyncBlock {
MyClass *obj = [[MyClass alloc] init];
[obj doSomethingInBackground:^(NSArray *results, NSError *error) {
expect([results count]).toNot.equal(0);
done();
}];
});
});
- (void)setupTests {
}
- (void)testFeatureFoo {
}
- (void)testFeatureBlah {
}
- (void)tearDown {
@danpalmer
danpalmer / gist:5129944
Created March 10, 2013 19:12
Backtrace
* thread #1: tid = 0x2303, 0x00007fff8ffb6250 libobjc.A.dylib`objc_msgSend + 16, stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
frame #0: 0x00007fff8ffb6250 libobjc.A.dylib`objc_msgSend + 16
frame #1: 0x00007fff88ffe708 Foundation`___NSURLConnectionWillCacheResponse_block_invoke_0 + 110
frame #2: 0x00007fff88e86528 Foundation`__65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke_0 + 28
frame #3: 0x00007fff88e8646c Foundation`-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 227
frame #4: 0x00007fff88e86368 Foundation`-[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 63
frame #5: 0x00007fff88ffda3c Foundation`_NSURLConnectionWillCacheResponse + 126
frame #6: 0x00007fff879f8272 CFNetwork`___delegate_willCacheResponse_block_invoke_0 + 48
frame #7: 0x00007fff87a75a7a CFNetwork`___withDelegateAsync_block_invoke_0 + 90
frame #8: 0x00007fff87b062ea CFNetwork`__block_global_1 + 28
@danpalmer
danpalmer / gist:4546950
Created January 16, 2013 12:55
I need to check that I'm not missing something about the details of CoreLocation. I am extending this code, and found this in the CLLocationManagerDelegate. It starts updating *location* and *heading*, then when it receives the *location* it stops updating the *heading* and vice-versa. This seems to be wrong to me, am I misunderstanding somethin…
- (void) locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading {
[manager stopUpdatingLocation];
occurrence.heading = [NSNumber numberWithDouble:[newHeading trueHeading]];
[occurrence didReceiveNewData];
}
- (void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
[manager stopUpdatingHeading];
occurrence.lat = [NSNumber numberWithDouble:newLocation.coordinate.latitude];
occurrence.lon = [NSNumber numberWithDouble:newLocation.coordinate.longitude];