Skip to content

Instantly share code, notes, and snippets.

View kp54's full-sized avatar
💭
<script>alert('!')</script>

kp54

💭
<script>alert('!')</script>
View GitHub Profile
@kp54
kp54 / pipe.ts
Created September 10, 2023 13:46
typed pipe
export type Pipe<T, U> = {
then: <V>(func: (value: U) => V) => Pipe<T, V>;
apply: (value: T) => U;
};
const _pipe = <T, U, V>(prev: Pipe<T, U>, func: (x: U) => V): Pipe<T, V> => {
const self: Pipe<T, V> = {
then: <W>(func: (x: V) => W) => _pipe(self, func),
apply: (value: T) => func(prev.apply(value)),
};
@kp54
kp54 / notify-updates.py
Last active August 26, 2023 19:05
detect and notify updates on arch-based systems (requires `checkupdates` from pacman-contrib)
#!/usr/bin/python
import json
import platform
import subprocess
import urllib.request
WEBHOOK = '<discord_webhook_url_here>'
hostname = platform.node()
@kp54
kp54 / index.html
Last active October 28, 2022 23:44
copy-pasta
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<title>copy-pasta</title>
<script>
document.addEventListener('DOMContentLoaded', function onDOMContentLoaded() {
const title = document.querySelector('title');
const heading = document.querySelector('h1');
const container = document.querySelector('main');
@kp54
kp54 / systemd-nspawnで快適な開発体験を得る話.md
Created December 15, 2020 16:08
NITKC ProLab Advent Calendar 2020
@kp54
kp54 / main.ts
Last active June 10, 2023 14:14
micro:bit Code-Breaker
enum StateNames {
Init,
Enter,
PreJudge,
Judge,
Result,
End,
Edit,
Err,
};
@kp54
kp54 / im2pdf.py
Last active October 22, 2019 10:28
画像をPDFにするやつ (uses img2pdf)
import argparse
import glob
import os.path
import img2pdf
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('-o', '--out', help='output filename', default='a.pdf')
@kp54
kp54 / ORPN.py
Last active March 13, 2022 22:23
RPNをワンライナーで書いてみたやつ
(lambda s:[s.append(eval('{2}{1}{0}'.format(s.pop(),i,s.pop()))if(i in'+-*/')else i)for i in __import__('sys').argv[1:]]and print(s[0]))([])