Skip to content

Instantly share code, notes, and snippets.

@mischief
mischief / .init.lua
Last active September 17, 2022 05:01
site
host = unix.gethostname()
c1, c2, c3 = string.byte(GetRandomBytes(1)), string.byte(GetRandomBytes(1)), string.byte(GetRandomBytes(1))
function OnHttpRequest()
Write([[<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Hello World!</title>
</head>
@mischief
mischief / build.zig
Last active December 11, 2021 19:20
zig linkage failure 0.9.0-dev.1936+77836e08a
const std = @import("std");
pub fn build(b: *std.build.Builder) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard release options allow the person running `zig build` to select
@mischief
mischief / tis.bundle
Last active September 9, 2019 15:43
wip tis-100
# To unbundle, run this file
echo tis/as.y
sed 's/.//' >tis/as.y <<'//GO.SYSIN DD tis/as.y'
-%{
-#include <u.h>
-#include <libc.h>
-#include <bio.h>
-#include <ctype.h>
-
-#include "tis.h"
@mischief
mischief / unbound.conf
Created August 5, 2018 18:37
unbound forwarding to dnsmasq for lan zone
# local DNS fuckery
do-not-query-localhost: no
private-domain: "home.arpa"
local-zone: "0.0.10.in-addr.arpa." nodefault
domain-insecure: "home.arpa"
domain-insecure: "0.0.10.in-addr.arpa"
private-address: 10.0.0.0/8
stub-zone:
@mischief
mischief / baddns.go
Created July 13, 2018 14:00
quick and dirty test dns server with different negative rcodes
package main
import (
"fmt"
"github.com/miekg/dns"
)
func negrcode(w dns.ResponseWriter, r *dns.Msg) {
m := new(dns.Msg)
@mischief
mischief / node_exporter
Created May 28, 2018 22:11
prometheus on openbsd
#!/bin/ksh
daemon="/usr/local/bin/node_exporter"
rc_bg=YES
. /etc/rc.d/rc.subr
rc_reload=NO
rc_cmd $1
@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"