Skip to content

Instantly share code, notes, and snippets.

@mischief
mischief / benchmark.lua
Created January 12, 2018 22:28
lua benchmark library modeled after go testing package
local io = require "io"
local math = require "math"
local M = {}
M.__index = M
function M:reset()
local os = require("os")
local ffi = require("ffi")
-- luajit ffi declarations
ffi.cdef[[
typedef int32_t pid_t;
pid_t fork(void);
int close(int d);
/* fisher-yates shuffle */
void
shuffle(void *base, long nel, long width)
{
unsigned char *b, *swap1, *swap2;
long i, j, k;
b = base;
for(i = nel - 1; i > 0; i--){
j = nrand(i);
swap1 = &b[i*width];
@mischief
mischief / http2socks.go
Created December 22, 2016 23:21
http to socks proxy
package main
import (
"flag"
"log"
"net/http"
"os"
"golang.org/x/net/proxy"
goproxy "gopkg.in/elazarl/goproxy.v1"
@mischief
mischief / 90-token.conf
Created May 25, 2016 22:09
override cloudconfig discovery token
# /etc/systemd/system/etcd2.service.d/90-token.conf
[Service]
Environment="ETCD_DISCOVERY=https://discovery.etcd.io/12345678901234567890123456789012"
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
EAPI=5
inherit games versionator
DESCRIPTION="Cataclysm - Dark Days Ahead"
HOMEPAGE="http://en.cataclysmdda.com/"
@mischief
mischief / grub.cfg
Created April 15, 2016 00:00
nice console resolution in coreos via grub
set gfxmode=1920x1080
set gfxpayload=keep
terminal_output gfxterm
@mischief
mischief / coreos-install.go
Created March 29, 2016 04:53
coreos-install in go
package main
import (
"bytes"
"compress/bzip2"
"flag"
"fmt"
"io"
"net/http"
"os"
@mischief
mischief / coreos-cloudinit.yml
Created March 3, 2016 22:37
locksmith on a single node with a reboot window
coreos:
update:
reboot-strategy: "reboot"
locksmith:
window-start: "14:00"
window-length: "2h"
@mischief
mischief / Makefile
Created February 29, 2016 03:50
coreos templates via makefile
CTX=etcd.yaml.tmpl.ctx
etcd: CONFS=$(addsuffix .json, $(shell cat .hosts))
etcd: $(CTX) $(ROOT)/bin/templater .hosts
make $(CONFS)
install: CONFS=$(addsuffix .json, $(shell cat .hosts))
install: etcd .hosts
scp $(CONFS) $(CONFIG_TARGET)/ignition/