Skip to content

Instantly share code, notes, and snippets.

@ato
ato / debug.clj
Created December 9, 2009 11:42
Simpler debug-repl that works with unmodified Clojure
;; Inspired by George Jahad's version: http://georgejahad.com/clojure/debug-repl.html
(defmacro local-bindings
"Produces a map of the names of local bindings to their values."
[]
(let [symbols (map key @clojure.lang.Compiler/LOCAL_ENV)]
(zipmap (map (fn [sym] `(quote ~sym)) symbols) symbols)))
(declare *locals*)
(defn eval-with-locals
@alandipert
alandipert / midi.clj
Created March 31, 2010 12:37
Play music with Clojure and javax.sound.midi
(import '(javax.sound.midi MidiSystem Synthesizer))
(defn play-note [synth channel note-map]
(let [{:keys [note velocity duration]
:or {note 60
velocity 127
duration 1000}} note-map]
(. channel noteOn note velocity)
(Thread/sleep duration)
(. channel noteOff note)))
@ryancrum
ryancrum / jquerytest.cljs
Created July 21, 2011 02:24
How to use jQuery from ClojureScript
(ns jquerytest.core)
(def jquery (js* "$"))
(jquery
(fn []
(-> (jquery "div.meat")
(.html "This is a test.")
(.append "<div>Look here!</div>"))))
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@lspector
lspector / evolvefn_noeval.clj
Created August 19, 2012 23:36
Clojure code for tree-based genetic programming. Like evolvefn.clj but doesn't call eval.
;; Lee Spector (lspector@hampshire.edu) 20111018 - 20120819
;; 20111113 update: handles functions of different arities
;; 20120819 update: forked this from evolvefn.clj and removed eval
(ns evolvefn_noeval
(:require [clojure.zip :as zip])
(:use [clojure.walk]))
;; This code defines and runs a genetic programming system on the problem
@trishume
trishume / .slate
Created November 20, 2012 22:21
My Slate config
# Configs
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
config secondsBetweenRepeat 0.1
config checkDefaultsOnLoad true
config focusCheckWidthMax 3000
config keyboardLayout dvorak
config windowHintsShowIcons true
config windowHintsIgnoreHiddenWindows false
@fogus
fogus / core.clj
Last active December 20, 2015 09:09
(ns depr.core)
(defn ^:private !! [c]
(println "WARNING - Deprecation of " c " in effect."))
(defmacro defn-deprecated
[nom _ alt ds & arities]
(let [silence? (:silence-deprecations (meta clojure.core/*ns*))]
(when-not silence?
(!! alt)))
macro invert {
rule { { $x:ident <- $y:expr } } => {
$y(function($x) { return $x })
}
rule { { $x:ident <- $y:expr $rest ... } } => {
$y(function($x) {
return invert { $rest ... }
})
}
rule { { $y:expr } } => { $y }
@jackrusher
jackrusher / rhyming-and-scheming.clj
Created January 26, 2014 22:42
Finding rhymes with clojure and CMU's pronunciation dictionary. Tested with this file, minus comments, as 'cmudict.txt': http://svn.code.sf.net/p/cmusphinx/code/trunk/cmudict/cmudict.0.7a
(def rhyme-txt
(map #(string/split % #"[ ]+") (string/split-lines (slurp "cmudict.txt"))))
(def word-to-rhyme
(reduce (fn [m [word & rhyme]]
(assoc m
(string/lower-case word)
(mapv #(keyword (string/replace %1 #"[0-9]" "")) (reverse rhyme))))
{} rhyme-txt))
@jpillora
jpillora / sshd.go
Last active December 17, 2023 16:27
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client: