Skip to content

Instantly share code, notes, and snippets.

@raineorshine
raineorshine / human-readable-hash-comparisons.md
Last active April 26, 2024 13:52
An aesthetic comparison of a few human-readable hashing functions.

An Aesthetic Comparison of Human-Readable
Hashing Functions

The following compares the output of several creative hash functions designed for human readability.

sha1's are merely used as arbitrary, longer, distributed input values.

input 1 word output 2 word output 3 word output
@fasiha
fasiha / README.md
Last active October 2, 2022 22:36
Pitch (fundamental frequency) detection using (1) harmonic product spectrum, (2) Blackman-Tukey spectral estimator, and (3) Welch spectral estimator.

Experimenting with pitch detection and spectral estimators

See the question and discussion on StackOverflow: How to get the fundamental frequency using Harmonic Product Spectrum?.

We’re trying to estimate the fundamental frequency of a voiced A4 note (440 Hz). (See the question for link to audio clip.)

Harmonic product spectrum

Result: full data, 0 to 2 KHz

@olivergeorge
olivergeorge / Nicer Assert README.md
Last active March 31, 2016 01:38
Assert macro patch to show details about failed assertions.

This is an attempt to make assert more friendly by including more details in the assertion error.

  • show the result of the assertion expression
  • show local variable values used in assertion form

In other words, this should make assertion errors easier to reason about:

AssertionError Assert failed: Should be equal
@olivergeorge
olivergeorge / profile.clj
Created March 18, 2016 00:58
Lein user profile for convenient access to all common databases via JDBC
{:user {:plugins [[lein-ancient "0.6.8"]
[lein-pprint "1.1.1"]]
:resource-paths ["user-resources/sqljdbc4.jar"
"user-resources/sqljdbc.jar"
"user-resources/ojdbc6.jar"]
:dependencies [[org.clojure/java.jdbc "0.3.7"]
[org.postgresql/postgresql "9.4.1208"]
[mysql/mysql-connector-java "5.1.38"]
[net.sourceforge.jtds/jtds "1.3.1"]
[org.xerial/sqlite-jdbc "3.8.11.2"]
@paulirish
paulirish / what-forces-layout.md
Last active June 8, 2024 13:18
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@LazerPanther
LazerPanther / iterm2_settings.md
Last active January 27, 2021 23:22
Semantic history command for iTerm2 and Neovim. Allows iTerm integration of Command+Click to open a file in default app (if non-text), or Neovim with optional line number and column. Detects relative paths based on PWD.

Semantic history command for iTerm2 and Neovim.

In iTerm's Preferences > Profiles > Default > Advanced > Semantic History, choose Run command... and enter /your/path/to/iterm_open_with \5 \1 \2.

@micha
micha / throttle.cljs.hl
Last active October 30, 2016 02:23
Create a cell that only updates at most once every so many milliseconds
(defn throttle [c ms]
(let [queued? (atom false)]
(with-let [ret (cell @c)]
(add-watch c (gensym)
#(when-not @queued?
(reset! queued? true)
(with-timeout ms
(reset! queued? false)
(reset! ret @c)))))))
(defn my-get
"@param {*} m
@param {*} k
@return {nil|Object}"
[m k]
(get m k))
(defn foo
"@param {!Object} x" ;; non-nullable
[x] x)
(* -*- mode: ocaml; -*- *)
module type NEXT =
sig
type 'a t
exception Timing_error of int * int
val delay : (unit -> 'a) -> 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
val zip : 'a t * 'b t -> ('a * 'b) t
; compilers are cool
(when-let [missing-methods (->> possible-dispatch-values
(map #(when-not (get-method multimethod %) %))
(filter identity)
seq)]
(throw (ex-info "Missing methods for `multimethod`" {:dispatch-vals missing-methods})))