Skip to content

Instantly share code, notes, and snippets.

View hoelzro's full-sized avatar

Rob Hoelz hoelzro

View GitHub Profile
function parsePrometheusLabels(s) {
s = s.substring(1, s.length - 1); // strip {...}
let re = new RegExp(/(\w+)=\"(.*?)\"[,]?\s*/, 'y');
let labels = {};
let labelSpans = {};
while(true) {
let m = re.exec(s);
if(!m) {
break;
}
/*
title: $:/custom/ui/wikiparser/rules/emoji.js
type: application/javascript
module-type: wikirule
*/
(function() {
exports.name = 'emoji';
exports.types = {inline: true};
def ddb_unpack(item):
item |
with_entries({
key: .key,
value: (.value | to_entries[0] | if .key == "NULL" then
null
elif .key == "L" then
.value | map(ddb_unpack({key:.}).key) # XXX this sucks
elif .key == "M" then
ddb_unpack(.value)
package main
import (
"fmt"
)
func main() {
sliceOne := make([]byte, 10)
sliceTwo := sliceOne[0:5]
package main
import (
"bytes"
"crypto/aes"
"fmt"
"runtime"
"sync"
"time"
)
#!/usr/bin/env perl
use strict;
use warnings;
use feature qw(say);
use experimental qw(signatures);
my $THRESHOLD = 8;
sub distance($a, $b) {
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xmu/Atoms.h>
#define die(fmt, args...)\
fprintf(stderr, fmt "\n", ##args);\
exit(1)
@hoelzro
hoelzro / Makefile
Last active July 16, 2019 13:35
A stupid sampling profiler thing for Lua
CFLAGS += -fPIC
all: heatmap.so
%.so: %.o
gcc -shared -o $@ $^
clean:
rm -f *.o *.so
@hoelzro
hoelzro / remote.lua
Created May 22, 2019 01:55
Tweaked awful.remote that runs REPL expressions in a sandbox, preloads the awful module, and provides print that outputs via naughty notifications
---------------------------------------------------------------------------
--- Remote control module allowing usage of awesome-client.
--
-- @author Julien Danjou &lt;julien@danjou.info&gt;, with tweaks from Rob Hoelz
-- @copyright 2009 Julien Danjou
-- @module awful.remote
---------------------------------------------------------------------------
-- Grab environment we need
require("awful.dbus")