Skip to content

Instantly share code, notes, and snippets.

@gustavla
gustavla / gist:9499068
Created March 12, 2014 01:45
_isotonic.pyx
# Author: Nelle Varoquaux, Andrew Tulloch
# Uses the pool adjacent violators algorithm (PAVA), with the
# enhancement of searching for the longest decreasing subsequence to
# pool at each step.
import numpy as np
cimport numpy as np
cimport cython
@eraserhd
eraserhd / macros.clj
Created April 19, 2014 23:17
in-> and ->' macros
(ns avi.compose)
(declare ^:private splice-form)
(defn- splice-normal-form
[value form]
(apply list (first form) value (rest form)))
(defn- splice-if-form
[value form]
(sm/defn coupon-lookup
"If the code supplied is empty, sends a failed discount on
immediately. (This won't affect the rendering, since nothing's
shown if the code is blank.) If the code is NOT blank, fires off an
Ajax request to the server to look up the discount.
TODO: Ideally we'd have a channel that could signal a dissoc,
instead of only adding items to the state."
[title :- regatta/Title
code :- coupon/Code
@grandchild
grandchild / selfspy.conf
Last active August 29, 2015 14:07
An example config for selfspy
# Example selfspy.conf. Put this in your ~/.config/ to use it
# with the systemd .service file.
# Note: You cannot indent lines in here!
# Defaults, used by both selfspy and selfstats.
[Defaults]
# Don't use quotes around the password, they'd be part of it!
# Example:
@loganlinn
loganlinn / schema_extensions.clj
Last active August 29, 2015 14:10
variants in schema extensions
(ns schema-client.schema-extensions
"Schemas representing abstract classes and subclasses"
(:use plumbing.core)
(:require
[clojure.string :as str]
[plumbing.map :as map]
[schema.core :as s]
[schema.utils :as utils]
[schema.macros :as sm]))
@timcharper
timcharper / company.el
Last active August 29, 2015 14:12
Some initializers
(require 'company)
(global-company-mode t)
(global-set-key (kbd "s-;") 'company-dabbrev)
(global-set-key (kbd "s-:") 'company-complete)
(global-auto-complete-mode 0) ;; disable this!!! they fight eachother and it is annoying.
(require '[clj-serializer.core :as serializer])
(require '[clj-json.core :as m-json])
(require '[org.danlarkin.json :as dl-json])
(require '[clojure.contrib.json.read :as cc-json-read])
(require '[clojure.contrib.json.write :as cc-json-write])
(defn nano-time []
(System/nanoTime))
(defn timed [task]
#!/usr/bin/env ruby
def find_deps(cookbook_dir)
nel = Hash.new { |h, k| h[k] = [] }
Dir.glob("#{cookbook_dir}/*/").each do |r|
deps_for(r, nel)
end
nel
end
(ns org.dipert.reconfig
"Reads a file of Clojure data into *config*
when a SIGHUP is recieved.
Useful for daemons that support the reloading of
configuration data while running."
(:use [clojure.contrib.io :only (reader)]
[clojure.contrib.logging :only (info warn)])
(:import (sun.misc Signal SignalHandler)
(java.io File PushbackReader)))
(defn mapmap
"Return a new map, mapping keys to (keyfn key) and mapping values to
(valfn val)"
([valfn map]
(mapmap identity valfn map))
([keyfn valfn map]
(persistent! (reduce
(fn [c [k v]] (assoc! c (keyfn k) (valfn v)))
(transient {})
map))))