Skip to content

Instantly share code, notes, and snippets.

View enigmaticape's full-sized avatar

Enigmatic Ape enigmaticape

View GitHub Profile
@enigmaticape
enigmaticape / inject.js
Created May 19, 2013 21:56
Hack mouse zoom into safari via extension javascript.
zoomWithWheel = false;
zoomLevel = 1;
zoomIncrement = 0.2;
document.addEventListener( "mousewheel", function( event ) {
if( zoomWithWheel ) {
if( event.wheelDeltaY > 0 ) {
zoomLevel += zoomIncrement;
}
@enigmaticape
enigmaticape / topgrossingfreeapps.py
Last active May 29, 2017 12:49
Grab and parse iTunes App Store RSS feed and coiunt how many of the top grossing apps for a particular store are currently free
#!/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 / EnigmaticApe_ShortExcerpts_WP_Plugin.php
Last active December 12, 2015 09:19
Wordpess plugin that adds an extra post meta box for a short (or just additional) excerpt. Bung it in your wp-content/plugins directory, get the short excerpt using : get_post_meta($post->ID, "ape_short_excerpt", true) ) :
<?php
/*
Plugin Name: Add Short Excerpt Meta
Plugin URI: https://gist.github.com/enigmaticape/4751121
Description: Add an additional excerpt box for front page
Version: 1.0
Author: Steve Trewick
Author URI: http://www.enigmaticape.com
License: Public Domain
*/
.gist .line,
.gist .line-number {
font-size:14px !important;
line-height:25px !important;
}
#import <Foundation/Foundation.h>
@interface Appcast : NSObject
+ ( id ) instance;
+ (void) post:(NSString *) message;
@end
@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
*/
@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 / 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 / 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 / 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;
}