Skip to content

Instantly share code, notes, and snippets.

@AriPerkkio
AriPerkkio / ipleak.sh
Last active December 6, 2020 09:17
ipleak.net CLI
#!/bin/bash
echo "IP"
curl -s https://ipv4.ipleak.net/json/ | grep -E 'country|city|region|continent|ip'
echo -e "\nDNS"
for i in {1..5}
do
HASH=$(head /dev/urandom | tr -dc a-z0-9 | head -c 39 ; echo '')
echo $(curl -s https://1$HASH.ipleak.net/dnsdetect/) &
@AriPerkkio
AriPerkkio / utils.ts
Last active October 17, 2023 10:01
Type definition utils I keep forgetting
// https://www.typescriptlang.org/play?#code/C4TwDgpgBAggNnA0hEBnA8mYBLA9gOwEM4AeAFSggA9gJ8ATVKAbygG1EAuKVYAJ2z4A5gF1uhfCCgBfAHxQAvCwBQUNe0RRBUANYpcAMyhkRAfm5kOIgNzLpt5aEhQAqvjz4yuGHz6EQJKrqbh5k4NDUtAxMvALCADRBaj5+IGHOkXSMPPyCQmwiiuwiyvJKzEnsAMq5wgAy2LR+cFr4ru4E6RBiUACiVADGcACu9BAkIZ3h8VA1cUINTcTymdFQ+BAAbhB8lepQpuwAdCcp-l0zc3mLO8Ql+-vck57evv4k-UOj488Xs7ULRq3OCyGZsE5HM5pab-eY3ZoiWS2aRsX7hQoAMhy8wKDmUAHp8cYILxUI5wrNcABbCBdIoAcnQADlevSoAAfKD0sgAdXQbM53IAEgAlXqshyCJoGQgDaAAWRAAEl8NLZdAKmonBBuFVqbTwrY1EQadxYnkjVp6GaAZa4NheDacTY7MplAMCLxYNxFSq1XKiqxtdxGSz6TMTTquTBw1aQzAAIyx+2O9j0pMzekAJnpIns7s9wCgACFuPAkCgMFgPMQSL7VTsZXKyix1oRTdG2fmC-gvQ1eOgDHqaV0MHwxnwINb2qFXqkSMODZAW2xQ6zM7z+RvReLc7YPb2i-3gIPF6O3Lhxzsnh0XlCF-quivhWL11zN7G13u3YSoAABYBUAAWmoSABmAEDfEvHs+wdE8h0fcJUHlB1UDyG9Z3vM9wmfD9M2ZVkXQJIkAOA0CIHAyC+Ggg9YIHBCRyQtwdHwXAAHd8AANWIYYo1+Od3mw5cilXAjPzwrkADF0BcEVv2I-9AJAqgwIgnZqN2Wijzg09EMgVBmNYjjuJGCAswwzoBICISIGfMSNz5cSdzfelpNk+Tf1I5TVKomjCygY9dMY-S6joIRgAACyZXBgHlQhgAGCL0JnSysL02yRK-Byt3fZynNfeSgA
type AllKeysOpt
document.querySelectorAll([
'main',
'[role="main"]',
'header',
'[role="banned"]',
'footer',
'[role="contentinfo"]',
@AriPerkkio
AriPerkkio / README.md
Created August 31, 2022 17:18
Svelte transpiled and instrumented
@AriPerkkio
AriPerkkio / tannerlinsley_react-table.md
Created October 3, 2022 15:24
react#25360, react-hooks/no-nested-components, react-table

Rule: react-hooks/no-nested-components

  • Message: Component "Header" is declared during render. You should move this declaration outside of render to ensure this component's state is persisted across re-renders of its parent. If this component is memoized, you should still refactor the component to be able to move it outside of render. If you want to reset its state use a key instead (see https://reactjs.org/docs/lists-and-keys.html#keys).
  • Path: tannerlinsley/react-table/old-examples/expanding/src/App.js
  • Link
  90 |         // Build our expander column
  91 |         id: 'expander', // Make sure it has an ID
> 92 |         Header: ({ getToggleAllRowsExpandedProps, isAllRowsExpanded }) => (
/*
rm -rf ./profiling
node --cpu-prof --cpu-prof-dir=./profiling index.mjs
*/
import { fileURLToPath } from "node:url";
import vm from "node:vm";
import { Worker, isMainThread } from "node:worker_threads";
globalThis.variableInGlobalScope = "Hello world";
@AriPerkkio
AriPerkkio / . index.mjs
Last active January 31, 2023 13:36
node:inspector + V8 Profiler.*PreciseCoverage
import { writeFileSync } from "node:fs";
import inspector from "node:inspector";
function firstMethod() {}
function secondMethod() {}
const session = new inspector.Session();
const collectedCoverage = [];
session.connect();
@AriPerkkio
AriPerkkio / process.mjs
Last active March 8, 2023 09:43
Node inspector worker_threads + child_process
/*
* Run as `node process.mjs` and open Chrome DevTools or similar debugging tool
*/
import { fork } from "node:child_process";
import { fileURLToPath } from "node:url";
import inspector from "node:inspector";
const filename = fileURLToPath(import.meta.url);
if (!process.env.SOME_FLAG) {
@AriPerkkio
AriPerkkio / . vm.mjs
Last active March 17, 2023 07:07
isolated vm + dynamic import
/*
$ node --watch --no-warnings --experimental-vm-modules --experimental-import-meta-resolve vm.mjs
*/
import vm from "node:vm";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { JSDOM } from "jsdom";
const server = {
async fetchModule(filename) {
@AriPerkkio
AriPerkkio / tic-tac-toe.ts
Created April 9, 2023 09:17
Typescript type system Tic-tac-toe game
/* Typings */
type TicTacToe<
MovesOrNextBoard extends Board | Turn[], // On initial round this will be a Turn[], on next rounds it will be a Board with some moves done
MovesOrMissing extends Turn[] = [], // On initial round this will be empty, on next rounds it will be the moves
PreviousMark extends ValidMark | undefined = undefined, // On initial round this will be missing, on next rounds it will be the mark of the last move
CurrentBoard extends Board = ResolveBoardFromArgs<MovesOrNextBoard>, // Parsed argument
Moves extends Turn[] = ResolveNextMovesFromArgs<MovesOrNextBoard, MovesOrMissing> // Parsed argument
> =
Moves extends [infer NextMove, ...infer NextMoves] ?
NextMove extends Turn ?