Skip to content

Instantly share code, notes, and snippets.

View Klowner's full-sized avatar
🤡
total bozo

Mark Riedesel Klowner

🤡
total bozo
View GitHub Profile
@Klowner
Klowner / journal
Created February 29, 2024 19:47
Simple command line daily journaling script
#!/usr/bin/env sh
# Journal by Mark Riedesel
set -e
SCRIPT_DIR="$( cd "$(dirname $0)" &> /dev/null && pwd )"
EDITOR=${EDITOR:-nvim}
ENTRY_SUBDIR="entries"
ENTRY_DIR="${SCRIPT_DIR}/${ENTRY_SUBDIR}"
type NewProjectRecord = Omit<Partial<ProjectRecord>, 'id'>;
type DeletableProjectRecord = Pick<ProjectRecord, 'id'>;
export class ProjectsContext {
constructor(private service: ProjectService) {}
private readonly remoteRefresh$ = new BehaviorSubject<void>(null);
private readonly create$ = new Subject<NewProjectRecord>();
private readonly delete$ = new Subject<DeletableProjectRecord>();
export class AuthService {
private readonly createRequest: AjaxCreationMethod = this.config.createRequest;
private readonly refreshToken$ = this.refreshToken();
constructor(private readonly config: AuthServiceConfig) {}
authenticate(username: string, password: string): Observable<AjaxResponse> {
return this.createRequest({
url: '/account/login',
method: 'POST',
// (C) 2018 Mark Riedesel <mark@klowner.com>
// http://sensible.website/posts/serializing-tasks-with-c++-metaprogramming/
// The following code is licensed under the MIT license.
#include <cstdint>
#include <cstring>
#include <iostream>
using CommandId = uint16_t;
@Klowner
Klowner / lockjob.cpp
Last active September 29, 2017 02:53
Lock-free C++ single producer job scheduler thing that probably is secretly broken
#include <mutex>
#include <thread>
#include <vector>
#include <iostream>
#include <atomic>
class Scheduler
{
public:
@Klowner
Klowner / autossh
Created May 23, 2017 17:01
autossh connection with openrc
#!/sbin/openrc-run
name=$RC_SVCNAME
command="/usr/bin/autossh"
pidfile="/run/${RC_SVCNAME}.pid"
AUTOSSH_LOGFILE="${AUTOSSH_LOGFILE:-/var/log/${RC_SVCNAME}.log}"
start_stop_daemon_args="-e AUTOSSH_PIDFILE=\"${pidfile}\" -e AUTOSSH_LOGFILE=\"${AUTOSSH_LOGFILE}\""
command_args="-M 10984 -N -f -o 'PubkeyAuthentication=yes' -o 'PasswordAuthentication=no' \
-i /root/.ssh/id_rsa -R 6666:localhost:22 middleman@middleman"
#include <iostream>
#include <string>
#include <vector>
#define DEF(_name_) _name_,
typedef enum {
#include "types_defs.h"
MAX_TYPES,
} Types;
@Klowner
Klowner / xinput-automatrix.sh
Last active February 27, 2020 23:00
A short script for auto calculating and setting an xinput coordinate transform matrix
#!/bin/sh
#
# Automatically calculate and set xinput coordinate transformation matrix
# for all matching devices listed in DEVICES array
#
# usage:
# ./xinput-automatrix.sh
#
# Mark Riedesel <mark@klowner.com>
#
@Klowner
Klowner / gist:0069ef5468a9b9404322
Created February 8, 2015 14:37
Archlinux nat virtual bridge interface
Description="Virtualbox Routed Bridge"
Interface=vnet0
Connection=bridge
IP=static
BindsToInterfaces=()
Address=172.32.0.1/24
ExecUpPost="iptables -t nat -I POSTROUTING -s 172.32.0.0/24 -j MASQUERADE || true"
ExecDownPre="iptables -t nat -D POSTROUTING -s 172.32.0.0/24 -j MASQUERADE || true"
@Klowner
Klowner / xintoggle.py
Created January 6, 2015 04:10
dmenu interface for toggling xinput devices written in python
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# a simple python script for toggline xinput devices via dmenu
# Written by Mark "Klowner" Riedesel 2015
#
# License: MIT yadda yadda, do what you want
import subprocess
import re