Skip to content

Instantly share code, notes, and snippets.

use Lingua::StopWords q(getStopWords);
use Lingua::EN::Inflect::Number qw/to_S/;
my $stop = getStopWords("en");
$stop->{$_}++ for qw/thee thou ye shall unto hath/;
my %hash;
while (<>) {
chomp;
my @words = split /\s+/, $_;
for (@words) {
$_= to_S(lc $_);
@simoncozens
simoncozens / iconmaker.pl
Last active August 29, 2015 14:00
PhoneGap Icon Maker - put this into .cordova/hooks/after_prepare/
#!/bin/perl
use strict;
my $base = shift @ARGV;
my $splash = "splash.ai";
my $icon = "icon.ai";
my @formats = (
[qw/ splash ios Default-Landscape@2x~ipad.png 1496 2048 /],
[qw/ splash ios Default-Landscape~ipad.png 748 1024 /],
[qw/ splash ios Default-Portrait@2x~ipad.png 2008 153 /],
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_OUTLINE_H
#include <hb.h>

Keybase proof

I hereby claim:

  • I am simoncozens on github.
  • I am simoncozens (https://keybase.io/simoncozens) on keybase.
  • I have a public key whose fingerprint is 3194 43FE 3FC8 1122 7991 C09D FC12 2714 E641 8532

To claim this, I am signing this object:

scope :located_near, lambda { |distance, long, lat|
geoFactory = RGeo::Geographic.spherical_factory
circle = geoFactory.point(long, lat).buffer(distance.to_f * 1609.34) # METERS PER MILE
where("Intersects(location, GeomFromText(\"#{circle}\"))")
}
class MiscController < ApplicationController
# Useful stuff which doesn't belong anywhere else
def geocode
render :json => Geokit::Geocoders::GoogleGeocoder.geocode(params[:q])
end
def reverse_geocode
render :json => Geokit::Geocoders::GoogleGeocoder.reverse_geocode(params[:q])
end
end
@simoncozens
simoncozens / kerningpairs.txt
Created November 9, 2015 10:36
All lower case kerning pairs - shortest text found from dictionaries using a dumb random search
jw Shahjahanpur supercalifragilisticexpialidocious acquaintanceship
dichlorodifluoromethane insightfulnesses jl Erzgebirge vx kx Overijssel
solemnifying roofgarden boxberries fq substratosphere bxs Gewurztraminer
disconnectedly jg Thanksgivings bugbears Allhallowmas labdanums pq adjt
chymotrypsin sleepwalked kibitka awlworts unobjectionable sheqel
magnetohydrodynamics anthropomorphize goldfields Chappaquiddick Moskva clxii
misjudgment tx Panmunjom px earthquake outperform mx Netzahualcoyotl Skopje
bandwidths clavicytherium clampdown zx convolvulaceous honeysuckle qf fz
Gelbvieh succinylsulfathiazole sixfold bogtrotter subcultural pkwy eurhythmy
Ecbatana qx jimjams cml crowfeet prajna Flaxman Kafkaesque weekday Reykjavik
$("#videoContainer").empty();
$("#videoContainer").append('<video id="video" webkit-playsinline=1 poster preload="metadata"><source id="source" type="video/mp4" src="'+Vibi.localCatalogue[book].video+'"/></video>');
var vid = $("#video")[0];
var f = function(e) {
vid.currentTime = startingTime;
};
vid.addEventListener("loadedmetadata", f);
// This hack is required to force iOS to buffer the video. Without it, it won't play. :(
// c.f. http://blog.millermedeiros.com/html5-video-issues-on-the-ipad-and-how-to-solve-them/
from __future__ import print_function, division, absolute_import
from fontTools.misc.py23 import *
from fontTools.ttLib import TTFont
from Lib.fontTools.varLib.iup import iup_delta_optimize, _iup_contour_bound_forced_set
font = TTFont("NotoSerifHebrew-GX.ttf")
gvar = font["gvar"]
glyf = font["glyf"]
total = 0
@simoncozens
simoncozens / SignalHandler.py
Created May 31, 2018 01:57
Keras callback for signal handing
# In your model:
# from SignalHandler import SignalHandler
# model.fit(... callbacks=[..., SignalHandler()])
# kill -USR1 $KERAS_PROCESS # Drop learning rate x0.1
# kill -USR2 $KERAS_PROCESS # Save model immediately
# kill $KERAS_PROCESS # Terminate at end of epoch
from keras import backend as K
from keras.callbacks import Callback