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
(def snare (sample (freesound-path 26903))) | |
(def kick (sample (freesound-path 2086))) | |
(def ch (sample (freesound-path 802))) | |
(def oh (sample (freesound-path 26657))) | |
; define a metronome that will fire every eighth note | |
; at 100 bpm | |
(def met (metronome (* 100 2))) | |
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
# The regular expression checks for a public class declared in the file. | |
# The match, captured using the $1 variable, then is used to rename the file according | |
# to java conventions, i.e. ClassName.java | |
perl -ne '/public class ([a-zA-Z0-9]+) / && rename($ARGV,$1.".".java)' * | |
# I created this gist because manning ships the source code for "Hadoop in Action" in files called | |
# "listing-2-2", with no indication what kind of file it is. |
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
package com.paulsanwald.prototype; | |
import static org.junit.Assert.*; | |
import java.util.Collection; | |
import java.util.List; | |
import org.junit.Test; | |
import com.google.common.base.Predicate; |
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
package com.redowl.prototype; | |
import static org.junit.Assert.*; | |
import java.util.Collection; | |
import java.util.List; | |
import org.junit.Test; | |
import com.google.common.base.Predicate; |
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
(import 'javax.sound.midi.Synthesizer 'javax.sound.midi.MidiSystem) | |
; plays a middle C for 2 seconds, then pauses for 500ms | |
(defn play [channel] | |
(do | |
(.noteOn channel 67 1) | |
(Thread/sleep 2000) | |
(.allNotesOff channel) | |
(Thread/sleep 500))) |
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
; declare a total variable which will keep | |
; count of the number of haircuts | |
(def total (agent 0)) | |
; declare a queue for customer/barber:producer/consumer behavior | |
(def seats (ref (clojure.lang.PersistentQueue/EMPTY))) | |
; it takes 20ms to give a haircut. | |
; when a haircut is done, we'll | |
; safely increment the total. | |
(defn cut-hair [thetotal] |