Skip to content

Instantly share code, notes, and snippets.

@genmeblog
genmeblog / init.el
Last active May 27, 2022
Emacs config
View init.el
;;
(setq gc-cons-threshold 10000000)
;; Restore after startup
(add-hook 'after-init-hook
(lambda ()
(setq gc-cons-threshold 1000000)
(message "gc-cons-threshold restored to %S"
gc-cons-threshold)))
@genmeblog
genmeblog / init.el
Last active Mar 29, 2022
Emacs config
View init.el
;;
(setq gc-cons-threshold 10000000)
;; Restore after startup
(add-hook 'after-init-hook
(lambda ()
(setq gc-cons-threshold 1000000)
(message "gc-cons-threshold restored to %S"
gc-cons-threshold)))
@genmeblog
genmeblog / select_by_index.clj
Last active Mar 21, 2021
Using TreeMap index to subselect datasets
View select_by_index.clj
(require '[clojure.set]
'[tablecloth.api :as api])
(defprotocol IndexProto
(slice-idx [idx ks] [idx from to] [idx from from-inclusive? to to-inclusive?]
"Slice by keys or range")
(select-by-idx [idx ks] [idx from to]
"Select by keys or range"))
;; TreeMap as an index
@genmeblog
genmeblog / format_sequence.clj
Last active Jun 18, 2020
Format sequence of doubles to seq of aligned strings
View format_sequence.clj
(ns format-sequence
"Format sequence of doubles"
(:require [clojure.pprint :refer [cl-format]]
[clojure.test :refer [deftest is]]))
(set! *warn-on-reflection* true)
(set! *unchecked-math* :warn-on-boxed)
;; maximum double power for precise calculations
(def ^:private ^:const ^long kp-max 22)
View testing_dataset.clj
;; MOVED! https://github.com/genmeblog/techtest/blob/master/src/techtest/core.clj
(ns testing.dataset
(:require [tech.ml.dataset :as ds]
[tech.ml.dataset.column :as col]
[tech.v2.datatype.functional :as dfn]))
;; Working thrugh R `data.table` type and confronting with tech.ml.dataset
;; https://cran.r-project.org/web/packages/data.table/vignettes/datatable-intro.html
View tablesaw_test.clj
(ns tablesaw-test
(:import [tech.tablesaw.io.csv CsvReadOptions CsvReader]))
(def ^CsvReader csv-reader (CsvReader.))
(defn load-csv-data
([file] (load-csv-data file nil))
([^String file {:keys [separator line-ending header?]
:or {separator \, line-ending "\n" header? true}}]
(let [builder (doto (CsvReadOptions/builder file)
@genmeblog
genmeblog / temperature.clj
Created Nov 19, 2019
Black body temperature to color converter
View temperature.clj
;; Better interpolation functions for calculating temperature colors
;; Reference: http://www.zombieprototypes.com/?p=210
;; Data: http://www.vendian.org/mncharity/dir3/blackbody/UnstableURLs/bbr_color.html
;; use fastmath and clojure2d libraries
(ns black-body.temperature
(:require [fastmath.core :as m]
[fastmath.interpolation :as i]
@genmeblog
genmeblog / gff.pde
Last active Oct 15, 2019
Gaussian Free Field
View gff.pde
int gffSize = 30; // field density
int rays = 150;
float rsteps = TWO_PI / rays;
float[][] gff;
void setup() {
size(800,800);
smooth(8);
noStroke();
fill(235);
@genmeblog
genmeblog / popcorn_vf.pde
Last active Sep 3, 2018
Popcorn over vector fields
View popcorn_vf.pde
ArrayList<PVector> points = new ArrayList<PVector>();
float step = random(0.01, 0.05); // random step
Folds vector_field = new Folds(); // random vector field
float noise_scale = random(-2,2); // noise scaler
void setup() {
size(600, 600);
noStroke();
smooth(8);