Skip to content

Instantly share code, notes, and snippets.

View lambder's full-sized avatar

Lambder lambder

View GitHub Profile
(ns hiredman.schedule
(:import (java.util.concurrent ScheduledThreadPoolExecutor TimeUnit)))
(def unit {:minutes TimeUnit/MINUTES :seconds TimeUnit/SECONDS :hours TimeUnit/HOURS})
(def tasks (ref {}))
(def #^{:doc "ScheduledThreadPoolExecutor for scheduling repeated/delayed tasks"}
task-runner (ScheduledThreadPoolExecutor. (+ 1 (.availableProcessors (Runtime/getRuntime)))))
$(function() {
//run the accordion plugin, set height of sections to height of content
$("#accordion").accordion({ autoHeight: false });
});
;(function($) {
//write new sammy application
var app = new Sammy.Application(function() {
with(this) {
//corresponds to routes such as #/section/1
get('#/section/:section_id', function() { with(this) {
<!DOCTYPE html>
<!-- Helpful things to keep in your <head/>
// Brian Blakely, 360i
// http://twitter.com/brianblakely/
-->
<head>
<!-- According to Heather Champ, former community manager at flickr,
you should not allow search engines to index your "Contact Us"
#!/bin/bash
cat .gitignore | egrep -v "^#|^$" | while read line; do
if [ -n "$line" ]; then
OLD_IFS=$IFS; IFS=""
for ignored_file in $( git ls-files "$line" ); do
git rm --cached "$ignored_file"
done
IFS=$OLD_IFS
fi
@lambder
lambder / gist:2066588
Created March 17, 2012 23:36
The Zen of R
# I am a scientist who has been using R for about 2 years. Today I achieved a measure of enlightenment into
# the zen of R, and I want to share it with you.
# I was simulating a set of independent random walks, which are formed by a multiplicative process. Here is
# the code I had built up over a few months of working on it and modifying it on and off as research
# questions changed:
TimeSteps <- 1000
Walks <- 100
ErrorMagnitude <- 0.03
@lambder
lambder / optional-config.clj
Created March 29, 2012 15:33 — forked from jsofra/optional-config.clj
Config using optional named parameters
(def ^:dynamic *config* nil)
(defn save [data & {:keys [config] :or {config *config*}}]
(println (format "Saved %s with %s" data config)))
;; => (save {:a 5 :b 6} :config {:some :config})
;; Saved {:a 5, :b 6} with {:some :config}
;; nil
;; => (binding [*config* {:some :config}] (save {:a 5 :b 6}))
;; Saved {:a 5, :b 6} with {:some :config}
@lambder
lambder / 0_README.md
Created September 7, 2012 19:35 — forked from netzpirat/0_README.md
Continuous CoffeeScript testing with Guard and Jasmine

Continuous CoffeeScript testing with Guard and Jasmine

This Gist shows how to set up a Rails project to practice BDD with CoffeeScript, Guard and Jasmine. You can see this setup in action on Vimeo

  • Install Gems with Bundler with bundle install
  • Define your guards with mate Guardfile
  • Initialize Jasmine with bundle exec jasmine init
  • Configure Jasmine with mate spec/support/yasmine.ym
  • Start Guard with bundle exec guard
@lambder
lambder / sum.clj
Created August 24, 2013 23:25 — forked from stuartsierra/sum.clj
;; Demonstration of JVM dead code elimination in Clojure 1.2 and 1.5
;;
;; This Clojure script demonstrates some of the effects of dead code
;; elimination in the JVM. For unknown reasons, the bytecode produced
;; by Clojure 1.2.1 is more susceptible to elimination than the
;; bytecode produced by Clojure 1.5.1, making it seem like 1.2.1 is
;; faster. But when the code is forced to do real work, the difference
;; disappears.
;;
;; My results with Clojure 1.2.1:
(use 'com.lambder.deriva.core)
(def N
'(/ 1
(+ 1
(exp (-
(* -0.07056 (pow x 3))
(* -1.5976 x)))))
(def d1 '(/ (+ (/ F K) (* T (/ (sq sigma) 2)))))
//based on code from http://www.arcfn.com/2009/03/y-combinator-in-arc-and-java.html and the generic version https://gist.github.com/2571928
class YFact {
// T function returning a T
// T -> T
public static interface Func<T> {
T apply(T n);
}
// Higher-order function returning a T function