Skip to content

Instantly share code, notes, and snippets.

View postspectacular's full-sized avatar
🎉
Celebrating 24 years of building open source tools

Karsten Schmidt postspectacular

🎉
Celebrating 24 years of building open source tools
View GitHub Profile
@postspectacular
postspectacular / deftype-apply.clj
Created February 19, 2014 17:22
deftype & applyTo problem illustrated
(deftype Foo [x y]
clojure.lang.IFn
(invoke [_ a] (case a 0 x, 1 y))
(invoke [_ a nf] (case a 0 x, 1 y nf)))
(def f (Foo. 23 42))
(f 0) ; => 23
(f 2 -1) ; => -1
(apply f [0]) ; AbstractMethodError clojure.core/apply (core.clj:624)
@postspectacular
postspectacular / pointatdemo.clj
Last active August 29, 2015 13:57
3D point-at demo using alignment quaternion. this example requires thi.ng/geom "0.3.0-SNAPSHOT" or later.
(ns pointatdemo
(:require
[thi.ng.geom.core :as g]
[thi.ng.geom.tetrahedron :as t]
[thi.ng.geom.meshio :as mio]
[clojure.java.io :as io]))
(defn point-at
"Takes an entity implementing PTransform, a reference point and two
direction vectors. Transforms the entity in such a way that the 1st
@postspectacular
postspectacular / gist:10312313
Created April 9, 2014 20:38
Setup selfsigned SSL cert for nginx
# https://www.digitalocean.com/community/articles/how-to-create-a-ssl-certificate-on-nginx-for-ubuntu-12-04
sudo openssl genrsa -des3 -out new.key 1024
sudo openssl req -new -key new.key -out new.csr
sudo cp new.key new.key.orig
sudo openssl rsa -in new.key.orig -out new.key
sudo openssl x509 -req -days 1095 -in new.csr -signkey new.key -out new.crt
sudo service nginx restart

Toxi's Lebkuchen (plain "Elisen" style)

Spice blend

  • 3 whole star anise
  • 15 whole cardamon pods
  • 2 tblsp ground cinnamon (or ~0.75 stick)
  • 1.5 tblsp ground cloves
  • 0.5 tsp ground coriander
  • 0.75 tsp ground ginger
@postspectacular
postspectacular / gist:a50083bdd22441a295d0
Created February 19, 2015 12:05
High quality JPG conversion w/ IM
convert -strip -interlace Plane -sampling-factor 4:2:0 -define jpeg:dct-method=float -quality 90% src.jpg dest.jpg
@postspectacular
postspectacular / coloredmesh.cljs
Last active August 29, 2015 14:17
geom-webgl workaround for individual colored faces: Until face/vertex attributes are implemented in https://github.com/thi-ng/geom, colored meshes for WebGL apps can be achieved by building the attribute buffers (semi)manually...
(ns coloredmesh
(:require
[thi.ng.geom.core :as g]
[thi.ng.geom.core.vector :as v]
[thi.ng.geom.core.matrix :as mat :refer [M44]]
[thi.ng.geom.aabb :as a]
[thi.ng.geom.core.utils :as gu]
[thi.ng.geom.webgl.core :as gl]
[thi.ng.geom.webgl.arrays :as arrays]
[thi.ng.geom.webgl.animator :as anim]
@postspectacular
postspectacular / ebug.cljs
Created April 16, 2015 18:05
Clojurescript eduction reduce bug?
;; CLJS 0.0-3196
(reduce conj [] (eduction (filter identity) [1 2 3 4]))
;; [1 2 3 4]
(defrecord Foo [state])
(defn add-foo [foo x] (Foo. (conj (:state foo) x)))
(reduce add-foo (Foo. []) (sequence (filter identity) [1 2 3 4]))
;; => #cljs.user.Foo{:state [1 2 3 4]}
Below I collected relevant links and papers more or less pertaining to the subject of tetrahedral meshes.
It's an ever-growing list.
------------------------------
Relevant links:
http://en.wikipedia.org/wiki/Types_of_mesh
http://en.wikipedia.org/wiki/Tetrahedron
http://en.wikipedia.org/wiki/Simplicial_complex
@postspectacular
postspectacular / gist:b62565c0e788e8f27dfd
Last active August 29, 2015 14:22
geom-webgl mesh handling with & without vertex attributes (temp. workaround until fully implemented)
(require
'[thi.ng.geom.core :as g]
'[thi.ng.geom.core.vector :as v :refer [vec2 vec3]]
'[thi.ng.geom.core.matrix :refer [M44]]
'[thi.ng.geom.core.utils :as gu]
'[thi.ng.geom.aabb :as a]
'[thi.ng.geom.plane :as pl]
'[thi.ng.geom.quad :as q]
'[thi.ng.geom.webgl.core :as gl]
'[thi.ng.geom.webgl.buffers :as buf]
@postspectacular
postspectacular / accept.clj
Created September 9, 2015 10:58
Parse accept header into prioritized seq
(require '[thi.ng.strf.core :as strf])
(require '[clojure.string :as str])
(defn parse-accept-header
[accept]
(->> accept
(re-seq #"((([\w\*\-]+/[\w\*\-\+]+,?)+)(;q=(\d+\.\d+))?)")
(mapcat
(fn [[_ _ a _ _ q]]
(let [q (if q (strf/parse-float q 0) 1)]