Skip to content

Instantly share code, notes, and snippets.

View niamtokik's full-sized avatar

Niamtokik niamtokik

View GitHub Profile
@niamtokik
niamtokik / Makefile
Created November 26, 2023 13:19
OpenBSD Sync Repository Makefile
######################################################################
# A simple Makefile to synchronize OpenBSD repository locally. Helpful
# for air-gapped computers.
#
# $ make help
# $ make all
#
# see: https://www.openbsd.org/ftp.html#rsync
######################################################################
VERSION ?= 7.4
@niamtokik
niamtokik / setup.sh
Created March 26, 2019 07:35 — forked from adamsteen/setup.sh
OpenBSD Current: MirageOS
#!/bin/sh -e
# required packages
doas pkg_add ocaml opam
# setup opam and mirage
opam init
eval $(opam env)
# pins to fix for OpenBSD Current (mincore fixes and noretpoline)
@niamtokik
niamtokik / socatd.sh
Created July 18, 2018 16:31
FreeBSD socatd service
#!/usr/bin/env sh
######################################################################
# socat daemon wrapper. This script use daemon(8) command and
# transform a standard socat process in daemon. This script stop
# the service by stopping daemon supervisor instead of socat process.
#
# PROVIDE: socatd
# REQUIRE: network
# KEYWORD: socat daemon
#
@niamtokik
niamtokik / editor2.erl
Last active February 14, 2018 19:01
Simple File Representation In Erlang/OTP with gen_statem Behavior
%%%===================================================================
%%% @doc Editor2 State Machine simulate a file with different action
%%% on it (append, delete, read).
%%% @end
%%% @todo add something to abstract state data-structure.
%%% @todo add dynamic callback functions (editor_test currently).
%%% @todo add replace function support.
%%% @todo add map function support.
%%%===================================================================
-module(editor2).
@niamtokik
niamtokik / irc_connection.erl
Created February 8, 2018 06:45
Erlang/OTP IRC Client Test
-module(irc_connection).
-compile(export_all).
-behaviour(gen_statem).
%%====================================================================
%%
%%====================================================================
start() ->
start([]).
start(Args) ->
gen_statem:start(?MODULE, Args, []).
@niamtokik
niamtokik / reauest.erl
Created February 8, 2018 06:34
erlang process wrapper around common data-structure
-module(request).
-behaviour(gen_server).
%% API exports
-export([]).
-compile(export_all).
-record(state, { type, struct, name, options }).
start() ->
@niamtokik
niamtokik / dmu_replay_record.erl
Created January 9, 2018 19:47
Quick and Dirty implementation of ZFS dmu_replay_record from zfs_ioctl.h (PoC)
%%%-------------------------------------------------------------------
%%% @author Mathieu Kerjouan
%%% @copyright (c) 2018, Mathieu Kerjouan
%%% @doc This is a quick and dirty zfs dmu replay record implementation
%%% in Erlang. This is only a PoC and should not be used in
%%% production. This code is an implementation of zstreamdump
%%% from OpenZFS.
%%% @end
%%%-------------------------------------------------------------------
-module(dmu_replay_record2).
@niamtokik
niamtokik / Main.hs
Created December 19, 2017 20:13
Some experiment with System.Posix.Signals in Haskell
module Main where
import System.Posix
import System.Posix.IO
import System.Posix.Signals
test childRead fatherWrite = do
(r, _) <- fdRead childRead 10
putStrLn r
childHandler = do
@niamtokik
niamtokik / intel.conf
Last active March 18, 2021 22:32
OpenBSD Xorg Configuration Files for GPD Pocket with wsfb (/etc/X11/xorg.conf.d/)
Section "Device"
Identifier "Device0"
Driver "intel"
Option "DRI" "3"
EndSection
#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;