Skip to content

Instantly share code, notes, and snippets.

@pervognsen
pervognsen / shift_dfa.md
Last active January 27, 2024 19:54
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 April 29, 2024 01:39
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 June 8, 2018 10:11
wstest.go
package main
import (
"flag"
"net/http"
"io"
"time"
"golang.org/x/net/websocket"
"log"
)
@hgfischer
hgfischer / benchmark+go+nginx.md
Last active April 11, 2024 22:09
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI