Skip to content

Instantly share code, notes, and snippets.

Avatar

daurnimator

View GitHub Profile
@daurnimator
daurnimator / ThreadPool.zig
Last active Jan 3, 2021 — forked from kprotty/ThreadPool.zig
simple http server compatible with wrk for linux using epoll
View ThreadPool.zig
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,
View bls.zig
// 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 Oct 20, 2019
luarocks draft makepkg-template
View luarocks-0.1.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 Jun 25, 2019
PostgreSQL issue where constraint function is not being called as view owner
View weird.sql
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;
View changelog
luarocks (3.1.3-1) unstable; urgency=medium
* New upstream release
-- Daurnimator <quae@daurnimator.com> 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
Reverse Variable-length Bit-strings for Zig.
View RVlBs.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 Apr 15, 2019
zig struct field vs method shadowing
View shadow.zig
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 Apr 12, 2019
http header object for zig
View http_header.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
Lua binding creator in zig
View autolua.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 {