Skip to content

Instantly share code, notes, and snippets.

View Desdaemon's full-sized avatar

Viet Dinh Desdaemon

View GitHub Profile
@Desdaemon
Desdaemon / Auto-Kalimba.js
Last active June 19, 2024 21:28
Collective Unconscious Auto Kalimba Sync
// ==UserScript==
// @name Collective Unconscious: Auto-Kalimba
// @namespace http://tampermonkey.net/
// @version 2024-06-09
// @description Play back MIDI files using the Kalimba!
// @author knuxify / unk_f000
// @license MIT
// @match https://ynoproject.net/unconscious/
// @icon https://www.google.com/s2/favicons?sz=64&domain=ynoproject.net
// @grant none
@Desdaemon
Desdaemon / lmusize.py
Last active July 5, 2024 05:30
Tool to read map width/height from RM2K LMU maps
#!/usr/bin/env python3
def read_map(path):
with open(path, 'rb') as file:
header = read_slice(file)
if header != b"LcfMapUnit":
return
width = None
height = None
while not (width and height):
@Desdaemon
Desdaemon / join.rs
Created July 11, 2023 19:24
typed-sled table joins
use std::{marker::PhantomData, sync::Arc};
use typed_sled::{Tree, KV};
#[derive(Clone)]
pub struct JoinTree<I, T> {
inner: I,
joins: T,
}
pub struct InnerJoin<T, F, FP>(T, F, PhantomData<fn(FP)>);
@Desdaemon
Desdaemon / gen-stub.py
Last active June 17, 2022 01:39
Create Python Stubs
#!/usr/bin/env python
# pyright: basic
import re
import sys
import os
import ast as a
from typing import Callable, Generic, Iterable, Iterator, TypeVar
from multiprocessing import Pool
from pathlib import Path
@Desdaemon
Desdaemon / api.rs
Created February 18, 2022 00:51
Long-running StreamSink
use anyhow::Result;
use std::{thread::sleep, time::Duration};
use flutter_rust_bridge::StreamSink;
const ONE_SECOND: Duration = Duration::from_secs(1);
// can't omit the return type yet, this is a bug
pub fn tick(sink: StreamSink<i32>) -> Result<()> {
let mut ticks = 0;
@Desdaemon
Desdaemon / init.lua
Last active February 1, 2022 03:11
NVIM config file
-- Full list at https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
local servers = {
'pyright', 'rust_analyzer', 'tsserver', 'dartls', 'clangd',
-- Provided by vscode-langservers-extracted
'html', 'eslint', 'cssls', 'jsonls',
}
local use = require('packer').use
require('packer').startup(function()
use 'wbthomason/packer.nvim' -- Self-management
#!/usr/bin/python3
# Source: https://support.particle.io/hc/en-us/articles/360045547634-How-can-I-set-up-my-Argon-or-Boron-via-USB-
from shutil import which
from urllib.request import urlopen
from sys import exit as bail
from subprocess import run
from os import remove
from re import compile as regex
@Desdaemon
Desdaemon / Ayu Dark.tmTheme
Created January 9, 2022 22:30
Ayu Dark TextMate color scheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Generated by: TmTheme-Editor -->
<!-- ============================================ -->
<!-- app: http://tmtheme-editor.herokuapp.com -->
<!-- code: https://github.com/aziz/tmTheme-Editor -->
<plist version="1.0">
<dict>
<key>name</key>
<string>Ayu Dark</string>
@Desdaemon
Desdaemon / .vimrc
Last active December 13, 2021 01:51
Typescript vimrc
if !has('nvim')
source $VIMRUNTIME/defaults.vim
endif
set number
set hlsearch
set incsearch
let &t_ut='' " fixes display bug on kitty
call plug#begin('~/.vim/plugged')
@Desdaemon
Desdaemon / dark.dart
Last active March 15, 2021 13:52
Yet Another Flutter Todo (Null-safe + Animations + Dark Theme/List State via Riverpod + State Persistence via Hive)
/* lib/state/dark.dart */
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:hive/hive.dart';
final darkTheme = StateNotifierProvider((_) => Dark());
class Dark extends StateNotifier<bool> {
final String boxname;
bool firstrun = true;
Dark({this.boxname = 'todo'}) : super(false);