Skip to content

Instantly share code, notes, and snippets.

View lantiga's full-sized avatar

Luca Antiga lantiga

View GitHub Profile
@wojdyr
wojdyr / mbox_send.py
Created August 28, 2011 08:14
script to send all messages in an mbox file to a specific email address, with various options
#!/usr/bin/python
"""\
A command-line utility that can (re)send all messages in an mbox file
to a specific email address, with options for controlling the rate at
which they are sent, etc.
"""
# I got this script from Robin Dunn a few years ago, see
# https://github.com/wojdyr/fityk/wiki/MigrationToGoogleGroups
@mojavelinux
mojavelinux / Writing Tools Writeup.markdown
Created January 30, 2012 18:56 — forked from matthewmccullough/Writing Tools Writeup.md
How To Write A Technical Book (One Man's Modest Suggestions)
@rnewson
rnewson / gist:2387973
Created April 14, 2012 21:31
CouchDB Future Feature List - Round 2
A list of features that we want to see in CouchDB. Needs to be voted on so that it can become a priority queue.
User Facing Features
====================
1. Conflicts are the rule, not the exception
All previous versions of CouchDB hide conflicts by default (selecting
an arbitrary but consistent winning revision). Expert users can find
and resolve conflicts.
@jterrace
jterrace / xvfb
Created June 11, 2012 18:46
xvfb init script for Ubuntu
XVFB=/usr/bin/Xvfb
XVFBARGS=":1 -screen 0 1024x768x24 -ac +extension GLX +render -noreset"
PIDFILE=/var/run/xvfb.pid
case "$1" in
start)
echo -n "Starting virtual X frame buffer: Xvfb"
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."
;;
stop)
@cemerick
cemerick / gist:3657912
Created September 6, 2012 16:07
#{Ring, Compojure}-friendly shoreleave-remote backend
;;; this is now in a library: https://github.com/cemerick/shoreleave-remote-ring
(ns ^{:doc "Server-side RPC support for use with shoreleave (and maybe fetch?).
Mostly copied from https://github.com/shoreleave/shoreleave-remote-noir;
changed to eliminate the noir-isms..."}
cemerick.cljs.rpc)
(def default-remote-uri "/_fetch")
(def remotes (atom {}))
@jvranish
jvranish / dynamic_alloc_reverse.c
Created September 22, 2012 21:07
Dynamic Allocation without malloc in C (with no mutation!)
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
/*
This is our integer linked list type (Null is an empty list)
(it is immutable, note the consts)
*/
typedef struct IntList_s const * const IntList;
@swannodette
swannodette / boom.clj
Created November 27, 2012 23:45
path_constraint.clj
;; using defc from core.logic master
;; guarantee that a path of keys does not occur in map x,
;; note that the body of a defc is in fact just regular
;; Clojure code
(defc not-pathc [x path]
(= (get-in x path :not-found) :not-found))
(comment
@ptaoussanis
ptaoussanis / free-port.clj
Created December 14, 2012 06:28
A little utility to allow simple redeployment of Clojure web servers with zero downtime, and without the need for a proxy or load balancer. Just wrap any port-binding calls, and the utility will auto kill pre-existing servers as necessary. *nix only. Based on the blog post by Feng Shen, http://shenfeng.me/fast-restart-clojure-webapp.html
;; (require '[clojure.string :as str] '[clojure.java.shell :as shell] '[taoensso.timbre :as timbre])
(defn with-free-port!
"Attempts to kill any current port-binding process, then repeatedly executes
nullary `bind-port!-fn` (which must return logical true on successful
binding). Returns the function's result when successful, else throws an
exception. *nix only.
This idea courtesy of Feng Shen, Ref. http://goo.gl/kEolu."
[port bind-port!-fn & {:keys [max-attempts sleep-ms]

Array abstraction in Clojure

Few days ago Mike Anderson wrote [a proposal][mike] for a generic matrix API in Clojure which could compete with NumPy. I wanted to write a similar post for months, but was reluctant to start. This problem is very dear to me. Basically, it is a matter if I can use Clojure for most of my work, or it remains a toy language for me. Thanks to Mike for bringing the question up. Though, I have a different vision of how we should approach arrays and matrices in Clojure.

(ns speed-test.core
;; Original Java Source
(:import LCS))
(set! *warn-on-reflection* true)
(defn time-it [num-trials f]
(loop [sum-ms 0 trials-left num-trials]
(let [start (System/currentTimeMillis)]
(f)