Skip to content

Instantly share code, notes, and snippets.

@lilactown
lilactown / rebel.sh
Last active June 18, 2019 09:52
Start a Clojure(Script) REPL with rebel-readline and any other dependencies you want to include
# Add these to your .bash_profile / .zshrc / etc.
# Starts a Clojure repl
function rebel-clj() {
clojure -Sdeps "{:deps {com.bhauman/rebel-readline {:mvn/version \"0.1.4\"} $@}}" -m rebel-readline.main
}
# Starts a browser REPL
function rebel-cljs() {
clojure -Sdeps "{:deps {com.bhauman/figwheel-main {:mvn/version \"0.1.7\"} com.bhauman/rebel-readline-cljs {:mvn/version \"0.1.4\"} $@}}" -m figwheel.main

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@teropa
teropa / life.cljs
Created November 3, 2015 09:57
Conway's Life in ClojureScript
;; Credits:
;;
;; * ClojureScript
;; * Reagent https://reagent-project.github.io/
;; * Figwheel https://github.com/bhauman/lein-figwheel
;; * core.async https://clojure.github.io/core.async/
;; * Christophe Grand's Life implementation http://clj-me.cgrand.net/2011/08/19/conways-game-of-life/
(ns life.core
(:require [reagent.core :as r]
@rbnpi
rbnpi / basssamplevoices.rb
Last active August 29, 2015 14:10
Sample based voices for all bass_xxx_c samples built into Sonic Pi, except for :bass_hit_c
#sample based voices for any bass_xxx_c samples over 4 octave range from :c2 to :c5 by Robin Newman December 2014
#use pl(inst,n,d=0.2,pan=0,v=0.8) to play a note where n is note symbol,d duration,v volume
#or plarray(inst,nt,dur,sh=0,vol=0.8,pan=0) to play lists of note symbols and durations
#where inst is samplename,nt and dur are note symbol and duration arrays,sh transpose shift
use_debug false
rm = 2**(1.0/12) #rate multiplier between adjacent semitones (twelth root of 2)
inst = :bass_hard_c #to define scope of inst variable set up here. Used as a parameter later
s=1.0/16 #speed multiplier give 2 crotchet/sec or 120 bpm
shift=0
@rbnpi
rbnpi / GlassArmonicaPlaysMozart.rb
Last active August 27, 2022 18:47
Glass Armonica for Sonic Pi plays Mozart UPDATED to use rpitch: (introduced after this was first written) to calculate sample rate. MUCH simpler
#a Glass Armonica "voice" for Sonic Pi by Robin Newman November 2014
# revised to use rpitch 2018; corrected 2022 for missing tr function
#This simulates the Glass Armonica invented by Benjamin Franklin and for which Mozart
#composed the piece played here
#This version uses rpitch: parameter added to Sonic Pi after the original was written in 2014
##| sample :ambi_glass_rub
##| play :fs5
##| puts note(:fs5)
##| stop
use_debug false
@gshaw
gshaw / carrier_wave.rb
Created August 14, 2014 19:06
CarrierWave initialization file for testing with fixtures and support S3 in staging and production.
# NullStorage provider for CarrierWave for use in tests. Doesn't actually
# upload or store files but allows test to pass as if files were stored and
# the use of fixtures.
class NullStorage
attr_reader :uploader
def initialize(uploader)
@uploader = uploader
end
@john2x
john2x / 00_destructuring.md
Last active June 6, 2024 13:40
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@twinforces
twinforces / gist:8548404
Created January 21, 2014 21:07
This is a cheat sheet for Multi-Markdown.
Title: MMD Cheat Sheet
Author: Pierce T. Wetter III
Email: pierce@twinforces.com
Date: September 6, 2013
### Basics ###
| What | | Syntax |
| :------------ | -- | :----------- |
| *Italic* | | \*Italic\* or \_Italic\_|
@ecmendenhall
ecmendenhall / core.clj
Last active February 12, 2016 13:32
Prime factors two ways: Traditional unit tests and simple-check generative tests.
(ns primes.core)
(defn trial-division [n divisor factors]
(if (< n 2)
factors
(if (= 0 (mod n divisor))
(recur (/ n divisor) divisor (conj factors divisor))
(recur n (inc divisor) factors))))
(defn prime-factors [n]