Skip to content

Instantly share code, notes, and snippets.

View narslan's full-sized avatar

Nevroz Arslan narslan

  • Turkey
  • 11:36 (UTC +03:00)
View GitHub Profile
@narslan
narslan / band.ex
Created September 30, 2025 10:03
Sample Static Supervisor in Elixir
defmodule Band do
use GenServer
@delay 750
def start_link(role, skill) do
GenServer.start_link(__MODULE__, [role, skill], [])
end
@impl true
@narslan
narslan / CMakeLists.txt
Created December 22, 2024 00:53
integrate asio with cmake
find_package(Threads REQUIRED)
add_library(asio INTERFACE)
target_include_directories(asio SYSTEM INTERFACE asio/include)
target_compile_definitions(asio INTERFACE ASIO_STANDALONE ASIO_NO_DEPRECATED)
target_link_libraries(asio INTERFACE Threads::Threads)
@narslan
narslan / colorstring.cpp
Created December 22, 2024 00:33
print in color
#include <fmt/color.h>
#include <string_view>
template <typename... T>
void printg(std::string_view format, T... args)
{
fmt::print(fmt::emphasis::bold | fg(fmt::color::green), format, args...);
}
template <typename... T>
void printr(std::string_view format, T... args)
@narslan
narslan / pdfsplit.txt
Created December 19, 2024 11:13
extract first and particular pages of an pdf
qpdf dbbook.pdf --pages . 1 . 23-165 -- outfile.pdf
@narslan
narslan / circledb.rkt
Created December 11, 2024 11:34 — forked from Saityi/circledb.rkt
'An Archaeology-inspired database' (but in Racket) (https://www.aosabook.org/en/500L/an-archaeology-inspired-database.html) (Incomplete -- does not include queries)
#lang racket
(require racket/generic
racket/match
racket/pretty
struct-update
threading)
(define flip
(curry (λ (f a b) (f b a))))
@narslan
narslan / posixmq.sml
Created April 9, 2024 00:51
posix send with sml
open MLton.Pointer
open MLton.Platform
val O_RDONLY = 0wx0 and O_WRONLY = 0wx1 and O_RDWR = 0wx2
val O_CREAT = 0wx40 and O_CLOEXEC = 0x80000 and O_EXCL = 0wx80 and O_NONBLOCK = 0wx800
val S_IRUSR = 0wx100 and S_IWUSR = 0wx80
val mq_open = _import "mq_open" : string * int * int * t -> int;
val mq_close = _import "mq_close" : int -> int;
val mq_unlink = _import "mq_unlink" : string -> int;
val mq_send = _import "mq_send" : int * string * int * int -> int;
@narslan
narslan / gist:24fc00c7ed53693a90d85d76d96841f6
Created March 26, 2024 06:49
Practical Number finder
(*This implementation is slow. It can be improved.
The summings function can use memoizing.
*)
fun divisors n = (List.filter (fn x => n mod x = 0) (List.tabulate (n div 2, fn x => x + 1 )))
fun powerset [] = []
| powerset [x] = [[],[x]]
| powerset (x::xs) =
let
val power_subset = powerset xs
@narslan
narslan / building-sync-systems.md
Created February 19, 2024 04:28 — forked from pesterhazy/building-sync-systems.md
Building an offline realtime sync engine

So you want to write a sync system for a web app with offline and realtime support? Good luck. You might find the following resources useful.

Overview articles

@narslan
narslan / podman.md
Last active June 23, 2023 21:06
rootless podman on void linux
#https://devpress.csdn.net/linux/62ea013920df032da732abb7.html
$ mount -t cgroup2 none /sys/fs/cgroup
$ xbps-install podman podman-compose cni cni-plugin-dnsname  cni-plugins
$ sudo vim /etc/containers/registries.conf
[registries.search]
registries = ['docker.io', 'registry.fedoraproject.org', 'quay.io', 'registry.access.redhat.com', 'registry.centos.org']
@narslan
narslan / directory_traverse.sml
Created June 4, 2023 06:34
directory read recursively in standard ml
(*WIP*)
(*Adapted from Unix System Programming with Standard ML*)
structure FS = OS.FileSys
structure OP = OS.Path
fun toErr msg = TextIO.print msg
exception Error of string
val printf = fn z => TextIO.output (TextIO.stdOut, z ^ "\n")
fun open_dir dir = (FS.openDir dir)
handle