Skip to content

Instantly share code, notes, and snippets.

@pohzipohzi
pohzipohzi / clangd.md
Last active February 8, 2024 08:23
setting up clangd

Here are some examples of how to setup clangd for a project

If the project:

  • uses meson

meson setup <build_dir> generates a compilation database in <build_dir>/compile_commands.json. Since clangd automatically looks for the compilation database in build, we don't need to do anything else if build is the name of the build directory

meson setup build
@pohzipohzi
pohzipohzi / git-history-reset-authors
Last active March 27, 2021 20:06
reset git history author names
git rebase -i --root
# change verbs for relevant commits to `edit`
while [ $? -eq 0 ]; do git commit --amend --reset-author --no-edit --allow-empty --date="$(git log -n 1 --format=%ad)" && git rebase --continue; done
@pohzipohzi
pohzipohzi / gotraceback.md
Last active September 22, 2019 19:14
sample program to test output for different GOTRACEBACK settings

This is a sample program that tests output on a panicking go program based on different GOTRACEBACK settings. There are several levels that control the amount of output generated - none, single, all, system - each with it's own aliases. More information can be found at https://golang.org/pkg/runtime/.

  • env GOTRACEBACK=none go run main.go

This should give the same output as env GOTRACEBACK=0 go run main.go

panic: f3
exit status 2
@pohzipohzi
pohzipohzi / rcstart.sh
Created May 23, 2019 15:14
simple bash script to start a 6-node redis cluster
#!/bin/sh
PORTS=($(seq 7001 1 7006))
# set up servers
rm -f appendonly.aof
rm -f dump.rdb
for i in ${PORTS[@]}
do
rm -rf $i
mkdir $i
@pohzipohzi
pohzipohzi / postgres_cheat.md
Created May 12, 2019 01:53
cheatsheet for some common postgres commands

Postgres Cheatsheet

pg_ctl

pg_ctl init -D cluster
pg_ctl -D cluster -l cluster/logfile start
pg_ctl -D cluster restart
pg_ctl -D cluster promote
@pohzipohzi
pohzipohzi / compress.sh
Created April 2, 2019 13:42 — forked from bvaudour/compress.sh
tar.lz4 creation/extraction
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage : $0 <file to compress>"
exit 1
fi
file=${1%%/}
tar c "$file" | lz4 -z - "$file.tar.lz4"
@pohzipohzi
pohzipohzi / checksum.md
Created March 31, 2019 10:14
PostgreSQL Page Checksum Protection

PostgreSQL Page Checksum Protection

This gist summarises a way to create corrupted databases. Most of the material is adapted from Luca's Article.

Setup the database

Create and start the server with data checksums enabled

initdb -k -D cluster
@pohzipohzi
pohzipohzi / walg-pitr.md
Last active April 25, 2023 15:47
PostgreSQL Point-In-Time-Recovery (PITR) with WAL-G

WAL-G PITR

This gist summarises a way to simulate point-in-time recovery (PITR) using WAL-G. Most of the material is adapted from Creston's tutorial.

Setup

First we initialize a database cluster

pg_ctl init -D cluster
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pohzipohzi
pohzipohzi / join_test.go
Created December 14, 2018 08:02 — forked from dtjm/join_test.go
strings.Join vs fmt.Sprintf vs string concat (+)
package join
import (
"fmt"
"strings"
"testing"
)
var (
testData = []string{"a", "b", "c", "d", "e"}