Skip to content

Instantly share code, notes, and snippets.

View dnbaker's full-sized avatar

Daniel Baker dnbaker

View GitHub Profile
@dnbaker
dnbaker / ipow.h
Last active February 1, 2016 00:18 — forked from orlp/ipow.c
#ifndef FALL_THROUGH_IPOW_H
#define FALL_THROUGH_IPOW_H
#include "stdint.h"
static inline int64_t ipow(int32_t base, uint8_t exp) {
static const uint8_t highest_bit_set[] = {
0, 1, 2, 2, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5,
@dnbaker
dnbaker / gist:760d2cd79ae0fc0a67e8
Created March 15, 2016 02:05 — forked from debasishg/gist:8172796
A collection of links for streaming algorithms and data structures
  1. General Background and Overview
@dnbaker
dnbaker / tmux_local_install.sh
Last active July 26, 2016 23:50 — forked from ryin/tmux_local_install.sh
bash script for installing tmux without root access
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=1.8
@dnbaker
dnbaker / inthash.c
Created February 3, 2017 02:39 — forked from lh3/inthash.c
Invertible integer hash functions
/*
For any 1<k<=64, let mask=(1<<k)-1. hash_64() is a bijection on [0,1<<k), which means
hash_64(x, mask)==hash_64(y, mask) if and only if x==y. hash_64i() is the inversion of
hash_64(): hash_64i(hash_64(x, mask), mask) == hash_64(hash_64i(x, mask), mask) == x.
*/
// Thomas Wang's integer hash functions. See <https://gist.github.com/lh3/59882d6b96166dfc3d8d> for a snapshot.
uint64_t hash_64(uint64_t key, uint64_t mask)
{
key = (~key + (key << 21)) & mask; // key = (key << 21) - key - 1;
@dnbaker
dnbaker / hmm.tex
Created February 22, 2017 18:58 — forked from mblondel/hmm.tex
Good-looking HMM and Lattice diagrams using TikZ
% (C) Mathieu Blondel, July 2010
\documentclass[a4paper,10pt]{article}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[ansinew]{inputenc}
\usepackage{lmodern}
\usepackage{amsmath}
@dnbaker
dnbaker / hmm.tex
Created February 22, 2017 18:58 — forked from mblondel/hmm.tex
Good-looking HMM and Lattice diagrams using TikZ
% (C) Mathieu Blondel, July 2010
\documentclass[a4paper,10pt]{article}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[ansinew]{inputenc}
\usepackage{lmodern}
\usepackage{amsmath}
@dnbaker
dnbaker / cult_of_ignorance.md
Created March 14, 2017 21:55 — forked from conspect/cult_of_ignorance.md
A Cult Of Ignorance, Isaac Asimov

It's hard to quarrel with that ancient justification of the free press: "America's right to know." It seems almost cruel to ask, ingeniously, "America's right to know what, please? Science? Mathematics? Economics? Foreign languages?"

None of those things, of course. In fact, one might well suppose that the popular feeling is that Americans are a lot better off without any of that tripe.

There is a cult of ignorance in the United States, and there always has been. The strain of anti-intellectualism has been a constant thread winding its way throughout political and cultural life, nurtured by the false notion that democracy means that "my ignorance is just as good as your knowledge."

Politicians have routinely striven to speak the language of Shakespeare and Milton as ungrammaticaly as possible in order to avoid offending their audiences by appearing to have gone to school. Thus, Adlai Stevenson, who incautiously allowed intelligence and learning and wit to peep out of his speeches, found the American people

@dnbaker
dnbaker / doge.grammar
Created February 6, 2019 20:31 — forked from somewacko/doge.grammar
A CFG definition for doge. wow.
# such grammar. very linguistics. wow.
#
# a context-free grammar of doge.
#
# much reference: the-toast.net/2014/02/06/linguist-explains-grammar-doge-wow
1 ROOT S
# ---- Sentences and doge phrases
#