Skip to content

Instantly share code, notes, and snippets.

@krisfoster
krisfoster / markov.el
Last active May 11, 2021 13:50
Scratch attempt at a markov model in elisp. God help me.
; Package-Requires: ((dash "2.10.0") (dash-functional "1.2.0") (emacs "24"))
;;;
;;; A markov model for generating rubbish text in an amusing
;;; and diverting number of voices.
;;;
;;
;; How to use:
;;
;; The steps about downloading the smaple text files aren't
@alexhall
alexhall / gist:5286484
Created April 1, 2013 17:51
declaring dynamic functions
;; internal helper function
(defn default-foo [] "Hello, world!")
;; public API
(def ^:dynamic *foo* default-foo)
(defn bar [] (*foo*))
;; Usage
(bar)
(binding [*foo* #("Goodbye, world!")]
@krisfoster
krisfoster / gist:4492592
Created January 9, 2013 11:55
Using emacs (server) for SVN commits
Set up:
export EDITOR=emacsclient
In a running emacs:
M-x server-start
To quit editing and return control the gnuclient:
@lynaghk
lynaghk / 0-update.md
Last active July 5, 2022 13:33
Angular.js from ClojureScript
@michaelklishin
michaelklishin / latency.txt
Created June 19, 2012 00:13 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@paulirish
paulirish / rAF.js
Last active June 11, 2024 14:29
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@ibdknox
ibdknox / alephNoir.clj
Created October 2, 2011 19:53
aleph and noir
(require '[noir.server :as server])
(use 'noir.core 'aleph.http 'lamina.core)
(defn async-response [response-channel request]
(enqueue response-channel
{:status 200
:headers {"content-type" "text/plain"}
:body "async response"}))
(defpage "/" [] "hey from Noir!")
@krisfoster
krisfoster / mailmoch.sh
Created June 9, 2011 14:58
Mock out an SMTP Mail Server - Python
#!/bin/bash
# Copied from a blog... but I have lost the link to it
HOST=localhost
PORT=25
python -m smtpd -n -c DebuggingServer ${HOST}:${PORT}
(ns bpsmannschott
(:import java.io.File)
(:import java.io.FileNotFoundException))
(defn as-file [s]
"Return whatever we have as a java.io.File object"
(cond (instance? File s) s ; already a file, return unchanged
(string? s) (File. s) ; return java.io.File for path s
:else (throw (FileNotFoundException. (str s)))))