Skip to content

Instantly share code, notes, and snippets.

View daurnimator's full-sized avatar

daurnimator

View GitHub Profile
@daurnimator
daurnimator / llvm.diff
Last active March 21, 2019 04:14
llvm 8 PKGBUILD 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 February 3, 2019 11:36
lua function for showing binary representation of a string
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)
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 November 24, 2018 11:00
Zig struct => JSON serializer
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 November 18, 2018 05:27
Attempt at using zig's export to C feature
#ifndef THING_H
#define THING_H
#include <stdint.h>
#ifdef __cplusplus
#define THING_EXTERN_C extern "C"
#else
#define THING_EXTERN_C
#endif
@daurnimator
daurnimator / cursed_mandelbrot.c
Last active November 14, 2018 04:09 — forked from DavidBuchanan314/cursed_mandelbrot.c
Compile-time mandelbrot in pure C and Zig. Outputs a PGM image file to stdout.
#include <stdio.h>
#define SQ(x) (x)*(x)
#define M0(x,y) SQ(x)+SQ(y)<4?0:0xe0
#define M1(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M0(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0)):0xc0
#define M2(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M1(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0),x0,y0):0xa0
#define M3(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M2(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0),x0,y0):0x80
#define M4(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M3(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0),x0,y0):0x60
#define M5(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M4(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0),x0,y0):0x40
@daurnimator
daurnimator / doh_client.lua
Last active August 28, 2018 02:12
DNS over HTTP with lua-http
#!/usr/bin/env lua
local basexx = require "basexx"
local cq_auxlib = require "cqueues.auxlib"
local cq_packet = require "cqueues.dns.packet"
local http_request = require "http.request"
local function doh_request(uri, method, name, type, class)
local req = http_request.new_from_uri(uri)
req.headers:upsert("accept", "application/dns-message")
@daurnimator
daurnimator / README.md
Created August 21, 2018 06:45
Desired blog engine features

This is a wishlist for an as-yet unwritten blog engine

Features

  • Has posts available via RSS
  • Supports ActivityPub
    • Mastodon users can subscribe to the blog
  • Composition has markdown authoring mode
  • Storage uses postgres and/or static files
  • Server-side rendering (client side rendering in addition is okay)
@daurnimator
daurnimator / PKGBUILD
Created August 11, 2018 02:43
New luarocks PKGBUILD
# $Id$
# Contributor: Daurnimator <quae@daurnimator.com>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Chris Brannon <cmbrannon79@gmail.com>
# Contributor: Geoffroy Carrier <geoffroy@archlinux.org>
pkgname=luarocks
pkgver=3.0.0_notreally
pkgrel=1
pkgdesc='Deployment and management system for Lua modules'
@daurnimator
daurnimator / test.py
Created March 18, 2018 01:56 — forked from RyanSquared/test.py
Program to migrate LDAP data to hashbang/userdb
#!/usr/bin/env python
# pylint: disable-all
# Search LDAP for all People of hashbang.sh
import json
import sys
import ldap
import ldap.resiter
import psycopg2