Skip to content

Instantly share code, notes, and snippets.

@mike-thompson-day8
mike-thompson-day8 / gist:76812d5452747bc79aac
Last active June 25, 2018 14:30
Middleware Which Acts Like A reverse reaction
(defn on-changes
"Middleware factory which acts a bit like \"reaction\" (but it flows into db , rather than out)
It observes N inputs (paths into db) and if any of them change (as a result of the
handler being run) then it runs 'f' to compute a new value, which is
then assoced into the given out=path within app-db.
Usage:
(defn my-f
[a-val b-val]
#Tribute to Dr Who coded by Robin Newman, February 2015
#Better on a Pi2 or Mac. A bit scratchy on B+ but just about OK
use_synth :prophet #synth for bass part
s=0 #to set the scope of the variable redefined in the next function
define :usebpm do |n| #setup own bpm definition
s=1.0/8*120/n
end
usebpm(200) #set required bpm
@pandeiro
pandeiro / README.md
Last active June 2, 2020 08:02
Example of a simple webapp written as a single file

Instructions

  1. Get Boot
  2. Copy the above file to $HOME/app.boot
  3. $ chmod a+x $HOME/app.boot
  4. $ cd && ./app.boot
@john2x
john2x / 00_destructuring.md
Last active April 23, 2024 13:18
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

@staltz
staltz / introrx.md
Last active May 20, 2024 14:59
The introduction to Reactive Programming you've been missing
@graemerocher
graemerocher / boot-gorm-hibernate4.groovy
Created April 4, 2014 08:21
Using GORM for Hibernate 4 in Spring Boot
@Grab("org.grails:gorm-hibernate4-spring-boot:1.0.0.RC2")
@Grab("com.h2database:h2:1.3.173")
import grails.persistence.*
import org.springframework.http.*
import static org.springframework.web.bind.annotation.RequestMethod.*
@RestController
class GreetingController {
@RequestMapping(value="/person/greet", method = GET)
@pbaille
pbaille / midi-parser.clj
Last active April 10, 2020 09:09
midi-parser in Clojure
(ns midi-parser.core
(:use clojure.java.data)
#_(:use utils.utils)
#_(:use vendors.debug-repl)
(:import (java.io File)
#_(java.util Arrays)
#_(java.nio ByteBuffer)
(javax.sound.midi MidiSystem Sequence MidiMessage MidiEvent ShortMessage MetaMessage Track)))
;***************** Utils ********************
;;;; Super top secret talk stuff nobody should ever see. Shhh.
(in-ns 'user)
(defmacro bench [& body]
`((re-find #"\"(.*)\"" (with-out-str (time (do ~@body)))) 1))
*ns*
(require 'clojure.walk)
@wsargent
wsargent / docker_cheat.md
Last active August 31, 2023 12:10
Docker cheat sheet