Skip to content

Instantly share code, notes, and snippets.

Enigmatic Ape enigmaticape

Block or report user

Report or block enigmaticape

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@enigmaticape
enigmaticape / part1.m
Created Nov 14, 2012
You want to use NSObject performSelector with multiple parameters, but you can't ? (1)
View part1.m
- ( id ) methodWithOneParam:( id ) theParam {
// Do amazing stuff
return @"Srsly, Amazing!";
}
- ( id ) methodWithFirst:( id ) firstParam
andSecond:( id ) secondParam
{
// Do doubly amazing stuff
@enigmaticape
enigmaticape / HTTPMessage.h
Created Nov 6, 2012
Minimal (ish) HTTP server in ObjC using GCD socket dispatch
View HTTPMessage.h
#import <Foundation/Foundation.h>
@interface HTTPMessage : NSObject
@property (nonatomic, readonly) CFHTTPMessageRef request;
- ( BOOL ) isRequestComplete:(NSData *) append_data;
@end
@enigmaticape
enigmaticape / Invoker.h
Created Nov 17, 2012
Wrapping NSInvocation for fun and profit, for values of profit that include a better peformSelector
View Invoker.h
#import <Foundation/Foundation.h>
@interface Invoker : NSObject
+ ( NSValue * ) invoke:( SEL ) selector onTarget:( id ) target, ...;
@end
@enigmaticape
enigmaticape / SomeObject.h
Created Nov 19, 2012
A short digression on Objective C runtime type encoding
View SomeObject.h
#import <Foundation/Foundation.h>
@interface SomeObject : NSObject
- (NSObject*) someMethodWithAchar:(char) aChar
anInt:(int) anInt
aFloat:(float) aFloat
aString:(NSString*) aString;
@end
@enigmaticape
enigmaticape / main.m
Created Nov 9, 2012
You want to use NSObject performSelector with multiple parameters, but you can't ?
View main.m
#import <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
#import <objc/message.h>
@interface AmazingClass : NSObject
- ( void ) doMultipleAmazingStuff;
@end
@implementation AmazingClass
View gist:4e8d467571680a3bf774
#import <Foundation/Foundation.h>
#import <ifaddrs.h>
#import <net/if.h>
#import <SystemConfiguration/CaptiveNetwork.h>
@interface SMTWiFiStatus : NSObject
- (BOOL) isWiFiEnabled;
- (BOOL) isWiFiConnected;
@enigmaticape
enigmaticape / csv2html.py
Created Nov 5, 2012
Very simple CSV to HTML table in Python
View csv2html.py
#!/usr/bin/python
import sys
import os
import csv
import string
if len( sys.argv ) < 2 :
sys.stderr.write( sys.argv[ 0 ] +
": usage - " +
@enigmaticape
enigmaticape / topgrossingfreeapps.py
Last active May 29, 2017
Grab and parse iTunes App Store RSS feed and coiunt how many of the top grossing apps for a particular store are currently free
View topgrossingfreeapps.py
#!/usr/bin/env python
# topgrossingfreeapps.py [country code]
# us, gb, ch, etc
# quick and dirty python script to grab the percentage
# of top grossing aps in a given app store which are
# currently free
import feedparser
@enigmaticape
enigmaticape / iterfib.scm
Created Nov 4, 2012
Iterative (tail recursive) Fibonacci in Scheme (a snippet from SICP)
View iterfib.scm
(define (fib n)
(fib-iter 1 0 n))
(define (fib-iter a b count)
(if (= count 0)
b
(fib-iter (+ a b) a (- count 1))))
@enigmaticape
enigmaticape / ic.py
Created Dec 10, 2012
Compute the index of coincidence of a text file
View ic.py
#!/usr/bin/env python
import sys
import collections
# Bag em
cipher_file = open( sys.argv[ 1 ], 'rb')
cipher_text = cipher_file.read()
# remove all non alpha and whitespace and force uppercase
You can’t perform that action at this time.