Skip to content

Instantly share code, notes, and snippets.

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
$("#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/
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:

@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
@simoncozens
simoncozens / harmonization.md
Last active October 23, 2023 06:42
Harmonizing two Bezier curves

To harmonize (with G2 curvature) two cubic Bézier curves a0,a1,a2,a3 and b0,b1,b2,b3 where a2, a3 = b0, and b1 are colinear:

  • First find d = intersection point of line a1--a2 and line b1--b2.
  • Now find ratios p0 = |a1, a2| / |a2, d| and p1 = |d1, b1| / |b1, b2|.
  • Determine ratio p = sqrt(p0 * p1)
  • Now set position of a3 = b0 such that |a2, a3| / |a3, b1| == p.
  • To do this, set t = p / (p+1).
  • Adjust the position of a3=b0 so that it sits t of the way between a2 and b1.

Of course, you may prefer to keep the position of a3 because it's the on-curve point. Fine. Instead, compute where a3 should go according to this algorithm, work out the delta between the new position and the current position, and apply that delta to the handles a2 and b1 instead.

@simoncozens
simoncozens / otvar-instance.py
Created September 27, 2016 10:04
OpenType Variation Instance Generator
#!/usr/bin/python
from fontTools.misc.py23 import *
from fontTools.ttLib import TTFont
import sys
import argparse
parser = argparse.ArgumentParser(description="OpenType Variation Instance Generator")
parser.add_argument('font', help="font file")
parser.add_argument('-a', '--all', action="store_true", help="Generate all instances")
parser.add_argument('-o', '--output', help="Output directory", default = ".")