Skip to content

Instantly share code, notes, and snippets.

View edw's full-sized avatar

Edwin Watkeys edw

View GitHub Profile
@edw
edw / bloom.clj
Created October 24, 2012 15:59
Fn for computing Bloom filter size given set size and acceptable error rate
(defn bloom-filter-size-in-mb [n epsilon]
(/ (* n
(* 1.44 (/ (Math/log (/ 1 epsilon)) (Math/log 2))))
1024 1024))
@edw
edw / double.md
Created December 7, 2012 13:40
Doubling an array, in a bunch of languages

Python

[2 * x for x in (1,2,3,4,5,6,7,8)]
# ==> [2, 4, 6, 8, 10, 12, 14, 16]

Clojure

(map #(* % 2) [1 2 3 4 5 6 7 8])
@edw
edw / gist:4608927
Last active December 11, 2015 13:39 — forked from shripadk/gist:552554
Heroku SSL Cert
How to setup Heroku Hostname SSL with GoDaddy SSL Certificate
The following tutorial explains how to use Heroku's new 'Hostname SSL' option on your Heroku project. Before we begin, let's list what we're using here:
* Heroku Hostname SSL
* GoDaddy Standard SSL Certificate
I. Getting a GoDaddy SSL Certificate (Part I)
1. Purchase a GoDaddy Standard SSL Certificate
@edw
edw / delete-recursively.clj
Last active November 12, 2021 20:31
To delete a directory recursively in Clojure.
(defn delete-recursively [fname]
(let [func (fn [func f]
(when (.isDirectory f)
(doseq [f2 (.listFiles f)]
(func func f2)))
(clojure.java.io/delete-file f))]
(func func (clojure.java.io/file fname))))
@edw
edw / heroku-pg-dump-schema.sh
Last active May 6, 2022 17:33
Dump a schema from a Heroku app's database.
#!/bin/sh
# Usage: heroku-pg-dump-schema.sh HEROKU-APP-NAME DB-ENV-VAR-NAME SCHEMA-NAME
app=$1
env_var=$2
schema=$3
db_url=`heroku config -s --app ${app} | grep ${env_var}`
@edw
edw / .gitignore
Created April 5, 2013 16:57 — forked from adamgit/.gitignore
#########################
# .gitignore file for Xcode4 / OS X Source projects
#
# Version 2.0
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
# 2013 updates:
# - fixed the broken "save personal Schemes"
#
# NB: if you are storing "built" products, this WILL NOT WORK,
@edw
edw / gist:6308295
Last active December 21, 2015 12:49
sudo journalctl -u etcd
core@ip-10-99-66-79 ~ $ sudo journalctl -u etcd
-- Logs begin at Thu 2013-08-22 12:50:11 UTC, end at Thu 2013-08-22 14:55:20 UTC. --
Aug 22 12:50:21 ip-10-99-66-79 systemd[1]: Starting etcd...
Aug 22 12:50:21 ip-10-99-66-79 systemd[1]: Started etcd.
Aug 22 12:50:21 ip-10-99-66-79 etcd-bootstrap[490]: trying 10.116.74.174:7001,10.244.29.8:7001
Aug 22 12:50:21 ip-10-99-66-79 etcd-bootstrap[490]: + exec /usr/bin/etcd -d /var/lib/etcd -f -n 10.99.66.79 -c 10.99.66.79:4001 -s 10.99.6
Aug 22 12:50:21 ip-10-99-66-79 etcd-bootstrap[490]: [etcd] 12:50:21.634333 INFO Wrote node configuration to '/var/lib/etcd/info'
Aug 22 12:50:22 ip-10-99-66-79 etcd-bootstrap[490]: [etcd] 12:50:22.469927 INFO etcd server [10.99.66.79:http://10.99.66.79:4001]
Aug 22 12:50:22 ip-10-99-66-79 etcd-bootstrap[490]: [etcd] 12:50:22.470843 INFO raft server [10.99.66.79:http://10.99.66.79:7001]
Aug 22 12:57:21 ip-10-99-66-79 systemd[1]: etcd.service: main process exited, code=exited, status=2/INVALIDARGUMENT
@edw
edw / gist:6308497
Last active September 10, 2016 15:41
docker: apt-get unable to locate redis-server
core@ip-10-99-66-79 ~ $ sudo docker pull ubuntu
Pulling repository ubuntu
Pulling image 8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c (precise) from ubuntu
Pulling 8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c metadata
Pulling 8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c fs layer
Downloading 58.34 MB/58.34 MB (100%)
Pulling image b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc (quantal) from ubuntu
Pulling b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc metadata
Pulling b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc fs layer
Downloading 10.24 kB/10.24 kB (100%)
@edw
edw / gist:7138535
Created October 24, 2013 14:43
nREPL Exception on M-c C-j…
java.lang.IllegalAccessError: pp does not exist
at clojure.core$refer.doInvoke (core.clj:3849)
clojure.lang.RestFn.applyTo (RestFn.java:139)
clojure.core$apply.invoke (core.clj:619)
clojure.core$load_lib.doInvoke (core.clj:5394)
clojure.lang.RestFn.applyTo (RestFn.java:142)
clojure.core$apply.invoke (core.clj:619)
clojure.core$load_libs.doInvoke (core.clj:5413)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.core$apply.invoke (core.clj:619)
@edw
edw / description.md
Last active December 27, 2015 12:39
ActionX seeks Clojure Developers in NYC

ActionX, located in NYC, is looking for talented programmers interested in working full-time in our SoHo office. Successful candidates will have experience and interest in mostly-functional programming as well as at least some familiarity with Java and the Java Virtual Machine.

Furthermore, you should be familiar with the basics of Emacs, the Unix (e.g. OS X, Linux, FreeBSD) programming environment and the shell, and a computer science or EE/ECE background.