Skip to content

Instantly share code, notes, and snippets.

@pervognsen
pervognsen / shift_dfa.md
Last active May 23, 2025 10:30
Shift-based DFAs

A traditional table-based DFA implementation looks like this:

uint8_t table[NUM_STATES][256]

uint8_t run(const uint8_t *start, const uint8_t *end, uint8_t state) {
    for (const uint8_t *s = start; s != end; s++)
        state = table[state][*s];
    return state;
}
@rueycheng
rueycheng / GNU-Make.md
Last active May 1, 2025 19:20
GNU Make cheatsheet
@ericelliott
ericelliott / cancellable-wait.js
Last active October 8, 2019 08:06
Cancellable wait -- an ES6 promise example
const wait = (
time,
cancel = Promise.reject()
) => new Promise((resolve, reject) => {
const timer = setTimeout(resolve, time);
const noop = () => {};
cancel.then(() => {
clearTimeout(timer);
reject(new Error('Cancelled'));
@barosl
barosl / add.c
Created July 26, 2015 07:26
Function overloading in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int addi(int a, int b) {
return a + b;
}
char *adds(char *a, char *b) {
char *res = malloc(strlen(a) + strlen(b) + 1);
@9nut
9nut / dht9psrv.py
Created July 15, 2015 19:28
9P Server for DHT22 sensor (uses py9p and Adafruit_DHT packages)
#!/usr/bin/env python
import time
import sys
import getopt
import os
import copy
import py9p
import getopt
import getpass
@mraaroncruz
mraaroncruz / repos.md
Created February 24, 2015 12:02
repos to read for Herding Gophers talk Gophercon India 2015

Link to typeform

https://typeform.com

Golang Repo Links

Here are lists of repos from the most prolific Go project creators

Hashicorp

@jimmycuadra
jimmycuadra / cloud-config.yml
Last active April 19, 2021 03:04
CoreOS cloud-config for DigitalOcean with iptables firewall
#cloud-config
coreos:
etcd:
# generate a new token for each unique cluster from https://discovery.etcd.io/new
discovery: https://discovery.etcd.io/<token>
# multi-region deployments, multi-cloud deployments, and droplets without
# private networking need to use $public_ipv4
addr: $private_ipv4:4001
peer-addr: $private_ipv4:7001
@jordanwade90
jordanwade90 / Slide
Created April 28, 2014 22:43
Use acme to switch between “slides” (actually just text files) in a directory. Blatantly stolen from Russ Cox (http://research.swtch.com/acme).
#!/usr/local/plan9/bin/rc
. /usr/local/plan9/lib/acme.rc
winname `{pwd}^/$1
winctl clean
winctl get
@9nut
9nut / wstest.go
Last active February 26, 2025 17:31
wstest.go
package main
import (
"flag"
"net/http"
"io"
"time"
"golang.org/x/net/websocket"
"log"
)
@dmichael
dmichael / httpclient.go
Last active October 18, 2023 20:07
Light wrapper for the Go http client adding (essential) timeouts for both connect and readwrite.
package httpclient
import (
"net"
"net/http"
"time"
)
type Config struct {
ConnectTimeout time.Duration