Skip to content

Instantly share code, notes, and snippets.

View kiprasmel's full-sized avatar

Kipras Melnikovas kiprasmel

View GitHub Profile
@kiprasmel
kiprasmel / debugging-git.md
Created March 21, 2024 12:53 — forked from phil-blain/debugging-git.md
Debugging Git for Git developers on Linux and macOS

Debugging Git

Some tips about debugging Git with GDB and LLDB.

Compiling Git for debugging

By default, Git's Makefile compiles Git with debug symbols (-g), but with optimization level -O2, which can lead to some variable being optimized out and thus making the executable harder to debug.

To compile with -O0, you can tweak CFLAGS using config.mak:

$ cat config.mak
@kiprasmel
kiprasmel / bash-argv-forwarding
Last active February 20, 2024 14:36
bash argv forwarding: $* vs $@ vs "$*" vs "$@" -- use "$@"
#!/usr/bin/env bash
fn() {
base="$1"
shift
printf "$base with \$*\n"
for i in $* ; do printf " $i\n"; done;
printf "$base with \$@\n"
for i in $@ ; do printf " $i\n"; done;
printf "$base with \"\$*\"\n"
@kiprasmel
kiprasmel / roam-expand-all-linked-refs.js
Last active September 17, 2023 18:02
roam: Expand All blocks of linked refs
/**
* https://gist.github.com/kiprasmel/3fb1578e1f428dd1dd8e88683ca8c400
*
* put in a javascript code block under a block containing {{[[roam/js]]}} text, like so:
* - {{[[roam/js]]}}
* - this code
*/
// https://roamresearch.com/#/app/developer-documentation/page/JTLUegLiI
window.roamAlphaAPI.ui
#!/bin/sh
for p in *projects/; do
printf "\n$p\n\n"
for dir in $(find "./$p" -type d -maxdepth 1); do
gitdir="$dir/.git"
test -d "$gitdir" && {
printf "$dir\n"
git --work-tree="$dir" --git-dir="$gitdir" status -s
}
// import fs from "fs";
import { Server } from "http";
import express from "express";
import cors from "cors";
const app = express();
app.use(cors());
app.use(express.json());
<!--
- https://preactjs.com/guide/v10/getting-started#no-build-tools-route
- https://preactjs.com/guide/v10/getting-started#alternatives-to-jsx
-->
<script type="module">
import * as preact from 'https://unpkg.com/preact?module';
import htm from 'https://unpkg.com/htm?module';
const h = htm.bind(preact.h);
/**
* https://gist.github.com/kiprasmel/75de24e48c8c442e55d4771768d7ba49
*/
export type Cb = () => void;
export class EventEmitter<Event extends string> {
listeners: Map<Event, Cb[]> = new Map();
/**
/*
.mtk3, .mtk6 {
color: #61e2ff;
text-shadow: 0 0 2px #001716, 0 0 5px #03edf933, 0 0 10px #ffff6633;
}
.mtk3.mtki {
font-style: italic;
color: #9963ff99;
}
@kiprasmel
kiprasmel / rename.js
Created October 10, 2021 20:19
rename.js - experiments w/ `git mv` et al
#!/usr/bin/env node
const fs = require("fs");
const { spawn, exec } = require("child_process");
const path = require("path");
const { snakeCase, pascalCase } = require("/Users/kiprasmelnikovas/.local/share/yarn/global/node_modules/change-case");
// const {pipe} =require( "/Users/kiprasmelnikovas/.local/share/yarn/global/node_modules/fp-ts")
// // git status --short | grep '^[RAD]' > status
const doFoo = ({ a = 10, b, c } = {}) => {
console.log(a, b, c);
};
doFoo(); // a 10 b undefined c undefined
doFoo({ b: 20 }); // a 10 b 20 c undefined
// /\ a still with default value!