Skip to content

Instantly share code, notes, and snippets.

View yogthos's full-sized avatar
🤷‍♂️

Dmitri Sotnikov yogthos

🤷‍♂️
View GitHub Profile
(ns noise)
(def distributions
{:uniform 1
:triangular 2
:bell 5})
(defn random-parametric [n bias]
(Math/pow
(/ (->> #(Math/random)
(ns file-watcher
(:require [clojure.set :refer [rename-keys]]
[clojure.java.io :refer [file]])
(:import
[java.nio.file
FileSystems
Path
Paths
StandardWatchEventKinds]))
@yogthos
yogthos / html_pdf.clj
Created July 7, 2014 15:36
HTML to PDF example
(ns html-pdf
(:require [clojure.xml :refer [parse]]
[clj-pdf.core :refer [pdf]]))
(def tag-map
{:html [{}]
:h1 [:paragraph {:leading 20 :style :bold :size 14}]
:h2 [:paragraph {:leading 20 :style :bold :size 12}]
:h3 [:paragraph {:leading 20 :style :bold :size 10}]
:hr [:line]
(ns bloom.core
(:require [com.github.kyleburton.clj-bloom
:refer [make-optimal-filter
optimal-n-and-k
make-permuted-hash-fn
make-hash-fn-crc32
add!
include?]])
(:import [java.util BitSet]))
(ns parser)
(defn read-char [rdr]
(let [ch (.read rdr)]
(if-not (== -1 ch) (char ch))))
(def expr-tags
{:if #(str "if tag args: " (clojure.string/join ", " %1))})
(defn expr-tag [{:keys [tag-name args] :as tag} rdr]
@yogthos
yogthos / metaballs.clj
Created December 4, 2013 23:11
Metaballs examples
(ns metaballs
(:import
[javax.swing JFrame]
[java.awt Canvas Graphics Color]
java.awt.image.BufferStrategy))
(set! *warn-on-reflection* true)
(def SIZE 250)
(function() {
var colorChooser, AlbumImage, AlbumColors;
/* colorChooser
* A series of function that is used to pick up 3 colors among 10 dominating colors
*/
colorChooser = {
colorStringToRGBArray: function(colorString) {
var n, arr = colorString.split(',');
(defn sorted-key-list
[& maps]
(or
(->>
(mapcat keys maps)
set
(map str)
sort
(clojure.string/join ", ")
not-empty)
@yogthos
yogthos / gist:4229822
Created December 7, 2012 00:55
Guestbook app
wget https://raw.github.com/technomancy/leiningen/preview/bin/lein
chmod +x lein
lein self-install
lein new noir guestbook
cd guestbook

#Add dependencies

@yogthos
yogthos / gist:3411106
Created August 21, 2012 03:00
Metaballs with optimizations
(ns metaballs
(:import
[javax.swing JFrame]
[java.awt Canvas Graphics Color]
java.awt.image.BufferStrategy))
(set! *warn-on-reflection* true)
(def ^:const SIZE 250)
(defn direction [p v]