Skip to content

Instantly share code, notes, and snippets.

daurnimator

Block or report user

Report or block daurnimator

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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 Jul 23, 2019
Example lua library 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 {
@daurnimator
daurnimator / llvm.diff
Last active Mar 21, 2019
llvm 8 PKGBUILD diff
View llvm.diff
diff --git a/trunk/PKGBUILD b/trunk/PKGBUILD
index d6e630c..b2c9672 100644
--- a/trunk/PKGBUILD
+++ b/trunk/PKGBUILD
@@ -2,23 +2,20 @@
# Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
pkgname=('llvm' 'llvm-libs' 'llvm-ocaml')
-pkgver=7.0.1
-pkgrel=2
@daurnimator
daurnimator / tobin.lua
Created Feb 3, 2019
lua function for showing binary representation of a string
View tobin.lua
local function tobin(x)
local t = {}
for i=0,#x-1 do
local c = x:byte(i+1)
for j=0,7 do
t[i*8+j+1] = (c & 0x80) ~= 0 and "1" or "0"
c = c << 1
end
end
return table.concat(t)
View stringToEnum.zig
const std = @import("std");
fn stringToEnum(comptime T: type, str: []const u8) ?T {
inline for (@typeInfo(T).Enum.fields) |enumField| {
if (std.mem.eql(u8, str, enumField.name)) {
return @intToEnum(T, @intCast(@TagType(T), enumField.value));
}
}
return null;
}
You can’t perform that action at this time.