Skip to content

Instantly share code, notes, and snippets.

View azenla's full-sized avatar
🏳️‍⚧️
cabbit mode

Alex Zenla azenla

🏳️‍⚧️
cabbit mode
View GitHub Profile
with recursive rel_tree as (
select "hash", "parent", 1 as level, cast(array["hash"] AS varchar(512)[]) as path_info
from "git.commits"
where "parent" is null
union all
select c.hash, c.parent, p.level + 1, cast((p.path_info || c.hash) AS varchar(512)[])
from "git.commits" c
join rel_tree p on c.parent = p.hash
)
with raw_commit_texts as (
select "hash", encode("content", 'escape') as info from "git.objects" where type = 1
),
commits as (
select
"hash",
(regexp_match("info", 'tree ([^\s]+)'))[1] as tree,
(regexp_match("info", 'parent ([^\s]+)'))[1] as parent,
(regexp_match("info", 'author ([^\n]+)'))[1] as author,
(regexp_match("info", 'committer ([^\n]+)'))[1] as committer,
@azenla
azenla / spec.cpp
Last active June 8, 2017 14:18
Specification Meta-Programming
#define STYPE(type, vt, defcase) template <vt input> struct type { enum { value = (defcase) }; };
#define ITYPE(type, defcase) STYPE(type, int, defcase)
#define SPEC(type, id, result) template <> struct type<id> { enum { value = (result) }; };
#define SVALUE(type, input) type<input>::value
ITYPE(Fib, Fib<input - 1>::value + Fib<input - 2>::value)
SPEC(Fib, 0, 0)
SPEC(Fib, 1, 1)
int main() {
#!/usr/bin/env bash
set -e
DISCORDS="$(xdotool search "Discord" | tail -n 1)"
CONTENT="$(cat - | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | sed '0~20 a\``````\')"
if [ "${CONTENT: -6}" == '``````' ]
then
CONTENT="${CONTENT::-3}"
fi
import "dart:async";
import "dart:convert";
import "dart:io";
class WhatPulse {
final String host;
final int port;
HttpClient _client;
@azenla
azenla / # neovim - 2016-08-15_23-11-09.txt
Created August 16, 2016 03:13
neovim (neovim/neovim/neovim) on Mac OS X 10.11.6 - Homebrew build logs
Homebrew build logs for neovim/neovim/neovim on Mac OS X 10.11.6
Build date: 2016-08-15 23:11:09
@azenla
azenla / dsa.service
Created July 27, 2016 20:10
Place at /etc/systemd/system/dsa.service
# systemd service for DSA
[Unit]
Description=DSA
After=network.target
[Service]
ExecStart=/bin/sh /opt/dsa/dglux-server/bin/daemon.sh start
ExecStop=/bin/sh /opt/dsa/dglux-server/bin/daemon.sh stop
WorkingDirectory=/opt/dsa/dglux-server
@azenla
azenla / dsa.service
Created July 27, 2016 20:10
Place at /etc/systemd/system/dsa.service, and run
# systemd service for DSA
[Unit]
Description=DSA
After=network.target
[Service]
ExecStart=/bin/sh /opt/dsa/dglux-server/bin/daemon.sh start
ExecStop=/bin/sh /opt/dsa/dglux-server/bin/daemon.sh stop
WorkingDirectory=/opt/dsa/dglux-server
EAPI=5
DESCRIPTION="Dart SDK"
HOMEPAGE="https://www.dartlang.org/"
SRC_URI=""
inherit git-r3 eutils autotools
LICENSE="BSD"
SLOT="0"
void on_invoke_updates(struct DSLink *link, ref_t *req_ref, json_t *resp) {
(void) link;
(void) req_ref;
char *data = json_dumps(resp, JSON_INDENT(2));
printf("Got invoke %s\n", data);
dslink_free(data);
}
dslink_requester_invoke(link, "/sys/clearConns", json_object(), on_invoke_updates);