Skip to content

Instantly share code, notes, and snippets.

@funkotron
funkotron / docker_create_treeio.sh
Last active December 18, 2019 17:56
Using Docker (requires docker to be installed http://www.docker.io/gettingstarted/ ), spawn a postgresql instance and a dynamically configured treeio instance.
#!/bin/bash
# Description: Using Docker (requires docker to be installed http://www.docker.io/gettingstarted/ ), spawn a postgresql instance and a dynamically configured treeio instance
# Also requires postgresql client tools http://www.postgresql.org/download/linux/ubuntu/
# Run chmod +x to make this file executable then run it: ./docker_create_treeio.sh
# Author: Adam Awan
# Email: adam@tree.io
# Set the port to forward for Tree.io
TREEIO_PORT="80"
@funkotron
funkotron / all_your_base.py
Created February 15, 2014 03:57
Solution to "All Your Base" Google Codejam contest in Python http://code.google.com/codejam/contest/189252/dashboard#s=p0
#!/usr/bin/python
def distinct(j):
seen = set()
for i in j:
if i not in seen:
seen.add(i)
return seen
def next_index(c):
@funkotron
funkotron / github-lang-count.clj
Created November 14, 2013 20:13
GitHub API Language Count
(ns crash-course-clojure.github
(:require [clj-http.client :as http]
[cheshire.core :refer [parse-string]]
[clojure.pprint :refer [pprint]]))
(defn query-github
"Run an arbitrary query agains Github's API."
[query]
(parse-string (:body (http/get "https://api.github.com/users/funkotron/repos"
@funkotron
funkotron / gist:7473547
Created November 14, 2013 20:12
Query Git for a list of repos - change the URL username
(ns crash-course-clojure.github
(:require [clj-http.client :as http]
[cheshire.core :refer [parse-string]]
[clojure.pprint :refer [pprint]]))
(defn query-github
"Run an arbitrary query agains Github's API."
[query]
(parse-string (:body (http/get "https://api.github.com/users/funkotron/repos"
@funkotron
funkotron / init
Last active December 20, 2015 00:39
Modified init script to keep existing password if arg given and keep existing /data dir if non empty for persistence of database
#!/bin/sh
set -e
mkdir -p /usr/share/zoneinfo /data
chown default /data
if [ $# -eq 1 ]
then
echo $1 > /pwfile
else
head -c 16 /dev/urandom | sha1sum | cut -c1-10 > /pwfile
fi
@funkotron
funkotron / gist:78df6988a09ee1396840
Last active August 29, 2015 14:22
Inside The Mind of The Machine <game>
<fun>
<begin>
<if Tech Super Hero Matrix not already open>
Open this URL in a new browser tab: j.mp/mosaic-browser
</if>
</begin>
Which technology superstars can you find in this Matrix?
Somewhere in there you might find a tiny sample of them; maybe you can add more? The Mosaically Matrix is open for Remix and you can Submit your favourite Heroes to be included. But right now, deep inside the mind of the machine are:
@funkotron
funkotron / dev-reload
Created April 29, 2015 01:01
bin/dev
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
nREPL server started on port 50793 on host 127.0.0.1 - nrepl://127.0.0.1:50793
* Initializing CLJS compiler & source server on port 8083
Starting watch on Resources/vee-out
Reflection warning, clojure/data/priority_map.clj:215:19 - call to method equiv on java.lang.Object can't be resolved (no such method).
Reflection warning, clojure/core/memoize.clj:72:23 - reference to field cache can't be resolved.
Starting file watcher (CTRL-C to quit)...
Elapsed time: 0.023 sec
@funkotron
funkotron / ios-sim-reload
Created April 29, 2015 01:00
bin/ios-sim
Titanium Command-Line Interface, CLI version 3.4.2, Titanium SDK version 3.5.1.GA
Copyright (c) 2012-2015, Appcelerator, Inc. All Rights Reserved.
Please report bugs to http://jira.appcelerator.org/
[INFO] tiapp.xml <sdk-version> set to 3.5.0.GA, but current Titanium SDK set to 3.5.1.GA
[INFO] Forking correct SDK command: "/usr/local/bin/node" "/usr/local/bin/titanium" "build" "--sdk" "3.5.0.GA" "--retina" "--tall" "--config-file" "/Users/adam/.titanium/config.json" "--platform" "iphone" "--project-dir" "/Users/adam/workspace/veestarter" "--log-level" "trace" "--device-id" "FA27B608-29A7-4314-8EB8-7E5752831043" "--ios-version" "8.3" "--sim-version" "8.3" "--target" "simulator"
Wed Apr 29 2015 01:57:52 GMT+0100 (BST)
@funkotron
funkotron / inversion_count.jl
Created February 15, 2014 04:02
Count inversions in a string using Julia
# Julia program to count number of inversions in a string
# using properties of the MergeSort algorithm
global inversions = 0
function arrange(xs, ys)
result = Int64[]
while (length(xs) > 0) & (length(ys) > 0)
if xs[1]<=ys[1]
push!(result,shift!(xs))
@funkotron
funkotron / all_your_base.clj
Created February 15, 2014 03:54
Solution to "All Your Base" Google Codejam contest in Clojure http://code.google.com/codejam/contest/189252/dashboard#s=p0
(ns jam.all-your-base
(:require [clojure.math.numeric-tower :as math]))
(def in (rest (clojure.string/split (slurp "A-large-practice.in") #"\n")))
(defn p [x y]
(math/expt x y))
(defn next-index [x]
(cond