Skip to content

Instantly share code, notes, and snippets.

View iso2022jp's full-sized avatar
🌌
Working in the metaverse

USHITO Hiroyuki iso2022jp

🌌
Working in the metaverse
View GitHub Profile
@iso2022jp
iso2022jp / update-factorio
Created January 8, 2024 06:40
Factorio Headless Updater
#!/bin/bash
set -euo pipefail
DRYRUN=''
DOWNLOAD_ONLY=''
usage() {
echo "Usage: $0 [-n|-d]" 1>&2
exit 1
@iso2022jp
iso2022jp / WheelBackflowCanceller.cs
Last active May 6, 2023 06:18
Mouse wheel back-flow canceller for Microsoft Pro IntelliMouse
using System;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
// [main: STAThread]
Thread.CurrentThread.SetApartmentState(ApartmentState.Unknown);
Thread.CurrentThread.SetApartmentState(ApartmentState.STA);
@iso2022jp
iso2022jp / _.js
Created May 2, 2023 10:47
Chunked "Content" Encoding transformer
class ChunkedTransformer {
#trasformLastChunk
#chunks
#header
// BWS: [ \t]*
// token: [-!#-'*+.^`|~\w]+
// quoted-string: "(?:[\t \x21\x23-\x5B\x5d-\x7E\x80-\xFF]|\\[\t \x21-\x7E\x80-\xFF])*"
@iso2022jp
iso2022jp / garble.js
Last active February 18, 2023 08:13
文字化かせ
prompt('', (new TextDecoder('Windows-31J')).decode((new TextEncoder()).encode(prompt())))
@iso2022jp
iso2022jp / fake-xlsx.js
Last active July 30, 2022 14:26
Download as Excel
const download = (blob, filename, type = blob.type || 'application/octet-stream') => {
const a = document.createElement('a')
a.href = window.URL.createObjectURL(blob)
a.download = filename
a.type = type
a.click()
window.URL.revokeObjectURL(a.href)
}
@iso2022jp
iso2022jp / wslm.cmd
Last active November 2, 2023 03:01
Run wls on the host directory with SMB
@echo off
: Prerequisite: share C: with "C", user "foo" accessible
wsl -- ^
set -euxo pipefail; ^
[[ ! -d /mnt/c2 ]] ^|^| mount ^| grep '/mnt/c2' ^|^| sudo find '/mnt/c2' -type d -empty -delete; ^
[[ -d /mnt/c2 ]] ^|^| sudo mkdir /mnt/c2; ^
grep -qs '/mnt/c2 ' /proc/mounts ^|^| sudo mount -t cifs -o user=foo,nobrl,noperm,cache=none,actimeo=0,iocharset=utf8 //$^(grep nameserver /etc/resolv.conf ^| grep '\.' ^| cut -f2 -d' '^)/C /mnt/c2; ^
cd ${PWD/#\/mnt\/c\///mnt/c2/}; ^
@iso2022jp
iso2022jp / solver.js
Last active February 5, 2022 06:32
Wordle Solver
'use strict'
if (!globalThis.prompt) {
const buffer = require('buffer')
const fs = require('fs')
const input = buffer.Buffer.alloc(10000)
globalThis.prompt = (message, defaultValue = '') => {
message && console.info(message)
let offset = 0
while (fs.readSync(0, input, offset, 1)) {
@iso2022jp
iso2022jp / ranks.js
Created July 6, 2021 15:39
Compute ranks
const ranks = (values, comparator = (a, b) => b - a) => values
.map((value, i) => [value, i])
.slice().sort(([a], [b]) => comparator(a, b))
.reduce((ranks, [value, i], rank, ordered) => [
...ranks.slice(0, i),
rank && !comparator(value, ordered[rank - 1][0]) ? ranks[ordered[rank - 1][1]] : rank + 1,
...ranks.slice(i + 1),
], Array.from({length: values.length}))
@iso2022jp
iso2022jp / ble-scan-example.ino
Last active April 2, 2022 03:32
M5Stack Basic/Gray/Core2 BLE Active Scan sample
#ifndef ARDUINO_M5STACK_Core2
#include <M5Stack.h>
#else
#include <M5Core2.h>
#endif
#include <utility/M5Timer.h>
#include <esp_bt.h>
#include <esp_bt_main.h>
@iso2022jp
iso2022jp / wifi-selector.ino
Created May 29, 2021 16:18
M5Stack Core2 で Wi-Fi に接続する GUI(入力辛い系)
#include <M5Core2.h>
#include <WiFi.h>
//--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2
void selectWiFi(String &ssid, uint8_t &encType, int32_t &rssi, uint8_t* &bssid, int32_t &channel) {
auto& d = M5.Lcd;
d.fillScreen(BLACK);