Skip to content

Instantly share code, notes, and snippets.

View Quantisan's full-sized avatar

Paul Lam Quantisan

View GitHub Profile
(ns com.snowtide.clojure.memoize)
(defn- mutable-memoize
[f #^java.util.Map map]
(fn [& args]
(if-let [e (find map args)]
(val e)
(let [ret (apply f args)]
(.put map args ret)
ret))))
;; ## Example of timeseries aggregation in cascalog.
;;
;; (copy paste all of this in at the REPL!)
(use 'cascalog.api)
(def tseries [["ndvi" 1 0 [1 2 3 4]]
["ndvi" 1 2 [2 3 4 5]]
["ndvi" 1 1 [4 3 2 1]]
["ndvi" 1 4 [1 2 3 4]]
@nolar
nolar / mturk-create.py
Created August 11, 2011 09:49
MTurk HIT initiation
import datetime
import boto.mturk.connection
import boto.mturk.question as mtq
import boto.mturk.qualification as mtqu
mt = boto.mturk.connection.MTurkConnection(aws_access_key_id='xxx', aws_secret_access_key='yyy')
text_en = '''Hello!
I am test text message to be translated from English to Russian.
If you ask me, I was born in a mind of a crazy web developer,
who tests the MTurk API to start a very promising service later.
@christianblunden
christianblunden / MerjSawt.clj
Created March 20, 2012 17:51
TCO optimised Clojure implementation of Merge Sort
(ns merge_sort.core
(:use [clojure.java.io :only (reader)])
(:gen-class :main true))
(defn merj [left right]
(loop [[lhead & ltail :as left] left
[rhead & rtail :as right] right
result []]
(cond (nil? left) (concat result right)
(nil? right) (concat result left)
@swannodette
swannodette / gist:3217582
Created July 31, 2012 14:52
sudoku_compact.clj
;; based on core.logic 0.8-alpha2 or core.logic master branch
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn get-square [rows x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in rows [x y])))
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 18, 2024 22:25
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@nimbus154
nimbus154 / dictionary.py
Created April 21, 2013 23:54
An example of how to write functional tests for a RESTful API using the Bottle microframework.
from bottle import get, run, request, post, Bottle, abort, error, response, debug, redirect
# This is a dictionary endpoint. It retrieves definitions for words.
# You can also add words to the dictionary.
# this allows our bottle application to be accessible outside this file
app = Bottle()
dictionary = {
"lugubrious": "extremely sad",

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@jbenet
jbenet / simple-git-branching-model.md
Last active June 17, 2024 14:53
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@wsargent
wsargent / docker_cheat.md
Last active June 29, 2024 19:32
Docker cheat sheet