Skip to content

Instantly share code, notes, and snippets.

View kamilogorek's full-sized avatar

Kamil Ogórek kamilogorek

View GitHub Profile
@kamilogorek
kamilogorek / pglite-protocol.mjs
Created March 30, 2024 17:02
pglite + postgres wire protocol
import { createServer } from "node:net";
import { PGlite } from "@electric-sql/pglite";
const PORT = 5432;
const db = new PGlite();
await db.exec(`
CREATE TABLE IF NOT EXISTS test (
id SERIAL PRIMARY KEY,
name TEXT
function prefixer(prefix) {
return function (...data) {
console.log(
data
.map((d) => JSON.stringify(d, null, 2))
.join(" ")
.split("\n")
.map((line) => `${prefix}${line}`)
.join("\n")
);
@kamilogorek
kamilogorek / _screenshot.md
Last active May 2, 2024 13:48
Clutter-free VS Code Setup
image
// HOW TO USE:
// 0. Get OAuth from https://developers.google.com/youtube/registering_an_application
// 1. Go to https://www.youtube.com/feed/library
// 2. Paste snippet below in DevTools
// 3. Replace `VIDEOS` with copied data
// 4. Run script
// JSON.stringify(
// Array.from(document.querySelectorAll("a.ytd-playlist-video-renderer"))
// .map((v) => {
# Get videos with:
#
# const videoElements = Array.from(
# document
# .querySelector("ytd-playlist-video-list-renderer")
# .querySelectorAll("ytd-playlist-video-renderer")
# );
#
# const links = videoElements
# .map((el) => `"${el.querySelector("a").href}"`)
#!/usr/bin/env bash
fn() {
echo "Return is just placeholder exit code, rely on command instead"
return 1
}
i=1
while true; do
var elements = Array.from(document.querySelectorAll(".ytd-playlist-video-list-renderer span.ytd-thumbnail-overlay-time-status-renderer"))
var time = elements.map(v => {
const [s,m,h] = v.innerText.split(':').reverse().map(x => parseInt(x,10));
return s + (m || 0) * 60 + (h || 0) * 60 * 60;
})
var total = time.reduce((acc, v) => acc + v);
var h = Math.floor(total / (60 * 60));
var m = Math.floor((total - (h * 60 * 60)) / 60);
var s = total%60;
npm run test-leaking
> sentry-jest-leak-repro@1.0.0 test-leaking /Users/kirill/Idea/sentry-jest-leak-repro
> jest leaking --maxWorkers=1 --logHeapUsage --detectOpenHandles
PASS src/leaking/488.leaking.test.js (60 MB heap size)
PASS src/leaking/399.leaking.test.js (55 MB heap size)
PASS src/leaking/31.leaking.test.js (55 MB heap size)
PASS src/leaking/136.leaking.test.js (57 MB heap size)
PASS src/leaking/270.leaking.test.js (68 MB heap size)
package main
import (
"fmt"
"os"
"os/exec"
"strconv"
"time"
)
func ExtractStacktrace(err error) *Stacktrace {
// https://github.com/pkg/errors
// Packages definitions:
// type Frame []uintptr
// type StackTrace []Frame
type stackTracer interface {
StackTrace() errors.StackTrace
}