Skip to content

Instantly share code, notes, and snippets.

View kig's full-sized avatar

Ilmari Heikkinen kig

View GitHub Profile
@kig
kig / nvmeof_controller.sh
Last active November 26, 2023 02:54
NMVeOF setup scripts
#!/bin/bash
# Adapted from https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/managing_storage_devices/configuring-nvme-over-fabrics-using-nvme-rdma_managing-storage-devices
# Exports an NVMe device over Fabrics so that it can be used by remote hosts.
#
# Usage: nvmeof_controller.sh DEVICE SERVER_IP SERVER_PORT TRANSPORT SUBSYSTEM_NAME NAMESPACE PORT
# Example: nvmeof_controller.sh /dev/nvme1n1 192.168.0.100 4420 tcp my_nvme 10 1
#
# Now you can import the device on a remote host.
#
@kig
kig / audio_min.js
Last active November 14, 2023 02:02
about:blank file viewer. Copy-paste this into the console, then drop files into the page to view them.
let d=document.body,n='\n',f=d.ondragover=e=>e.preventDefault();d.style.whiteSpace='pre';d.ondrop=e=>[f(e)].map.call(e.dataTransfer.files,f=>{e=new Audio(URL.createObjectURL(f));e.controls=e.loop=1;d.append(f.name+n,e,n+n)})
@kig
kig / fast_read.c
Created November 10, 2022 13:16
File read speed optimization tool
/*
What's the fastest way to read a file?
fast_read is a program that reads a file into memory using multiple parallel threads
with a stochastic hill climb optimizer to find the fastest thread count and block size.
Example run (note the effect of page cache, read is basically memcpy after that point):
$ ./fast_read iotest_6G.dat
Opening file iotest_6G.dat for reading
Reading 6442450944 bytes
@kig
kig / Cargo.toml
Created November 25, 2022 04:04
fast_read_optimizer
[package]
name = "fast_read_optimizer"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
io-uring = "0.5"
iou = "0.3.3"
/* MultiFile - A JavaScript library to load multiple files from
tar archives and json_packed files (see http://gist.github.com/407595)
Example: Loading multiple images from a tarball.
MultiFile.load('images.tar', function(xhr) {
this.files.forEach(function(f) {
var e = document.createElement('div');
document.body.appendChild(e);
var p = document.createElement('p');
@kig
kig / gist:1229476
Created September 20, 2011 15:52
Three.js canvas text
// Usage:
// var txt = alignPlane(createText2D('String', 'red', 'Verdana', 64), THREE.RightAlign, THREE.BottomAlign);
// scene.addChild(txt);
function createTextCanvas(text, color, font, size) {
size = size || 24;
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
var fontStr = (font || 'Arial') + ' ' + (size +'px');
ctx.font = fontStr;
@kig
kig / objdiff.js
Created May 3, 2022 01:10
JS Object diff function
const objDiff = (a, b) => {
if (typeof a === typeof b && typeof a === 'object') {
const diff = {};
let changed = false;
for (let i in a) {
if (!b.hasOwnProperty(i)) {
diff[i] = 'DELETED';
changed = true;
continue;
}
I am attesting that this GitHub handle kig is linked to the Tezos account tz2KhKnTtNyDnYzvHLATmwCcRvsthG1J6NWy for tzprofiles
sig:spsig16TXCkHGXnqEgWSNfsipz5KS7yMGygAtyWH3wd3AD9raSXgsGgTxg27H5EX7YdY6Eht9koHPT6KdagPwtFjKwBVB3uDigT
# Nano config file for minimalistic space-saving layout. Good for e.g. Termux.
# Turns line numbers on, hides help and other things.
# Multifile support on by default.
# Screws with the key bindings to make them more "standard"
#
# Close file is Ctrl-Q
# Open file is Ctrl-O
# Save As is Alt-S
# Cut/Copy/Paste are Ctrl-X/C/V
@kig
kig / chr.glsl
Last active May 31, 2020 12:50
A GLSL web server? Maybe?
#define CHR_NULL 0
#define CHR_SOH 1
#define CHR_STX 2
#define CHR_ETX 3
#define CHR_EOT 4
#define CHR_ENQ 5
#define CHR_ACK 6
#define CHR_BELL 7
#define CHR_BACKSPACE 8
#define CHR_TAB 9