Skip to content

Instantly share code, notes, and snippets.

View henrygarner's full-sized avatar

Henry Garner henrygarner

View GitHub Profile
@henrygarner
henrygarner / gist:d41e02ba3662aef88c69
Last active August 29, 2015 14:24
barebones.core.cljs
(ns ^:figwheel-always barebones.core
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[reagent.core :as r]
[b1.charts :as c]
[b1.svg :as s]))
(enable-console-print!)
(def data (take 100 (repeatedly rand)))
from mcpi.minecraft import Minecraft
import mcpi.block as block
mc = Minecraft.create()
pos = mc.player.getTilePos()
width = 6
depth = 5
height = 4
import turtle
tim = turtle.Turtle()
def drawSquare(length):
for i in range(4):
tim.forward(length)
tim.right(90)
# Draw 90 squares rotated 4 degrees
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]