Skip to content

Instantly share code, notes, and snippets.

View breandan's full-sized avatar
📖
I may be slow to respond.

breandan breandan

📖
I may be slow to respond.
View GitHub Profile
@staltz
staltz / introrx.md
Last active April 29, 2025 08:33
The introduction to Reactive Programming you've been missing
@CodaFi
CodaFi / Algebra.pl
Last active January 2, 2021 11:14
Algebraic Laws in Prolog
% Introduce reflexive equality
refl(X, X).
% Introduce symmetrical equality
sym(X, Y) :-
refl(X, Y),
refl(Y, X).
% Identity of addition by zero
add_zero(N) :-
@williame
williame / IntrusiveList.java
Created September 19, 2012 18:00
An intrusive list class for Java
public final class IntrusiveList<T> {
/** private constructor used by makeList() */
private IntrusiveList() {
t = null; // is null so we know this must be the head/tail
prev = next = this; // cyclic
}
/** returns a new head/tail pointer */
public static <T> IntrusiveList<T> makeList() {
@gatlin
gatlin / sat.hs
Created February 6, 2012 23:05
SAT Solver in Haskell
-- This is going to be on Hackage soon! https://github.com/gatlin/surely
{-# LANGUAGE BangPatterns #-}
-- |
-- Module : AI.Surely
-- Copyright : 2012 Gatlin Johnson
-- License : LGPL 3.0
-- Maintainer : [email protected]
-- Stability : experimental
@rgov
rgov / debruijn.py
Last active November 14, 2023 07:37
de Bruijn sequence generator
def deBruijn(n, k):
'''
An implementation of the FKM algorithm for generating the de Bruijn
sequence containing all k-ary strings of length n, as described in
"Combinatorial Generation" by Frank Ruskey.
'''
a = [ 0 ] * (n + 1)
def gen(t, p):
@mblondel
mblondel / lda_gibbs.py
Last active October 9, 2023 11:31
Latent Dirichlet Allocation with Gibbs sampler
"""
(C) Mathieu Blondel - 2010
License: BSD 3 clause
Implementation of the collapsed Gibbs sampler for
Latent Dirichlet Allocation, as described in
Finding scientifc topics (Griffiths and Steyvers)
"""
import bisect
class NFA(object):
EPSILON = object()
ANY = object()
def __init__(self, start_state):
self.transitions = {}
self.final_states = set()
self._start_state = start_state