This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Title: MMD Cheat Sheet | |
Author: Pierce T. Wetter III | |
Email: pierce@twinforces.com | |
Date: September 6, 2013 | |
### Basics ### | |
| What | | Syntax | | |
| :------------ | -- | :----------- | | |
| *Italic* | | \*Italic\* or \_Italic\_| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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] |
NewerOlder