Skip to content

Instantly share code, notes, and snippets.

View enigmaticape's full-sized avatar

Enigmatic Ape enigmaticape

View GitHub Profile
@enigmaticape
enigmaticape / sicp_ex_1.10b.scm
Created November 5, 2012 09:10
h(n) = 2^(h(n-1)) defined iteratively. SICP Exercise 1.10
;h(n) = 2^(h(n-1)) defined iteratively.
(define (h-iter-aux num prod count)
(if (= count 1)
prod
(h-iter-aux num (expt num prod) (- count 1))))
(define (h-iter n)
(if (= n 0)
0
@enigmaticape
enigmaticape / csv2html.py
Created November 5, 2012 12:15
Very simple CSV to HTML table in Python
#!/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 / theme_list_tags_v1.0.php
Created November 5, 2012 13:13
wp_list_tags a-like, mimics (some of) the functionality of wp_list_categories
function theme_list_tags( $args ) {
$current_url = $_SERVER['REQUEST_URI'];
/* get_tags shares a subset of its parameters with
wp_get_catgeories, :
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => true
@enigmaticape
enigmaticape / theme_get_archives_link.php
Created November 5, 2012 13:46
Wordpress PHP function which adds CSS class to currently selected archive list item
@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
@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 / 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 / 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 / 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 / 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