Skip to content

Instantly share code, notes, and snippets.

View mochki's full-sized avatar
🇯🇵
i could really use some time in Japan rn

キ ki mochki

🇯🇵
i could really use some time in Japan rn
View GitHub Profile
import { createStore } from "Redux";
const LOGGED_OUT = "LOGGED_OUT";
const LOGGING_IN = "LOGGING_IN";
const LOGGED_IN = "LOGGED_IN";
type AuthState = typeof LOGGED_OUT | typeof LOGGING_IN | typeof LOGGED_IN;
interface IUser {
username: string;
token: string;
// Some dynamic input to set where the origin should be
// Globals
let origin = { x: 0, y: 0 };
let layers = [];
// Inits
calibrateOrigin();
window.addEventListener("onresize", calibrateOrigin);
@mochki
mochki / iphone-usb_tethering-to-rpi.md
Last active January 30, 2024 07:41 — forked from antronic/iphone-usb_tethering-to-rpi.md
iPhone RPi Hotspot/Ethernet

iPhone Tethering to Raspberry Pi

  • update n shit
  • sudo apt install usbmuxd ipheth-utils libimobiledevice-utils
  • (on iPhone) plug in & trust. Enable hotspot if not already

internet should be working now. nmcli is what RPi uses

ethernet

  • sudo nmcli c add con-name <connection-name> type ethernet ifname <interface-name> ipv4.method shared ipv6.method ignore
  • sudo nmcli c up
@mochki
mochki / web-util-exp.js
Created April 24, 2023 17:31
simple "extensions", just need these somewhere
window.addEventListener("keydown", e => {
if (e.keyCode == 37) {
$('video').currentTime = $('video').currentTime - 5;
}
if (e.keyCode == 39) {
$('video').currentTime = $('video').currentTime + 5;
}
});
const fs = require('fs-extra');
const cal = require('./cal.js');
(async function() {
const uniq = [];
const newCal = [];
cal.map(event => {
const hash = `${event.match(/SUMMARY:(.*)\n/)[1]}::${event.match(/DTSTART(.*)\n/)[1]}`;
if (!uniq.includes(hash)) {
uniq.push(hash);
@mochki
mochki / vamp.js
Created April 14, 2022 22:03
vamp survr save migration (when steam wont sync and its in "Capaciitor Storage")
copy(
Object.entries({...window.localStorage})
.reduce((acc, [key, val]) => ({...acc, [key.replace('CapacitorStorage.', '')]: JSON.parse(val)}), {})
)
Object.entries(a).forEach(([k, v]) => {window.localStorage.setItem(`CapacitorStorage.${k}`, JSON.stringify(v))})
@mochki
mochki / ffmpeg-stem-management.js
Last active February 1, 2022 12:50
ffmpeg multitrack to stems
/*
it's a pain in the ass to manage and using ffmpeg is kinda easiest. so grab your multitracks and just make a comma/semicolon
separated list.
vox=Ld Vocals.mp3,Vocal FX.mp3,BGV 1.mp3,Adlibs.mp3,BGV 2.mp3,BGV 3.mp3;
drums=Snare.mp3,Percussion.mp3,Claps.mp3,Kick.mp3;
bass=808.mp3,Pads.mp3;
other=Guitar.mp3,Strings.mp3
this generates a string (multiple ffmpeg commands) that makes the 4 stems that you can just run in your terminal.
// For testing new svgs against old svgs
// yarn global add blink-diff
// brew install imagemagick
import { promises as fs } from 'fs';
import { remove as rm } from 'fs-extra';
import { execSync } from 'child_process';
import { remove } from 'lodash';
const iconsDir = 'some_dir';
@mochki
mochki / exhaustiveness-example.ts
Last active November 1, 2018 19:20
Exhaustiveness Checking in TypeScript
// This is from Microsoft's presentation
type Shape =
| {kind: 'circle'; radius: number}
| {kind: 'rectangle'; w: number; h: number}
| {kind: 'sqaure'; size: number}
// This function will throw ts-errors if obj ever comes in as something other than error
function assertNever(obj: never) {
throw new Error('Unexpected object')