Skip to content

Instantly share code, notes, and snippets.

View claj's full-sized avatar

Linus Ericsson claj

  • Sweden
  • 00:22 (UTC +02:00)
View GitHub Profile
@hiredman
hiredman / core.clj
Created October 25, 2011 22:56
srepl.clj
(ns srepl.core
(:use [clojure.main :only [repl]]
[clojure.pprint :only [pprint with-pprint-dispatch code-dispatch]])
(:import (jline.console ConsoleReader)
(jline.console.completer Completer))
(:gen-class))
(defmulti super-dispatch class)
(defmethod super-dispatch :default [thing]
@mrh0057
mrh0057 / browser-repl.bat
Created October 24, 2011 22:03
ClojureScript Inferior Lisp Mode Windows
@echo off
setLocal EnableDelayedExpansion
if "%CLOJURESCRIPT_HOME%" == "" set CLOJURESCRIPT_HOME=%~dp0..\
set CLASSPATH=%CLOJURESCRIPT_HOME%\src\clj;%CLOJURESCRIPT_HOME%\src\cljs;%CD%\src\cljs;%CD%\src\clj;%CD%\test\cljs;%CD%\test\clj"
for /R "%CLOJURESCRIPT_HOME%\lib" %%a in (*.jar) do (
set CLASSPATH=!CLASSPATH!;%%a
)
for /R "%CD%\lib" %%a in (*.jar) do (
@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!")
@ithayer
ithayer / create-heroku
Created July 4, 2011 19:20
Clojure on Heroku with Noir and Mongo Demo
# Commands to initialize a simple heroku noir app. You can cut and paste them together.
# Install latest version of noir. If an older version is installed, remove it first.
lein plugin install lein-noir "1.1.0-SNAPSHOT"
# Create new noir project.
lein noir new noir-mongo-heroku
cd noir-mongo-heroku
# Create instructions for heroku.
echo 'web: lein run' > Procfile
# Create git repository.
@djpowell
djpowell / finger_tree_stats.clj
Created November 11, 2010 14:53
fingertree stats
(ns finger-tree-stats
(:use [clojure.data.finger-tree]))
(defrecord stats [^double number ^double mean ^double variance])
(def null-stats (stats. 0 0 Double/NaN))
(defn make-stats
[^double x]
(stats. 1 x 0))
@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)))
(import 'org.apache.commons.mail.SimpleEmail)
(doto (SimpleEmail.)
(.setHostName "smtp.gmail.com")
(.setSslSmtpPort "465")
(.setSSL true)
(.addTo "you@gmail.com")
(.setFrom "you@gmail.com" "Lucky Clojurian")
(.setSubject "Hello from clojure")
(.setMsg "Wasn't that easy?")
(.setAuthentication "you@gmail.com" "yourpassword")