Skip to content

Instantly share code, notes, and snippets.


Ivan Kozik ivan

View GitHub Profile
ivan /
Last active Jun 26, 2022
Print an outline of Rust code in the current directory
#!/usr/bin/env bash
# Print an outline of Rust code in the current directory
GRAY=$(tput setaf 7)
PURPLE=$(tput setaf 5)
BOLD=$(tput bold)
CLEAR=$(tput sgr0)
rg --sort path --heading --no-line-number --glob '*.rs' '\b(fn|struct|enum|trait|impl|mod|macro_rules)\b' |\
View gist:ba6943a77e231b009ba3732299890ee3
backup-file: rsync --modify-window=-1 without --checksum
Hello, says "--checksum is necessary because rsync only has file modification-time granularity of one second". rsync -c / --checksum can really slow things down and thus extends the period during which the server must be down to get a consistent backup. So it would be helpful to know whether --checksum can be avoided by using `rsync --modify-window=-1` i.e. `rsync -@-1`. That argument tells rsync to use nanosecond precision when comparing timestamps. The PostgreSQL documentation sort of implies that -@-1 without -c would be safe, but it might be helpful to be explicit with the information that PostgreSQL really does always update mtimes when writing, and that rsync -@-1 without -c is safe (if this is true, I mean). Alternatively, if it is somehow not true, the implication that the only problem is one second granularity could be avoided.
Best regards,
ivan /
Last active Jun 24, 2022
How to maximize all your vscode windows on startup despite whatever stupid mitigations (?) Windows 10 is applying to prevent too many windows from starting maximized at the same time

This is for people who find that

"window.newWindowDimensions": "maximized",

does not actually work on Windows. Symptoms: some or all vscode windows are not maximized on startup.

The first thing you'll want is

ivan /
Last active Jun 16, 2022
bookmarklet to read a page with a reduced width

save with a bookmark keyword (Firefox) or search engine shortcut (Chrome), e.g. "readw" and then run with "readw 30"

javascript:(function() { var width = %s || 40; var styles=`div, p { line-height: 135% } body { margin: 0 auto 0 auto !important; max-width: ${width}em }`; var newSS=document.createElement('link'); newSS.rel='stylesheet'; newSS.href='data:text/css,' + escape(styles); document.getElementsByTagName("head")[0].appendChild(newSS); })();
View gist:0c2196760e835de28c01bd9390784363
at@dev:/home/at/code/postgresql/postgresql:REL_14_STABLE# git pull --rebase
remote: Enumerating objects: 14385, done.
remote: Counting objects: 100% (14385/14385), done.
remote: Compressing objects: 100% (5907/5907), done.
error: RPC failed; curl 92 HTTP/2 stream 11 was not closed cleanly before end of the underlying stream
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output
at@dev:/home/at/code/postgresql/postgresql:REL_14_STABLE# cat .git/config
View s cannot be regexp.svelte
<script lang="ts">
import escapeRegExp from 'lodash.escaperegexp';
export let lines: string[] = [];
let filter_string: string = "";
let match_case: boolean = false;
let match_whole_word: boolean = false;
let use_regexp: boolean = false;
View lesson.svelte
<script lang="ts">
import escapeRegExp from 'lodash.escaperegexp';
export let lines: string[] = [];
let filter_string: string = "";
let match_case: boolean = false;
$: escaped_filter_string = escapeRegExp(filter_string);
$: regexp = new RegExp(escaped_filter_string, match_case ? undefined : "i");
$: {
ivan / gist:cf2d7e53718e8f3a4489f3e66213136d
Last active Feb 27, 2022
uBlock Origin rules to hide useless stuff on Google Search results pages
View gist:cf2d7e53718e8f3a4489f3e66213136d
! This is the most annoying one that Google optimizes for accidental clicks.
! Hide the 'People also search for' slide-in box when going back on Google Search.
! We require the other attributes here to reduce the risk of false positives.$#div[id^="eob_"][jscontroller][jsdata][jsaction][data-ved] { display: none !important; }
! Hide the 'People also ask' box$#div[data-initq][data-it][jscontroller][jsaction]:nth-ancestor(1) { display: none !important; }
! Hide the 'Related searches' box
View json.ts
* A wrapper to work around otherwise not being able to mutate caller's string.
class WrappedValue {
constructor(public val: any) {}
function strip_out_nuls_(wrapped: WrappedValue): number {
let had_nul = 0;
const val = wrapped.val;
ivan /
Last active Jan 16, 2022
Using SingleFile/cli on NixOS without Docker
# or properly via environment.systemPackages
nix-env -iA google-chrome-dev nodePackages.pnpm nodejs_latest
(cd ~/ && git clone
(cd ~/SingleFile/cli && pnpm install --ignore-scripts --no-optional --prod)
~/SingleFile/cli/single-file --browser-executable-path google-chrome-unstable --dump-content ""