Skip to content

Instantly share code, notes, and snippets.

@leesei
leesei / convert.js
Created April 29, 2024 01:53
Convert Kibana exported dashboard NDJSON to JSON for readability
#!/usr/bin/env bun
const readline = require("node:readline");
const fs = require("node:fs");
const rl = readline.createInterface({
input: fs.createReadStream("export.ndjson"),
});
rl.on("line", (line) => {
@leesei
leesei / reimg.d.ts
Last active November 30, 2022 03:23
`d.ts` for reimg, MIT license
// Type definitions for reimg 1.0
// Project: https://github.com/gillyb/reimg
// Definitions by: leesei <https://github.com/leesei>
declare module "reimg" {
type OutputProcessor = {
toBase64: () => string;
toImg: () => HTMLImageElement;
toCanvas: (callback: (canvas: HTMLCanvasElement) => void) => string;
toPng: () => HTMLImageElement;
@leesei
leesei / machine.js
Last active May 17, 2022 06:34
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
version: "3.3"
services:
caddy:
deploy:
# this cannot control the number of replicas
replicas: 0
mongo:
ports:
@leesei
leesei / machine.js
Last active March 5, 2021 16:19
Generated by XState Viz: https://xstate.js.org/viz
// https://xstate.js.org/viz/
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
@leesei
leesei / git-su
Last active March 29, 2020 11:43 — forked from pasela/git-su
git-su - switches user and sshCommand in the current repository
#!/bin/bash
#
# git-su - Git Switch User
# ========================
#
# git-su switches user and sshCommand in the current repository.
#
# USAGE
# -----
#
@leesei
leesei / pdf_template.html
Last active September 25, 2019 18:28
weasyprint.test
<html>
<head>
<title>Test</title>
<link rel="stylesheet" href="./styles.css" />
</head>
<body>
<main class="container">
{% for ticket in tickets %}
<section class="ticket">
<div class="content">{{ ticket }}</div>
@leesei
leesei / tag_errors.js
Last active August 6, 2018 07:42
hexo/test/scripts/hexo/tag_errors.js
'use strict';
var sinon = require('sinon');
describe.only('Tag Errors', () => {
var Hexo = require('../../../lib/hexo');
var hexo = new Hexo(__dirname);
before(() => {
hexo.init().then(() => {
@leesei
leesei / ttc2ttf.py
Created November 7, 2017 03:57 — forked from kayahr/ttc2ttf.py
Python script to convert a true type font collection into separate ttf files. Copy from http://pastebin.com/QXcAtP24
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#First released as C++ program by Hiroyuki Tsutsumi as part of the free software suite “Beer”
#I thought porting it to Python could be both a challenge and useful
from sys import argv, exit, getsizeof
from struct import pack_into, unpack_from
def ceil4(n):
@leesei
leesei / npmpub
Created March 9, 2016 15:50
update version in `package.json`, tag repo, publish to npm and push to remote #node #npm
#!/bin/bash
# update version in `package.json`, tag repo, publish to npm and push to remote
# expects version as input
if [ -z "$1" ]; then
echo "Missing version, use those accepted by 'npm version'"
echo
npm version -h
exit
fi