Skip to content

Instantly share code, notes, and snippets.

Owain Lewis owainlewis

Block or report user

Report or block owainlewis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Postgresql Quick Guide
Postgresql Cheat Sheet
start: psql -U username databasename
quit: \q
list all: \d
list tables: \dt
list all databases: \l
owainlewis / _analytics.haml
Created Mar 9, 2012
Google Analytics HAML
View _analytics.haml
var _gaq = _gaq || [];
_gaq.push(['_setAccount', YOUR_CODE']);
(function() {
var ga = document.createElement('script');
ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
owainlewis / protocols.clj
Created Mar 9, 2012
Clojure IO Protocols
View protocols.clj
(defprotocol IO
"A protocol for reading and writing"
(read-file [this])
(write-file [this]))
(extend-protocol IO
(read-file [file]
(with-open [rdr ( file)]
(reduce conj [] (line-seq rdr))))
owainlewis / gist:2152665
Created Mar 21, 2012
ClojureScript Setup OSX
View gist:2152665

Install ClojureScript

git clone git://
cd clojurescript

In ClojureScript dir

owainlewis / core.clj
Created Apr 4, 2012
Clj-webdriver test
View core.clj
(ns selenium-test.core
(:use midje.sweet)
(:use []))
(set-driver! {:browser :firefox})
(to "")
(facts "About the homepage"
(visible? "#content") => true)
owainlewis /
Created Apr 4, 2012
Sieve of Erastothenes
from math import sqrt
# Sieve of Erastothenes
def sieve(n):
candidates = list(range(n))
# We only need to check up to the square root of n
upto = int(sqrt(n)) + 1
owainlewis / problem07.clj
Created Apr 5, 2012
Fast prime sort algorithm
View problem07.clj
(ns euler.problem7
(:use [euler.core]))
;; The algorithm for this is
;; - Start at the first 1000 primes
;; - If there are not enough primes then try again at 2000 etc
(defn get-nth-prime [n, max]
"Returns the nth prime"
(let [primes (sieve max)]
View gist:2361826

Cassandra CLI


  1. bin/cassandra -f
  2. bin/cassandra-cli
View query.rb
# A Micro DSL for NET/HTTP
require 'net/http'
require 'net/https'
require "uri"
# Base class for making HTTP connections
module Query
owainlewis / chunks.rb
Created Apr 28, 2012
Grouping sequence by n in Ruby
View chunks.rb
def group_sequence_by n, sequence do |result|
sequence.each_slice(n) { |item| result << item }
You can’t perform that action at this time.