Skip to content

Instantly share code, notes, and snippets.

View enigmaticape's full-sized avatar

Enigmatic Ape enigmaticape

View GitHub Profile
@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 / 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 / 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 / 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 / the_little_tokeniser.php
Created December 2, 2012 23:11
The little tokeniser that could
<?php
function tokeniseString( $string ) {
$regex = "/([[:space:]]+)|([[:punct:]])/";
$opts = PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY;
$toks = preg_split( $regex, $string, -1, $opts );
return $toks;
}
@enigmaticape
enigmaticape / esc-html-no-no.php
Created December 3, 2012 19:56
Wordpress does bad things with shortcodes and p tags
<?php
// ...
function eschtml_func( $atts, $content = null ) {
return htmlentities( $content );
}
add_shortcode( 'eschtml', 'eschtml_func' );
?>
@enigmaticape
enigmaticape / factors.py
Created December 7, 2012 21:02
Really awful code to count ngrams
#!/usr/bin/env python
import collections
import sys
nums = sys.argv[1:]
def factors_of( x ):
factors = []
n = x-1
@enigmaticape
enigmaticape / ic.py
Created December 10, 2012 22:49
Compute the index of coincidence of a text file
#!/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
@enigmaticape
enigmaticape / FUSmartQuotes_wp_plugin.php
Last active December 12, 2015 00:18
The smallest possible Wordpress Plugin. To disable smart quotes.
<?php
/*
Plugin Name: FU Smart Quotes
Plugin URI: https://gist.github.com/4682690
Description: Disable smart quotes
Version: 1.0
Author: Steve Trewick
Author URI: http://www.enigmaticape.com/blog/the-smallest-possible-wordpress-plugin/
License: Public Domain
*/
#import <Foundation/Foundation.h>
@interface Appcast : NSObject
+ ( id ) instance;
+ (void) post:(NSString *) message;
@end