Skip to content

Instantly share code, notes, and snippets.

package pl.allegro.tech.hermes.common.di;
import org.glassfish.hk2.api.DynamicConfiguration;
import org.glassfish.hk2.api.Factory;
import org.glassfish.hk2.utilities.Binder;
import org.glassfish.hk2.utilities.binding.ServiceBindingBuilder;
import org.glassfish.jersey.internal.inject.Injections;
@SuppressWarnings("unchecked")
public class InstantFactoryBinder {
@pjagielski
pjagielski / js-file-schema.cljs
Created February 11, 2015 19:07
Schema failing in phantomjs tests
(deftest file-validation
(s/defschema FileSchema
{:file (s/maybe (s/both js/File (s/pred (fn [f] (if f (< (.-size f) 1000000))) 'large-file)))})
(s/defn validated-file
[file :- [FileSchema]] 1)
(s/with-fn-validation
(is (= 1 (validated-file {:file nil})))))
lein new duct clojure-web-app +example
lein repl
(go)
[ring/ring-json "0.3.1"]
[cheshire "5.1.1"]
[ring.middleware.json :refer [wrap-json-body wrap-json-response]]
[wrap-json-body {:keywords? true}]
[org.clojure/clojurescript "1.7.48"]
[org.clojure/core.async "0.1.346.0-17112a-alpha"]
[cljs-http "0.1.37"]
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [cljs-http.client :as http]
[cljs.core.async :refer [<! >! chan]]))
(defn rest-call []
(go
@pjagielski
pjagielski / api.clj
Last active November 23, 2015 19:43
clojure-web
(ns jinkubator.endpoint.api
(:require [compojure.api.sweet :refer :all]
[ring.util.http-response :refer [ok]]
[schema.core :as s]))
(s/defschema Message
{:message s/Str})
(s/defschema MessageList
[Message])
@pjagielski
pjagielski / count-on-me.rb
Created May 14, 2016 20:07
Count on me supersaw
use_bpm 130
ch1 = [62,65,69]
ch2 = [63,67,70]
ch3 = [65,69,72]
ch4 = [67,70,74]
live_loop :saws do
use_synth :supersaw
with_synth_defaults sustain_level: 0.75, release: 1.25, cutoff: 130, amp: 1.5 do
use_bpm 130
samps = "path_to_breaks" ## download from http://www.junglebreaks.co.uk/breaks.html
ch1 = [61,68,78]
ch2 = [61,68,76]
ch3 = [64,71,76]
ch4 = [59,66,75]
ch5 = [59,66,76]
ch6 = [57,64,76]
@pjagielski
pjagielski / clojuredays_talk.clj
Last active August 24, 2022 02:37
My talk from Dutch Clojure Days 2017
(ns talk
(:require [overtone.core :refer :all]
[clojure.java.io :as io]))
;; Overtone by Sam Aaron & Jeff Rose
;; https://github.com/overtone/overtone
(definst da-funk [freq 440 dur 1.0 amp 1.0 cutoff 1700 boost 6 dist-level 0.015]
(let [env (env-gen (adsr 0.3 0.7 0.5 0.3) (line:kr 1.0 0.0 dur) :action FREE)
filter-env (+ (* freq 0.15)
@pjagielski
pjagielski / shape.rb
Last active September 12, 2021 16:18
Shape Of You in Sonic-Pi
use_bpm 100
ch1 = [73, 68, 61]
ch2 = [76, 68, 61]
ch3 = [73, 68, 61]
ch4 = [73, 69, 54]
ch5 = [76, 69, 54]
ch6 = [73, 69, 54]
ch7 = [73, 69, 57]
ch8 = [76, 69, 57]
(ns talk
(:require [overtone.core :refer :all]
[clojure.java.io :as io]
[clj-http.client :as http]
[clojure.test :as test]))
(def talk
{:title "Sequencing dance music with Clojure"
:author "Piotr Jagielski"
:company {:name "TouK" :what "Software house" :from "Warsaw, Poland"}