Skip to content

Instantly share code, notes, and snippets.

@niun
niun / set-pretty-git-log-alias.sh
Last active February 17, 2024 04:05
git log graph --oneline with date and author and colored ref names as alias
## One line per log entry with merge graph
## (--decorate is implicit for newer git versions?):
#git log --graph --oneline --decorate
## |
## Add --branches --remotes --tags --merges to see entries for all of the
## corresponding refs, not only commits (--all for all refs).
## Format output with --pretty=tformat:'<format>'
## Interesting placeholders for oneline <format>:
@niun
niun / root-ro
Last active August 1, 2023 23:22
Read-only Root-FS with overlayfs for Raspian
#!/bin/sh
#
# Read-only Root-FS for Raspian
#
# Modified 2015 by Pascal Rosin to work on raspian-ua-netinst with
# overlayfs integrated in Linux Kernel >= 3.18.
#
# Originally written by Axel Heider (Copyright 2012) for Ubuntu 11.10.
# This version can be found here:
# https://help.ubuntu.com/community/aufsRootFileSystemOnUsbFlash#Overlayfs
@niun
niun / find-raspberry.sh
Last active September 16, 2022 12:06
Find Raspberry Pi in network (looking for MAC address vendor prefix of Raspberry Pi Foundation using nmap, awk for ipv4 / ping6, ip, grep for ipv6 neighbour discovery)
sudo nmap -sP 192.168.0.0/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}'
@niun
niun / .tmux.conf
Last active February 15, 2021 11:09
mouse and colors for tmux and vim
# Configuration file for tmux >= 2.1
# .tmux.conf gets automatically read if in user directory (~)
# use 256 colour terminal:
set -g default-terminal "screen-256color"
# enable mouse:
set -g mouse on
# Not needed in tmux 2.8?
@niun
niun / rsync-cheatsheet.txt
Last active June 29, 2018 16:15
rsync backup cheatsheet
rsync -raXi --size-only /path/to/folder-to-backup/ /destinations/path/to/folder-to-backup
same as
rsync -rlptgoDXi --size-only /path/to/folder-to-backup/ /destinations/path/to/folder-to-backup
same as
rsync -rlptgoDXi --size-only /path/to/folder-to-backup /destinations/path/to
-r recursive
-l preserve links
-p preserve permissions (also updates permission on not transferred files)
-t preserve time (also updates time on not transferred files)
@niun
niun / remove-old-kernels.txt
Created July 27, 2015 11:30
Debian: Remove old kernel packages
http://tuxtweaks.com/2010/10/remove-old-kernels-in-ubuntu-with-one-command/
dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | grep -E "(image|headers)" | xargs sudo apt-get -y purge
@niun
niun / rpi-make-dt-blob.sh
Created October 24, 2014 14:33
Create custom device tree blob to configure Raspberry Pi pins on early boot time
apt-get install device-tree-compiler
wget https://raw.githubusercontent.com/raspberrypi/documentation/master/configuration/images/dt-blob.dts
# for example, set P1:26 (BCM pin 7) to active low (on Raspi B Rev2.0, in dts file from August):
awk 'NR==104{print " pin@p7 { function = \"output\"; termination = \"pull_down\"; }; // SPI_CE1_N (P1:26)"}1' dt-blob.dts > dt-blob-mod.dts
dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-mod.dts
@niun
niun / esp8266-03-result.md
Last active January 20, 2018 15:15
Test ESP8266 AT commandos

Connected to my ESP8266-ESP-03 with following baudrate settings

BAUD = 9600
BOOT_BAUD = 115200

esp8266_at_test.py prints this:

PINGING esp8266...
> AT

>

@niun
niun / build-kdeconnect-kubuntu-14.04.sh
Last active September 16, 2017 14:11
Build and install kdeconnect from git repository on (k)ubuntu 14.04 and 13.10
sudo apt-get install build-essential cmake kdebase-workspace-dev libqjson-dev git libqca2-dev
git clone git://anongit.kde.org/kdeconnect-kde
cd kdeconnect-kde
cmake -DQT_QMAKE_EXECUTABLE=/usr/bin/qmake-qt4 -DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix) ./
make
sudo make install
qdbus org.kde.kded /kded loadModule kdeconnect
kbuildsycoca4 -noincremental
@niun
niun / time-from-internet.sh
Created July 15, 2016 17:19
show time from Internetz in shell, iso-8601
curl -G -s --data-urlencode "format=%FT%T%:z" http://www.timeapi.org/cet/now # www.timeapi.org cet is CET/CEST. Don't use cest
date --iso-8601='seconds' -d "$(curl -s http://www.timeapi.org/utc/now)" # www.timeapi.org use local timezone settings
date -d "$(curl -s http://www.timeapi.org/utc/now)" +"%FT%T (UTC%:z = %Z)" # not quite ISO with timezone illustration
date -d "$(curl -s http://www.timeapi.org/utc/now)" +"%A %d.%m.%Y, %T (UTC%:z = %Z)" # non-ISO, easy readable by a german with day of week
date --iso-8601='seconds' -d "$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')" # google.com
date --iso-8601='seconds' -d "$(cat </dev/tcp/time.nist.gov/13 | cut -d' ' -f2,3) UTC" # NIST
date --iso-8601='seconds' -d "$(cat </dev/tcp/de.pool.ntp.org/13)" # ntp pool project