Skip to content

Instantly share code, notes, and snippets.

@sprhawk
sprhawk / tricks.md
Created March 15, 2021 10:54
change cwd of running process

Tricks

change cwd of running process

~ ps ax|grep tmux
~ lsof -p 8670 | grep cwd
~ gdb -q -p 8670
(gdb) call (int) chdir("/tmp")
(gdb) detach
(gdb) quit
@sprhawk
sprhawk / delete-readonly-btrfs-snapshots.sh
Created March 10, 2021 04:35
delete readonly btrfs snapshot
# set -x
# set -v
for f in *; do
if [ -d $f ]; then
device_dir=${f%%.*}
snapshot_dir=${f##*.}
if [ $snapshot_dir != $device_dir ]; then
echo $f "-> " $snapshot_dir ":" $device_dir
btrfs property set -ts $f ro false
@sprhawk
sprhawk / sync-debian-mirror.sh
Created March 10, 2021 04:34
sync debian mirror
### reference to https://help.ubuntu.com/community/Debmirror
#!/bin/bash
#
# Don't touch the user's keyring, have our own instead
#
# export GNUPGHOME=/home/mirrorkeyring
# Arch= -a # Architecture. For Ubuntu can be i386, powerpc or amd64.
# sparc, only starts in dapper, it is only the later models of sparc.
@sprhawk
sprhawk / build_chrono.sh
Created February 23, 2021 15:22
Generate Makefile for ProjectChrono
ROOT_DIR=$PWD
echo $ROOT_DIR
cd build_chrono; cmake -BRelWithDebInfo \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX="$ROOT_DIR/local" \
-DENABLE_MODULE_COSIMULATION=ON \
-DENABLE_MODULE_PYTHON=ON \
-DPYTHON_EXECUTABLE="/usr/local/bin/python3" \
-DENABLE_MODULE_MKL=ON \
-DENABLE_MODULE_PARALLEL=ON \
@sprhawk
sprhawk / btrfs_send_receive_snapshots.sh
Last active October 15, 2020 06:58
btrfs send all snapshots to other directory
#!/bin/bash
usage()
{
echo "usage: `basename $0` from_directory to_directory"
}
if [ -z $1 ] || [ -z $2 ]; then
usage
exit 1
@sprhawk
sprhawk / nfsroot.md
Created October 14, 2020 16:16
Yocto NFS boot
@sprhawk
sprhawk / openocd-rk3399.cfg
Created October 12, 2020 12:25
openocd for rk3399
source [find interface/jlink.cfg]
transport select swd
adapter speed 1000
reset_config none
source [find target/rk3399.cfg]
# reset_config trst_only
@sprhawk
sprhawk / openocd-rk3368.cfg
Last active October 12, 2020 15:33
openocd for rk3368
source [find interface/jlink.cfg]
transport select swd
adapter speed 4000
reset_config none
gdb_target_description enable
source [find target/rk3368.cfg]
@sprhawk
sprhawk / osm2pgsql.sh
Created October 12, 2020 04:07
import OSM into PostgreSQL
osm2pgsql -v -c -C 40960 -F ./flat-nodes -s --number-processes 16 -d osm -U osm -W -H localhost planet-200831.osm.pbf
@sprhawk
sprhawk / start_tmux_workspace.sh
Last active May 23, 2021 14:09
Start My iOS Backup Service Development tmux environment
#!/bin/bash
SESSION="Work"
WORKROOT=$PWD
IOS_BACKUP=0
CORE_SYSTEM=1
WEBUI=2
PHOTOS=3
OFFCLOUDS=4