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
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 / mylib.zig
Last active Apr 21, 2019
Example lua library in zig
View mylib.zig
// test with:
// zig test --library c --library lua -isystem /usr/include/ -L/usr/lib src/mylib.zig
//
// build with:
// zig build-lib -dynamic --library c -isystem /usr/include/ src/mylib.zig
// mv libmylib.so.0.0.0 mylib.so
//
// run example:
// lua -e 'mylib=require"mylib"; mylib.foo()'
@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;
}
@daurnimator
daurnimator / tojson.zig
Last active Nov 24, 2018
Zig struct => JSON serializer
View tojson.zig
const std = @import("std");
const Buffer = std.Buffer;
const mem = std.mem;
const assert = std.debug.assert;
const TypeInfo = @import("builtin").TypeInfo;
const TypeId = @import("builtin").TypeId;
fn toJSONacc(buf: *Buffer, value: var) !void {
switch (@typeInfo(@typeOf(value))) {
TypeId.Bool => {
@daurnimator
daurnimator / thing.h
Last active Nov 18, 2018
Attempt at using zig's export to C feature
View thing.h
#ifndef THING_H
#define THING_H
#include <stdint.h>
#ifdef __cplusplus
#define THING_EXTERN_C extern "C"
#else
#define THING_EXTERN_C
#endif
You can’t perform that action at this time.