Skip to content

Instantly share code, notes, and snippets.

View enigmaticape's full-sized avatar

Enigmatic Ape enigmaticape

View GitHub Profile
@enigmaticape
enigmaticape / freq.py
Created November 25, 2012 23:24
Some scripts used in exploring the "Pigeon Code"
import os
import sys
import codecs
import argparse
parser = argparse.ArgumentParser("Count frequency of letters in ciphertext")
parser.add_argument("-i", "--input" , help="input file",
action="store")
@enigmaticape
enigmaticape / AppDelegate.m
Created November 22, 2012 21:04
variadic performSelector, oh yes indeed
/* For iOS, obvs */
#import "AppDelegate.h"
#import "TestObj.h"
#import "NSObject+invokeSelector.h"
@implementation AppDelegate
@enigmaticape
enigmaticape / TestObj.m
Created November 22, 2012 14:16
sample code for a better performSelector (see comments for link)
#import "TestObj.h"
@implementation TestObj
-(float) printString:(NSString*) aString
aBOOL:(BOOL) aBOOL
aBool:(bool) aBool
aChar:(char) aChar
anInt:(int) anInt
andIncrement:(float) aFloat
@enigmaticape
enigmaticape / SomeObject.h
Created November 19, 2012 20:13
A short digression on Objective C runtime type encoding
#import <Foundation/Foundation.h>
@interface SomeObject : NSObject
- (NSObject*) someMethodWithAchar:(char) aChar
anInt:(int) anInt
aFloat:(float) aFloat
aString:(NSString*) aString;
@end
@enigmaticape
enigmaticape / Invoker.h
Created November 17, 2012 16:30
Wrapping NSInvocation for fun and profit, for values of profit that include a better peformSelector
#import <Foundation/Foundation.h>
@interface Invoker : NSObject
+ ( NSValue * ) invoke:( SEL ) selector onTarget:( id ) target, ...;
@end
@enigmaticape
enigmaticape / part1.m
Created November 14, 2012 19:59
You want to use NSObject performSelector with multiple parameters, but you can't ? (1)
- ( id ) methodWithOneParam:( id ) theParam {
// Do amazing stuff
return @"Srsly, Amazing!";
}
- ( id ) methodWithFirst:( id ) firstParam
andSecond:( id ) secondParam
{
// Do doubly amazing stuff
@enigmaticape
enigmaticape / ObjCWebService.m
Created November 9, 2012 22:00
Almost as small as the Python version,but not quite
#import <Foundation/Foundation.h>
#import "HttpService.h"
@implementation WebService {
HttpService * _service;
}
- ( HTTPResponse * ) GET:( HTTPRequest * ) request {
@enigmaticape
enigmaticape / main.m
Created November 9, 2012 14:26
You want to use NSObject performSelector with multiple parameters, but you can't ?
#import <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
#import <objc/message.h>
@interface AmazingClass : NSObject
- ( void ) doMultipleAmazingStuff;
@end
@implementation AmazingClass
@enigmaticape
enigmaticape / minimalweb.py
Created November 8, 2012 19:40
Teeny tiny webpy
import web
urls = (
'/', 'index'
)
class index:
def GET (self):
return "Post some data!"
@enigmaticape
enigmaticape / HTTPMessage.h
Created November 6, 2012 14:22
Minimal (ish) HTTP server in ObjC using GCD socket dispatch
#import <Foundation/Foundation.h>
@interface HTTPMessage : NSObject
@property (nonatomic, readonly) CFHTTPMessageRef request;
- ( BOOL ) isRequestComplete:(NSData *) append_data;
@end