Skip to content

Instantly share code, notes, and snippets.

View rebcabin's full-sized avatar

Brian Beckman rebcabin

View GitHub Profile
@rebcabin
rebcabin / core.clj
Created May 26, 2023 16:34
Too big for Clojure reader?
(ns reader-test.core
(:gen-class))
'[(=
(Var 2 a)
(ListConstant
[(StringConstant
"ab"
(Character 1 2 () [])
)
@rebcabin
rebcabin / 00_destructuring.md
Created March 31, 2023 13:59 — forked from john2x/00_destructuring.md
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@rebcabin
rebcabin / playground.pie
Created March 2, 2023 00:01
Notes on Chapter 8 of "The Little Typer"
;; ___ _ _ ___
;; / __| |_ __ _ _ __| |_ ___ _ _ ( _ )
;; | (__| ' \/ _` | '_ \ _/ -_) '_| / _ \
;; \___|_||_\__,_| .__/\__\___|_| \___/
;; |_|
;; This is a challenging chapter because it's not
;; clear at the start where it's going. I figured it
;; out by reading it and writing about it several
@rebcabin
rebcabin / bfs.clj
Created January 17, 2023 14:52 — forked from Sophia-Gold/bfs.clj
breadth-first search is annoying in Clojure
;; https://stackoverflow.com/questions/11409140/stumped-with-functional-breadth-first-tree-traversal-in-clojure
(def tree [1 [2 [4] [5]] [3 [6]]])
(defn bfs
[tree]
(loop [ret []
queue (conj [] tree)]
(if (seq queue)
(let [[node & children] (first queue)]
@rebcabin
rebcabin / meta.scm
Created December 30, 2022 17:18 — forked from charles-l/meta.scm
metacircular evaluator from sicp
;; metacircular evaluator from sicp
(define apply-in-underlying-scheme apply)
(define (list-of-values exps env)
(if (no-operands? exps)
'()
(cons (eval (first-operand exps) env)
(list-of-values (rest-operands exps) env))))
(define (eval-if exp env)
(if (true? (eval (if-predicate exp) env))
@rebcabin
rebcabin / SLIP.py
Created November 3, 2022 00:26 — forked from divs1210/SLIP.py
helps escape the Python's clutch
import types
# Helpers
# =======
def _obj():
'''Dummy object'''
return lambda: None
_FILLER = _obj()
@rebcabin
rebcabin / latex_export_condensed.org
Created January 20, 2022 18:19 — forked from jrbrodie77/latex_export_condensed.org
High Density OrgMode LaTeX Export Class

Exporting orgmode files in high density cheatsheet format.

#+TODO: TODO BACKLOGGED(!) SCHEDULED(!) STARTED(!) SUSPENDED(!) BLOCKED(!) DELEGATED(!) ABANDONED(!) DONE
# FOR DOCUMENTATION OF THESE OPTIONS, see 12.2, Export Settings of the Org Info Manual
#+OPTIONS: ':t # export smart quotes
#+OPTIONS: *:t # export emphasized text
#+OPTIONS: -:t # conversion of special strings
#+OPTIONS: ::t # fixed-width sections
#+OPTIONS: <:t # time/date active/inactive stamps
#+OPTIONS: \n:nil # preserve line breaks
@rebcabin
rebcabin / magic.py
Created February 16, 2021 00:06 — forked from RyanKung/magic.py
just magic
import sys
import ast
origin_import = __import__
AST = {}
def custom_import(name, *args, **kwargs):
module = origin_import(name, *args, **kwargs)
if not hasattr(module, '__file__'):
@rebcabin
rebcabin / kalmanSample.py
Created March 7, 2020 22:28
Kalman parameter estimation in PyTorch
import torch
import toolz
def kalman (b, # # rows, cols, in Z; # rows in z
n, # # rows, cols, in P; # rows in x
Z, # b x b observation covariance
x, # n x 1, current state
P, # n x n, current covariance
A, # b x n, current observation partials