Skip to content

Instantly share code, notes, and snippets.

@tomtaylor
tomtaylor / example.html
Last active August 29, 2015 14:03
PaperLater Markup Examples
<html lang="en">
<head>
<!-- instead of the lang attribute on html, you may also use... -->
<meta name="DC.language" content="en">
</head>
<body>
<div class="hentry">
<h2 class="entry-title">Example Title</h2>
def similar(n = 10)
other_tags = Tag.find(:all, :conditions => ['tags.id != ?', self.id], :include => :bookmarks)
other_tags.map do |b|
[b, tanimoto(b.bookmarks, self.bookmarks)] # compare tag listings
end.select do |b|
b.last > 0 # select only those which have a tanimoto greater than 0, ie. some shared tags
end.sort do |x,y|
y.last <=> x.last # sort on tanimoto
end[0..n].map(&:first) # return only 0..10 bookmarks

Keybase proof

I hereby claim:

  • I am tomtaylor on github.
  • I am tomtaylor (https://keybase.io/tomtaylor) on keybase.
  • I have a public key whose fingerprint is 3D06 51B2 FE84 D047 FFFE 3AC0 1289 8989 0875 EB38

To claim this, I am signing this object:

@tomtaylor
tomtaylor / flickr-geo-munge.rb
Created August 10, 2008 19:17
Munge Flickr to find yourself in photos.
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'activesupport'
require 'uri'
# Set the longitude, latitude and radius of your search in here. And your api key.
def get_uri(from, to)
@tomtaylor
tomtaylor / Dockerfile
Last active August 29, 2015 14:25
Dockerfile for Valhalla
FROM phusion/baseimage:0.9.17
CMD ["/sbin/my_init"]
EXPOSE 8002
RUN apt-get update && apt-get install -y \
autoconf \
automake \
libtool \
make \
@tomtaylor
tomtaylor / Animator.h
Created August 2, 2015 04:53
MGLMapView Spring Animation
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol Animation <NSObject>
- (void)animationTick:(CFTimeInterval)dt finished:(BOOL *)finished;
@end
@interface Animator : NSObject
+ (instancetype)animatorWithScreen:(nullable UIScreen *)screen;
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'activesupport'
require 'uri'
# Set the longitude, latitude and radius of your search in here. And your api key.
def get_uri
require 'xmpp4r-simple'
module ActiveMessaging
module Adapters
module Xmpp
class Connection
include ActiveMessaging::Adapter
register :xmpp
def initialize(cfg)
# For what I have done, please forgive me.
# This monkey patch adds in the HttpOnly support for the session cookie
# This is present and accepted into Rails 2.2 at the time of writing, but not in Rails 2.1.
# You can remove this and set HttpOnly properly when moving to Rails 2.2
module ActionController
class RackRequest
DEFAULT_SESSION_OPTIONS = {
:database_manager => CGI::Session::CookieStore, # store data in cookie
:prefix => "ruby_sess.", # prefix session file names
$(document).ready(function() {
var gmap = new GMap2(document.getElementById("map"));
gmap.addControl(new GSmallMapControl());
var startingPoint = new GLatLng(51.506325,-0.127144);
gmap.setCenter(startingPoint, 13);
var bounds = new GLatLngBounds();
function displayPolygon(woeid, borderColor, fillColor) {
$.getJSON('http://api.flickr.com/services/rest/?method=flickr.places.getInfo&api_key=get_your_own&woe_id=' + woeid + '&format=json&jsoncallback=?', function(data) {