Skip to content

Instantly share code, notes, and snippets.

@x-yuri
x-yuri / ruby: using RUBY_DEBUG_LOG.md
Last active September 14, 2024 12:26
ruby: using RUBY_DEBUG_LOG

ruby: using RUBY_DEBUG_LOG

Build with cflags=-DUSE_RUBY_DEBUG_LOG, run with RUBY_DEBUG_LOG=stderr RUBY_DEBUG_LOG_FILTER=... ruby ....

/* RUBY_DEBUG_LOG: Logging debug information mechanism
 *
 * This feature provides a mechanism to store logging information
 * to a file, stderr or memory space with simple macros.
 *
@x-yuri
x-yuri / Breaking Timeout::timeout().md
Last active September 10, 2024 16:04
Breaking Timeout::timeout()

Breaking Timeout::timeout()

a.sh:

docker run --rm -it \
-v "$PWD/timeout.patch:/timeout.patch" \
-v "$PWD/a.rb:/a.rb" \
alpine:3.20.1 sh -euxc '
    apk add ruby ruby-concurrent-ruby patch
@x-yuri
x-yuri / traefik.md
Last active August 8, 2024 07:56
traefik

traefik

traefik/bc.sh:

#!/usr/bin/env bash
set -eu
service=(
    --project traefik
    --name traefik
@x-yuri
x-yuri / vscode notes.md
Last active July 31, 2024 06:11
vscode notes

vscode notes

The shellIntegration-bash.sh is started this way:

(VS Code Internal)
TerminalService.constructor() -> [this._initializePrimaryBackend()][aaq]
TerminalService._initializePrimaryBackend() -> reconnectedPromise.then(() => [this._setConnected()][aar] )
TerminalService._setConnected() -> [this.onDidChangeConnectionState.fire()][aas]
TerminalViewPane.renderBody() -> this._terminalService.onDidChangeConnectionState(() => [this._initializeTerminal()][aat] )
TerminalViewPane._initializeTerminal() -> [this._terminalService.createTerminal()][aau] \

@x-yuri
x-yuri / Setting breakpoints using Chrome DevTools Protocol.md
Last active July 22, 2024 12:17
Setting breakpoints using Chrome DevTools Protocol

Setting breakpoints using Chrome DevTools Protocol

a.js:

const waitPort = require('wait-port');
const CDP = require('chrome-remote-interface');
const { spawn } = require('node:child_process');
const path = require('path');
const fs = require('fs');
@x-yuri
x-yuri / Debugging a nextjs project with vscode and --turbo.md
Last active July 19, 2024 03:12
Debugging a nextjs project with vscode and --turbo

Debugging a nextjs project with vscode and --turbo

Create a nextjs project:

next+14.2.5.patch (the name should match the nextjs version):

diff --git a/node_modules/next/dist/cli/.next-dev.js.swp b/node_modules/next/dist/cli/.next-dev.js.swp
new file mode 100644
index 0000000..59ed063
@x-yuri
x-yuri / Debugging vscode-js-debug.md
Last active July 19, 2024 03:13
Debugging vscode-js-debug

Debugging vscode-js-debug

Create a nextjs project:

next+14.2.5.patch (the name should match the nextjs version):

diff --git a/node_modules/next/dist/cli/.next-dev.js.swp b/node_modules/next/dist/cli/.next-dev.js.swp
new file mode 100644
index 0000000..59ed063
@x-yuri
x-yuri / Parsing nodejs command line.md
Last active July 16, 2024 10:34
Parsing nodejs command line

Parsing nodejs command line

a.mjs:

export default function getInspectInfo(nodeOptions, execArgv) {
    const args = (
        nodeOptions?.match(/(?<=^| )--inspect(-brk)?(=\S+)?(?= |$)/g) || []
    ).concat(execArgv.filter(
        a => a.startsWith('--inspect')
@x-yuri
x-yuri / Splitting a command line into arguments.md
Last active July 16, 2024 05:34
Splitting a command line into arguments

Splitting a command line into arguments

a.mjs:

// ", ', \ and (space) can be escaped with \
// \ before other symbols is removed
// inside double quotes " and \ can be escaped with \
// \ before other symbols remains
export default function splitCommandLine(l) {
@x-yuri
x-yuri / PID 1 processes doesn't have default signal handlers.md
Last active July 13, 2024 06:31
PID 1 processes doesn't have default signal handlers

PID 1 processes doesn't have default signal handlers

Dockerfile:

FROM alpine:3.20
COPY a.c .
RUN apk add build-base \
    && gcc a.c