Skip to content

Instantly share code, notes, and snippets.

View rebcabin's full-sized avatar

Brian Beckman rebcabin

View GitHub Profile
@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 / 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.

@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 / GPLv3.md
Created September 10, 2018 01:19 — forked from kn9ts/GPLv3.md
GPLv3 explained

GPL3 LICENSE SYNOPSIS

TL;DR* Here's what the license entails:

1. Anyone can copy, modify and distribute this software.
2. You have to include the license and copyright notice with each and every distribution.
3. You can use this software privately.
4. You can use this software for commercial purposes.
5. If you dare build your business solely from this code, you risk open-sourcing the whole code base.
@rebcabin
rebcabin / cartpole_pg.py
Created January 29, 2018 05:24 — forked from shanest/cartpole_pg.py
Policy gradients for reinforcement learning in TensorFlow (OpenAI gym CartPole environment)
#!/usr/bin/env python
import gym
import numpy as np
import tensorflow as tf
class PolicyGradientAgent(object):
def __init__(self, hparams, sess):
@rebcabin
rebcabin / Dumper.py
Created November 25, 2017 15:21 — forked from passos/Dumper.py
A perl Data.Dumper clone for Python
"""
A perl Data.Dumper clone for Python
Author: [email protected]
2011-07-08
"""
#!/bin/env python
import sys
from types import *
@rebcabin
rebcabin / screenshotty.py
Created October 27, 2017 18:35 — forked from Jerdak/screenshotty.py
OpenGL screenshots using python
#! /usr/bin/env python
'''
Simple example demonstrating how to take a screenshot
'''
import time
import sys
import os
import argparse
#OpenGL