Skip to content

Instantly share code, notes, and snippets.

View daurnimator's full-sized avatar

daurnimator

View GitHub Profile
@daurnimator
daurnimator / ThreadPool.zig
Last active January 3, 2021 18:09 — forked from kprotty/ThreadPool.zig
simple http server compatible with wrk for linux using epoll
const std = @import("std");
const system = switch (std.builtin.os.tag) {
.linux => std.os.linux,
else => std.os.system,
};
const ThreadPool = @This();
max_threads: u16,
counter: u32 = 0,
// zig test bls.zig -I/usr/include -lc -lstdc++ -L/usr/lib -lbls_c256
const std = @import("std");
const assert = std.debug.assert;
const testing = std.testing;
const BLS = struct {
const curves = enum {
bls_c256,
bls_c384,
@daurnimator
daurnimator / luarocks-0.1.template
Created October 20, 2019 13:41
luarocks draft makepkg-template
pkgname=("lua-$_rockname" "lua51-$_rockname" "lua52-$_rockname")
makedepends+=('luarocks' 'lua' 'lua51' 'lua52')
build() {
for lua_ver in 5.1 5.2 5.3; do
mkdir -p "$lua_ver"
(cd "$lua_ver"; luarocks build --pack-binary-rock --lua-version="$lua_ver" --deps-mode=none --no-manifest "$_rockname"-"$pkgver"-*.rockspec)
done
}
@daurnimator
daurnimator / weird.sql
Created June 25, 2019 23:26
PostgreSQL issue where constraint function is not being called as view owner
begin;
-- Load in uuid-ossp extension for uuid_generate_v1mc
create schema "uuid-ossp";
create extension "uuid-ossp" with schema "uuid-ossp";
-- Create roles
create role alice;
create role bob;
@daurnimator
daurnimator / changelog
Last active June 7, 2019 05:28 — forked from fmitha/rules
luarocks (3.1.3-1) unstable; urgency=medium
* New upstream release
-- Daurnimator <[email protected]> Fri, 07 Jun 2019 15:00:00 +1000
luarocks (2.4.2+dfsg-1) unstable; urgency=medium
* New upstream release
* Support lua 5.1, 5.2 and 5.3 via lua-any
@daurnimator
daurnimator / RVlBs.zig
Created May 5, 2019 18:04
Reverse Variable-length Bit-strings for Zig.
/// Reverse Variable-length Bit-strings
///
/// Marshal and unmarshal an integer into a reverse bit-string;
/// that is, written out right-to-left (in cardinality of memory space).
fn ReverseVariableLengthInteger(comptime rbitsint: type) type {
return struct {
/// Maximum space needed to store an rbitsint
pub const maxLen: usize = (rbitsint.bit_count + 6) / 7;
/// Return the buffer size required to hold an rbitsint value bit-string
@daurnimator
daurnimator / shadow.zig
Created April 15, 2019 16:03
zig struct field vs method shadowing
const std = @import("std");
const A = struct {
pub foo: i32,
pub fn foo() void {
}
};
test "shadowing" {
std.debug.warn("{}", @typeName(@typeOf(A.foo))); // fn() void
@daurnimator
daurnimator / http_header.zig
Last active April 12, 2019 10:35
http header object for zig
// HTTP Header data structure/type
// Based on lua-http's http.header module
//
// Design criteria:
// - the same header field is allowed more than once
// - must be able to fetch seperate occurences (important for some headers e.g. Set-Cookie)
// - optionally available as comma seperated list
// - http2 adds flag to headers that they should never be indexed
// - header order should be recoverable
//
@daurnimator
daurnimator / autolua.zig
Last active May 9, 2021 05:12
Lua binding creator in zig
const std = @import("std");
const assert = std.debug.assert;
const lua_ABI = @cImport({
@cInclude("lua.h");
@cInclude("lauxlib.h");
@cInclude("lualib.h");
});
pub const lua = struct {