Skip to content

Instantly share code, notes, and snippets.

View pnlybubbles's full-sized avatar
🍋
is delicious!

pnly pnlybubbles

🍋
is delicious!
View GitHub Profile
@pnlybubbles
pnlybubbles / proxy.ts
Last active February 2, 2024 19:17
Reverse Proxy (`pnpm dlx tsx proxy.ts`)
import type { IncomingMessage } from 'http'
import http from 'http'
import httpProxy from 'http-proxy'
import chalk from 'chalk'
type Target = { host: string; port: number }
type PathMapping = { '*': Target } & { [key: `/${string}`]: Target }
const MAPPING = {
// http://localhost:8080/api/hello -> http://localhost:8787/api/hello
#!/bin/bash
for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do
(
syspath="${sysdevpath%/dev}"
devname="$(udevadm info -q name -p $syspath)"
[[ "$devname" == "bus/"* ]] && exit
eval "$(udevadm info -q property --export -p $syspath)"
[[ -z "$ID_SERIAL" ]] && exit
echo "/dev/$devname - $ID_SERIAL"
{
"title": "For HHKB US",
"rules": [
{
"description": "左コマンドキーを単体で押したときに、英数キーを送信する",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_command",
#Space::
Send, {vkF3sc029}
return
^j::
Send, {Esc}
return
@pnlybubbles
pnlybubbles / quine-2020.rb
Created January 4, 2020 09:14
あけおめです。2020年(令和2年)の書き初めQuineだよ。
eval$s=%w'
b="BAhsKwIFAQAAAAAAAA
AAAAAAAADwPwAAAAAAAAAAAAD//x8AAAAA
AAAAAPD///8/AAAAAAAAAP7/////fwAAAAAAwP////////
8AAAAA/A8A8P//////AQCA/wEAAMD/////BwDwHwAAAADA////AwD/AwAA
AAAA4P9/AO D/AQAAAAAAAP4PAPz/HwAAAAAAgP8BwP///x8AAAAA8D8
A+P////8/A AAA/gMA////////BwDAfwDw//////8fAAD8Dw
D+/////z8 AAOD/AMD/////BwAAgP8fAPz///9
/AAAA//8Dg AcA//8HAID//z8A8AA
@pnlybubbles
pnlybubbles / quine-inoshishi.rb
Created January 2, 2019 05:32
あけおめだよ。書き初めだよ。亥Quineだよ。
eval$s=%w'b="BAhsKwHg////////////////////////////////////////////////////////////////
////////////////////////////A///////////DwCA/////////x8AAACA////////AAAAAMD//////wcAA
AAAwP////8/AIAHfACA/////wE4/PwHAMD///8fwOf/fwAA8P///wD8/////wD+//8P4P////8PgP//fwD///
///wDA//8D8P//////A+D/DwD///////8D+B8A+P//////fwD/AMAH/v////8B8A8Af8D/////HwD+Af4P+P/
///8fgD/A/wH//////w/gD/h/4P//////AfwB/////////weAP8D/////////APgPAPj//////z/A/wEAAP//
////Afz/AADAHwDgDwCA//8HAPABAPgAAPD///8APgAAHwCA////f4ADAMAB+P////8fAMAPAMD//////wMA+
AEA/P//////AIB/AMD////////////////////////// ///////////////////////////////////
//////////////////////////8DAA==" ;n=Marshal.load(b.unpack("m")[0])
;e="eval$s=%w"<<39<<($s*5);o= "";j=-1;0.upto(42*85-1
){|i|o<<((n[i]==1)?e[j+=1]: 32);o<<((i%85==84)?1
@pnlybubbles
pnlybubbles / quine-inu.rb
Created January 1, 2018 02:08
あけましておめでとうございます。書き初めです。戌Quineです。
eval$s=%w'b="BAhsKwIAAf////////////////////////////////////////////////////////////////8B/P
///////////w8A+D8A8P///////wMA/wAA+P//////PwDgPwDA////////BwD/HwD+//////9/APj/APj///////8Hg
P8B/////////38AvAP//////////wdAAPj/////////fwAAAP7/////////AAAA8P///////x8AAACA///////wAQAA
APz//////wMAAACA////////HwAAwAP8////////AAD4HwDg//////8H8P//AADg/////z+A/z8AAAD8/////wH8HwA
AAsD/////B+APAA8AAP////8/AAcA /gAA/P////8BAAD+DwDg/////w8AAPz/AMD/////fwAA+P8PAP///
///AQDw/x8A/P////8PwOH/PwDg// z//38A//9/A AD+w////wH4/38AAMA//P/
/D8D/HwDAAfzB//8/AP7/AOAfgA/8//8 A+P///f8 BcMD//wfA/////z8AA
vz/fwD+/////wMA4P//A/D/////PwAA/v 8/gP///// /AwDw//8D/v////9/A
ID//3/4//////8PAPz///////////8A4P// /////////z/A/ //////////////////
///////////9/";n=Marshal.load(b.unpa ck("m")[0]);e ="eval$s=%w"<<39<<(
@pnlybubbles
pnlybubbles / automaton.hs
Created September 17, 2017 08:18
haskellのStateモナドでAutomaton
import Control.Monad.Trans.State
data Auto = Auto {
getNode :: Int,
getValue :: [Int]
} deriving Show
type AutoOp = State Auto ()
f :: Char -> AutoOp
@pnlybubbles
pnlybubbles / promisify.js
Created January 21, 2017 09:09
もっとつよいのあった→ https://www.npmjs.com/package/pify
module.exports = function promisify(f) {
return (...args) => {
return new Promise((resolve, reject) => {
f(...[...args, (err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
}]);
@pnlybubbles
pnlybubbles / 2017-tori-quine.rb
Created December 31, 2016 15:32
あけましておめでとうございます。書き初めです。酉Quineです。
eval$s=%w'b="BAhsKwKlAf///////////////////9/a+fbZm9x9CWIXvsX/HwAAAAAAAAAAAAAAAAD/AAAAAAAAAAAAAAAAAMAHAAAAAAAAAAAAAAA
AAHwAAAAA AA A AA Pz/ /x8Aw Ac AAPD/ // //// // / wEA fAC A//// / / / // /// D wDABw D4 / //////////
/AAB8 AID/
//// /3
8AA AA
AAM AHAAAAAIAf8AcAAAAAAHwAAAAAA Pw
Bfw AAAAAAwAcAAAAAwB/wAwAAAAAAfAAAAAAA/IE/AAAAAADABwAAAADAH/gHAAAAAAB8AAA AA
AD8 gX8A+P8PAMAHAAAAAOD///////8DAHwAAP7//////////z8AwAcA4P///////////wcAfAAA/v/// //
/Aw CAfwDABwDwD2HwH/gHAAD4AwB8AAB/AAD/gH8AAIA/AMAHAPAHAPAP+AcAAPgDAHwAAP8