Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ts-node
const path = require('path')
const fs = require('fs')
if (!process.argv[2]) {
process.stderr.write(`Usage: ${process.argv[1]} <filename>\n`)
return -1
}
const filePath = path.join(process.cwd(), process.argv[2])
@lierdakil
lierdakil / madoko.py
Last active August 26, 2020 01:23
A simple script to make madoko play with pipes
#!/usr/bin/env python
import tempfile
import sys
import subprocess
import os
import errno
# Make temp. file for input
inp = tempfile.NamedTemporaryFile(suffix='.mdk',mode='wb',dir=os.getcwd())
@lierdakil
lierdakil / apod.ts
Created June 15, 2020 03:38
Downloads NASA Astronomy Picture of the Day and displays it as the background using feh
#!/usr/bin/env -S deno run --allow-net=api.nasa.gov,apod.nasa.gov --allow-env --allow-write=${HOME}/.apodwallpaper --allow-run
// Filename: apod.ts
// Purposes: Downloads NASA Astronomy Picture of the Day and displays it as the background using feh
// Author(s): Nikolay "Lierdakil" Yakimov https://github.com/lierdakil
// !!! Replace this with your NASA API key; go to https://api.nasa.gov/ to get one
const api_key = 'DEMO_KEY'
// Read home variable
@lierdakil
lierdakil / checkers.cpp
Last active May 11, 2020 15:31
A slightly generalized optimized solver for Matt Parker's coin puzzle in C++17 https://www.think-maths.co.uk/coin-puzzle
#include <array>
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
#include <future>
#include <iomanip>
#include <iostream>
#include <stdexcept>
#include <utility>
#include <vector>
enum class St { Empty, Occupied };
@lierdakil
lierdakil / .ccls
Last active February 10, 2020 01:47
Enables Razer BlackWidow 2013 macro keys in Linux
clang
-I/usr/include/libusb-1.0
@lierdakil
lierdakil / .gitignore
Last active January 14, 2020 12:33
Minimal typescript test project
node_modules
@lierdakil
lierdakil / const.c
Last active February 7, 2019 12:29
An example of messy const-correctness in C
struct bar { int foo; };
const struct bar fizz = { 10 };
void baz(struct bar * a) {
a->foo = 30;
}
int main() {
//fizz.foo = 20; // does not compile
@lierdakil
lierdakil / Makefile
Last active December 13, 2018 12:25
Linux key polling and counting KPM
all:
clang++ -std=c++17 keypoll.cpp -o keypoll -lstdc++fs -lpthread
@lierdakil
lierdakil / pollkeys.cpp
Created December 10, 2018 19:25
Linux polling all key event devices for key presses (minimalist example)
// Note: uses C++17 fs features; build with
// g++ -std=c++17 event-reader.cpp -lstdc++fs
//
// Licensed under the following terms:
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
//
// Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
//
// Everyone is permitted to copy and distribute verbatim or modified
@lierdakil
lierdakil / hair.hs
Created December 4, 2018 10:02
Example of TutorialD quasiquoter syntax
{-# LANGUAGE DeriveGeneric, DeriveAnyClass, OverloadedStrings, QuasiQuotes, TemplateHaskell #-}
module Main where
import ProjectM36.Client
import ProjectM36.Relation.Show.Term
import GHC.Generics
import Data.Text
import Data.Binary
import Control.DeepSeq
import qualified Data.Map as M