Skip to content

Instantly share code, notes, and snippets.

View henrygarner's full-sized avatar

Henry Garner henrygarner

View GitHub Profile
@henrygarner
henrygarner / llr.rb
Created February 1, 2011 12:04
A simple Ruby demonstration of Ted Dunning's log-likelihood statistical measure, via Paul Rayson http://ucrel.lancs.ac.uk/llwizard.html
require 'matrix'
module LLR
def self.calculate(m)
2 * (m.to_a.flatten.h - m.row_vectors.map(&:sum).h - m.column_vectors.map(&:sum).h)
end
def sum
to_a.inject(nil) { |sum, x| x = yield(x) if block_given?; sum ? sum + x : x }
end
user> (require '[biscuit.core :as digest])
nil
user> (digest/crc8 "hobnob")
17
@henrygarner
henrygarner / gist:3235131
Created August 2, 2012 08:07
Vagrantfile for Engineyard 'Rails in a Box'
Vagrant::Config.run do |config|
config.vm.box = "eyu"
config.vm.forward_port(22, 2222)
config.vm.forward_port(3000,3033)
config.vm.forward_port(80,8088)
config.vm.forward_port(3306,3366)
config.vm.forward_port(5432,5434)
config.vm.forward_port(4567,4568)
config.vm.share_folder("shared", "/shared", "shared")
end
(defproject dumbo "0.1.0-SNAPSHOT"
:repositories {"apache-releases" "http://repository.apache.org/content/repositories/releases/"}
:dependencies [[org.clojure/clojure "1.4.0"]
[org.apache.mahout/mahout-core "0.7"]
[org.apache.mahout/mahout-math "0.7"]
[org.apache.mahout/mahout-utils "0.5" :exclusions [com.google.guava/guava]]])
@henrygarner
henrygarner / gist:2907213
Created June 10, 2012 20:25
Vagrantfile for creating a VM running lucid64 and Hadoop
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "lucid64"
config.vm.box_url = "http://files.vagrantup.com/lucid64.box"
config.vm.provision :shell, :inline => "apt-get update"
# Otherwise java install will fail with missing dependencies
@henrygarner
henrygarner / hash_extension.rb
Created March 30, 2012 09:00
Recursively flatten nested Hashes
class Hash
def flatten_nested(hash = {}, prefix = '')
each do |key, value|
full_key = prefix.empty? ? key : "#{prefix}_#{key}"
value.is_a?(Hash) ? value.flatten_nested(hash, full_key) : hash[full_key] = value
end
hash
end
end
;; https://4clojure.com/problem/26
(partial (fn f [a b n]
(if (= n 0) ()
(cons a (f b (+ a b) (- n 1)))
)
) 1 1)
Ducklink::Decorator.configure do
group do
template 'http://affiliate.example.com?clickref={{reference}}&url={{url}}#campaign={{campaign}}'
host 'buy.example.com', 'shop.example.com' do |context|
set :campaign, 'campaign1'
set :reference, context[:reference]
end
host 'another.com' do |context|
set :campaign, 'campaign2'
set :reference, context[:reference]

We're Likely Ltd

We're the company behind many Facebook and Twitter accounts, such as Handpicked London on Facebook or @LDN on Twitter. We're a funded startup, and we try to find the best of the web around a particular topic to present to our communities. To do this efficiently with our small team (there's six of us, and just two technical staff) we are working on some challenging NLP, machine learning and 'big data' problems. In addition to content discovery, we have also built tools for online marketing. We use these tools ourselves but also apply their smarts on clients' behalf.

What we're after

To improve our public and client facing web presence we're looking to bring on a full time, full stack web developer to work on several self-contained and mostly green field projects.

The projects are diverse, and range from traditional click-to-buy customer facing web apps, to the specification of **

@henrygarner
henrygarner / gist:1123179
Created August 3, 2011 17:14 — forked from timcowlishaw/gist:1123148
Resources for setting up RVM and Passenger on Chef
http://www.agileweboperations.com/chef-rvm-ruby-enterprise-edition-as-default-ruby
http://www.christophersamuelson.com/2010/10/22/chef-rvm-capistrano-bundler/
http://blog.ninjahideout.com/posts/a-guide-to-a-nginx-passenger-and-rvm-server
http://brandontilley.com/2011/01/29/serving-rails-apps-with-rvm-nginx-unicorn-and-upstart.html
http://brandontilley.com/2011/01/29/rvm-unicorn-and-upstart.html
Chef workflow
# Install cookbook from opscode community site. (Automatically commits to local repo)
knife cookbook site install <COOKBOOK_NAME>