Skip to content

Instantly share code, notes, and snippets.

View iAnatoly's full-sized avatar

Anatoly Ivanov iAnatoly

View GitHub Profile
#!/bin/bash
#
# based off https://developer.atlassian.com/blog/2016/02/best-way-to-store-dotfiles-git-bare-repo/
#
git clone --bare git@github.com:iAnatoly/homedot.git $HOME/.cfg
function config {
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
config checkout
@iAnatoly
iAnatoly / gist:bff5274bd2730b1a4801cdb6cb152fa1
Created February 2, 2019 20:21
Fixing ubuntu 18.10 lock screen issue
# the issue is siimple misconfigurations of gdm3
# the solution is to reinstall it, or better yet - switch to lightdm:
sudo apt remove gdm3 && dpkg-reconfigure lightdm
#
# or reinstall gdm3, it is up to you.
@iAnatoly
iAnatoly / json-to-sqlite.md
Last active December 24, 2022 19:06
Convert json to a sqlite database for querying

Sometimes, you need to quickly dump a json file into sqlite, just to run some queries on it. This is a two-step process:

1. convert json to csv

cat file.json | jq -r '.data | map([.field1, .field2, .field3] | @csv)| join("\n")' > file.csv

1a. add headers line into your csv file, i.e.

@iAnatoly
iAnatoly / swap.sh
Created October 14, 2019 18:54
oneliner to investigateprocess swap usage
for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less
@iAnatoly
iAnatoly / fix-ubuntu-wifi-on-resume.sh
Created November 5, 2019 02:28
Fix no wifi on resume in Ubuntu
# cat > /etc/systemd/wifi-resume.service
[Unit]
Description=Restart networkmanager at resume
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target
[Service]
Type=oneshot
ExecStart=/bin/systemctl restart network-manager.service
@iAnatoly
iAnatoly / respbery_wifi.sh
Created November 5, 2019 19:54
Fix raspbery pi wifi reconnevct
cp /etc/wpa_supplicant/ifupdown.sh /etc/ifplugd/action.d/ifupdown
SELECT temp *9/5+32
FROM
(SELECT median("temperature") AS "temp" FROM "weather" WHERE $timeFilter GROUP BY time(5m)),
(SELECT median("mean_temperature") AS "temp" FROM "year"."weather" WHERE $timeFilter GROUP BY time(1h))
GROUP BY "source" fill(null)
@iAnatoly
iAnatoly / gist:022834cf07ec0d83cb14eae054864aba
Created November 10, 2020 01:13
Influxdb retention policy and downsampling
> CREATE RETENTION POLICY two_days on weather duration 2d replication 1 default
> CREATE RETENTION POLICY year on weather duration 52w replication 1
> create continuous query cq_30m on weather BEGIN SELECT mean(*) into year.:MEASUREMENT from two_days./.*/ group by time(30m),* EN
@iAnatoly
iAnatoly / swapin-swapout.bt
Created February 8, 2021 20:55
bpftrace oneliner for swap-in and swap-out
bpftrace -e 'kprobe:swap_read*,kprobe:swap_write* {@[comm, pid] = count();} interval:s:5{ time(); print(@); clear(@); }'
@iAnatoly
iAnatoly / whattheswap.sh
Last active November 30, 2021 18:47
print out the swap usage by process
for proc in /proc/*; do cat $proc/smaps 2>/dev/null | awk -v proc="${proc}" '/Swap/{swap+=$2/1024}END{if (swap>1) { "readlink "proc"/exe"|getline c; print int(swap+0.5), "\tMB\t", c }}'; done | sort -n