Skip to content

Instantly share code, notes, and snippets.

View rebcabin's full-sized avatar

Brian Beckman rebcabin

View GitHub Profile
@jrbrodie77
jrbrodie77 / latex_export_condensed.org
Last active January 20, 2022 18:19
High Density OrgMode LaTeX Export Class

Exporting orgmode files in high density cheatsheet format.

@olieidel
olieidel / delete_recursive.clj
Last active June 4, 2023 16:12
Delete Directories recursively with Clojure in only 4 lines of code.
(ns yourproject.yourns
(:require [clojure.java.io :as io]))
(defn delete-directory-recursive
"Recursively delete a directory."
[^java.io.File file]
;; when `file` is a directory, list its entries and call this
;; function with each entry. can't `recur` here as it's not a tail
;; position, sadly. could cause a stack overflow for many entries?
;; thanks to @nikolavojicic for the idea to use `run!` instead of
@divs1210
divs1210 / SLIP.py
Last active May 24, 2023 23:14
helps escape the Python's clutch
import types
# Helpers
# =======
def _obj():
'''Dummy object'''
return lambda: None
_FILLER = _obj()
@shanest
shanest / cartpole_pg.py
Last active February 17, 2020 03:26
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):
@ghoseb
ghoseb / clj_spec_playground.clj
Last active March 30, 2019 22:35
Examples of Clojure's new clojure.spec library
(ns clj-spec-playground
(:require [clojure.string :as str]
[clojure.spec :as s]
[clojure.test.check.generators :as gen]))
;;; examples of clojure.spec being used like a gradual/dependently typed system.
(defn make-user
"Create a map of inputs after splitting name."
([name email]
@john2x
john2x / 00_destructuring.md
Last active April 23, 2024 13:18
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

@chaitanyagupta
chaitanyagupta / _reader-macros.md
Last active April 29, 2024 09:09
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

@jteneycke
jteneycke / gist:7947353
Last active February 7, 2024 14:50
How to install and configure Common Lisp for Emacs. (SBCL + Slime + Emacs24)

In your shell

sudo apt-get install sbcl
curl -O http://beta.quicklisp.org/quicklisp.lisp
sbcl --load quicklisp.lisp

Inside the context of sbcl

@whanhee
whanhee / container_traits.h
Last active April 15, 2022 15:41
Type class: mappable, variadic. For explanation, see: http://functionalcpp.wordpress.com/2013/09/08/variadic-mapping/
/*
* Copyright (c) 2013, Daniel Park
* All rights reserved.
*
* Permission to modify and redistribute this software is granted to
* anyone provided the above copyright notice, this condition and the
* following disclaimer are retained.
*
* This software is provided "as is", without and express or implied
* warranty. In no event shall the author be liable for damages arising
@splinterofchaos
splinterofchaos / list.cpp
Created December 15, 2012 01:03
Several of Haskell's Data.List functions implemented in C++ Data.List: http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html
#include <algorithm>
#include <vector>
#include <iterator>
#include <iostream>
template< class F, class X, class S >
constexpr X foldl( F&& f, X x, const S& s ) {
return std::accumulate (
std::begin(s), std::end(s),