Skip to content

Instantly share code, notes, and snippets.

View niamtokik's full-sized avatar

Niamtokik niamtokik

View GitHub Profile
% Simple erlang parser.
-module(parser).
-compile([export_all]).
% Start char, with start State
-define(DATA_START(X, K),
data(<<X, Rest/bitstring>>, Buf, Ret) ->
data(Rest, Buf, Ret, K)).
@niamtokik
niamtokik / xtemplate.go
Created February 7, 2017 14:57
xbps-src templating in go
package main
import "fmt"
import "os"
import "flag"
import "strconv"
import "strings"
import "text/template"
import "crypto/sha256"
import "encoding/hex"
@niamtokik
niamtokik / Makefile
Created February 8, 2017 18:06
xbps template generator for erlang via erlang.mk database. This is a poc and currently doesn't work as expected.
# Copyright (c) 2013-2016, Loïc Hoguin <essen@ninenines.eu>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// feistel network test
// currently doesn't work as expected.
// the idea is to use variable return
// function to make branchment instead
// of traditional datastructure.
package main
import "fmt"
@niamtokik
niamtokik / pyramid.go
Created February 17, 2017 13:18
way to define triangle and pyramid in go (work on pointers)
package main
import "fmt"
// import "crypto/sha1"
// import "path/filepath"
// import "os"
type triangle struct {
connect [3]*triangle
}
@niamtokik
niamtokik / connection.go
Created February 17, 2017 14:39
simple concurrent wrapper with channels support around go net module
package main
import "fmt"
import "sync"
import "net"
import "bufio"
type Controller struct {
fifo chan string
status chan string
%
% extract namespace information from linux procfs.
%
-module(namespace).
-compile(export_all).
-include_lib("eunit/include/eunit.hrl").
-record(pid, { id :: integer(),
cgroup = 0 :: integer(),
@niamtokik
niamtokik / dualblink_arduino.c
Created July 9, 2017 14:26
simple beat parser for arduino (based on string) for dual blinking led.
@niamtokik
niamtokik / ports.mtree
Created October 29, 2017 14:36
OpenBSD mtree structure
######################################################################
# mtree ports structure
# cd /usr/ports
# mtree ports.mtree
######################################################################
/set type=dir uname=root gname=wheel mode=0755
.
distfiles uname=_pfetch gname=_pfetch
..
#include <stdio.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/param.h>
#include <stdlib.h>
#include <string.h>
struct tuple {
struct iovec key;
struct iovec value;