Skip to content

Instantly share code, notes, and snippets.


Alex Whitt WhittlesJr

View GitHub Profile
techhazard /
Last active May 8, 2020
NixOS: PCI Passthrough

PCI Passthrough

Warning: unfinished (but successfull!)

I did PCI passthrough on Archlinux and Debian with the old PCI-stub method (this was pre-4.0 era). And later I did PCI passthrough on the 4.1+ kernels on Arch and Ubuntu (16.10 I think?).

This is my attempt at doing the same on Nixos.


kennyjwilli / defspec-test.clj
Created Nov 5, 2016
clojure.spec.test integration with clojure.test
View defspec-test.clj
(defmacro defspec-test
([name sym-or-syms] `(defspec-test ~name ~sym-or-syms nil))
([name sym-or-syms opts]
(when t/*load-tests*
`(def ~(vary-meta name assoc :test `(fn []
(let [check-results# (clojure.spec.test/check ~sym-or-syms ~opts)
checks-passed?# (every? nil? (map :failure check-results#))]
(if checks-passed?#
(t/do-report {:type :pass
:message (str "Generative tests pass for "
sunng87 / reflection.clj
Created Nov 20, 2015
clojure: access private field/method via reflection
View reflection.clj
(defn invoke-private-method [obj fn-name-string & args]
(let [m (first (filter (fn [x] (.. x getName (equals fn-name-string)))
(.. obj getClass getDeclaredMethods)))]
(. m (setAccessible true))
(. m (invoke obj args))))
(defn private-field [obj fn-name-string]
(let [m (.. obj getClass (getDeclaredField fn-name-string))]
(. m (setAccessible true))
(. m (get obj))))
pingles / bytes_to_int.clj
Created Sep 22, 2011
Clojure code to convert a byte array to an integer
View bytes_to_int.clj
(defn bytes-to-int
(bytes-to-int bytes 0))
([bytes offset]
(reduce + 0
(map (fn [i]
(let [shift (* (- 4 1 i)
(bit-shift-left (bit-and (nth bytes (+ i offset))
You can’t perform that action at this time.