Skip to content

Instantly share code, notes, and snippets.

View nevyn's full-sized avatar

Nevyn Bengtsson nevyn

View GitHub Profile
@nevyn
nevyn / TCStream.h
Created November 19, 2013 22:42
Simple helpers for working with common data types on NSData-backed input and output streams.
#import <Foundation/Foundation.h>
/** @category TCInputStream
@abstract Reads Big Endian data in convenient sizes
*/
@interface NSInputStream (TCInputStream)
- (int8_t)readByte;
- (uint16_t)readShort;
- (uint32_t)readInt;
- (uint64_t)readLongLong;
@implementation MeteorClient (GFTask)
- (SPTask*)gf_sendMethod:(NSString*)method parameters:(NSArray*)params
{
SPTaskCompletionSource *source = [SPTaskCompletionSource new];
[self sendWithMethodName:method parameters:params responseCallback:^(NSDictionary *response, NSError *error) {
if(error) {
[source failWithError:error];
} else {
[source completeWithValue:response];
@nevyn
nevyn / chain.m
Last active December 26, 2015 22:19
// Wait for logout, then re-login
[[[loginController waitForLogoutCompletion] chain:^SPTask *(id value) {
return [loginController waitForLoginCompletion];
}] addCallback:^(id value) {
self.view.window.userInteractionEnabled = YES;
[self.introDelegate introFlow:self finishedSuccessfully:YES didMerge:YES];
self.introDelegate = nil;
}];
@nevyn
nevyn / reg.m
Created October 25, 2013 11:57
Subdividing camera image into smaller regions and time multiplexing them so that I can read more than 4 markers simultaneously. Works badly. SO: http://stackoverflow.com/questions/19431661/avcapturemetadataoutput-detect-more-than-four-4-qr-codes
- (id)init
{
...
static const float w = 1. / subdivisionColumns, h = 1. / subdivisionRows;
int i = 0;
for(int y = 0; y < subdivisionRows; y++) {
for(int x = 0; x < subdivisionColumns; x++, i++) {
_regions[i] = CGRectMake(x*w, y*h, w*1.5, h*1.5);
}
Pod::Spec.new do |s|
s.name = "Lookback"
s.version = "0.4.11"
s.summary = "Lookback records screen, camera, touches etc and uploads it to http://lookback.io. Useful for UX research, QA bug reporting, etc."
s.description = <<-DESC
Lookback is a tool and library for user experience testing that you can integrate into your app. Lookback records the iOS screen, the front-facing camera, microphone, metadata, touches and active views, and uploads it all in near-realtime to lookback.io where you can study and dive into the data. Example use cases:
* User testing sessions. Instead of mounting web cams in your testing lab to record both the screen and your tester's reactions, let Lookback do the hard work for you.
//
// TCKinectDepthController.h
// Ocunect2
//
// Created by Joachim Bengtsson on 2013-10-20.
// Copyright (c) 2013 nevyn. All rights reserved.
//
#import <Foundation/Foundation.h>
@nevyn
nevyn / main.m
Created September 10, 2013 08:34
ivar namespacing in objc
#import <Foundation/Foundation.h>
@interface Foo : NSObject
@end
@implementation Foo {
int _foo;
}
- (id)init
{
_foo = 1;
diff --git a/Antenna/ANTNetworkClient.m b/Antenna/ANTNetworkClient.m
index 6e6f791..a5531ef 100644
--- a/Antenna/ANTNetworkClient.m
+++ b/Antenna/ANTNetworkClient.m
@@ -67,6 +67,7 @@ NSString *RATNetworkClientDidLoginNotification = @"RATNetworkClientDidLoginNotif
_dateFormatter = [[NSDateFormatter alloc] init];
[_dateFormatter setDateFormat:@"dd-MMM-yyyy HH:mm"];
+ [_dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]];
#include <vector>
int width = 8, height = 10;
struct Tile {
bool is_wall;
} tiles[height][width];
struct Coordinate {
int x, y;
};
@nevyn
nevyn / Output
Created August 17, 2013 23:32
minimal eminet test. Fails.
2013-08-18 01:32:20.810 EmiNetDemo[87142:303] Failed to connect Error Domain=com.emilir.eminet.disconnect Code=3 "The operation couldn’t be completed. (com.emilir.eminet.disconnect error 3.)"
2013-08-18 01:32:20.811 EmiNetDemo[87142:303] Disconnect