Skip to content

Instantly share code, notes, and snippets.

View untoreh's full-sized avatar
🐭
munch...

Francesco Giannelli untoreh

🐭
munch...
View GitHub Profile
@untoreh
untoreh / i3-move
Created April 10, 2017 11:27
incremental steps i3wm window move command
#!/bin/sh
verse=$1
stu=20
tapf=/tmp/i3-tap
stepf=/tmp/i3-step
verf=/tmp/i3-verse
if [ ! -f $tapf ] ; then
echo `date +%s` > $tapf
fi
@untoreh
untoreh / build static go.md
Created January 5, 2018 06:57
build a stripped golang binary with statically linked c

build static go

-s -w for stripping

go build --ldflags '-s -w -linkmode external -extldflags "-static"' main.go

@untoreh
untoreh / compile with custom libs and ld folder.md
Created January 5, 2018 14:48
ld.so name of custom dynamic linker path

compile with custom libs and ld folder

VARS

LD_RUN_PATH='$ORIGIN' RPATH='$ORIGIN'

FLAGS

-Wl,--dynamic-linker=ld.so

@untoreh
untoreh / gitsync.md
Last active January 16, 2018 11:15
sync files over git

gitsync

GIT_SYNC_FILES=${GIT_SYNC_FILES:-$(find -name "*.?db")}
GIT_REPO_PATH=${GIT_REPO_PATH:-~/chain}

for f in "$GIT_SYNC_FILES"; do
  ln $f $GIT_REPO_PATH
done
@untoreh
untoreh / PATH.md
Created January 18, 2018 14:23
default path

PATH

echo "export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin" >> ~/.profile
@untoreh
untoreh / getalp.md
Last active March 19, 2018 11:46
fetch an alpine chroot

getalp

wget -qO- https://raw.githubusercontent.com/untoreh/scripts/utils/deploy/getalp | bash

@untoreh
untoreh / alpine glibc.md
Last active March 15, 2018 15:22
download alpine glibc

alpine glibc

apk add --update ca-certificates wget
wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.27-r0/glibc-2.27-r0.apk
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.27-r0/glibc-bin-2.27-r0.apk
apk add glibc-2.27-r0.apk glibc-bin-2.27-r0.apk

netcat http server

while true ; do nc -l -p 1234 -e 'echo -e "HTTP/1.1 200 OK\n\n $(date)"'; done

@untoreh
untoreh / fix-ppa-keys
Created April 4, 2018 15:48
add all missing ubuntu ppa keys
#!/bin/sh
KEYS=$(apt update 2>/dev/null | grep NO_PUBKEY | sed -r 's/.*NO_PUBKEY (.*)/\1/')
for k in $KEYS; do
apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys $k
done

Generate a random string with just bash

Adding options to add newlines, choose lowercase or uppercase or both is trivial

rand_string() {
    local c=0
    while [ $c -lt $1 ]; do
        printf "\x$(printf '%x' $((97+RANDOM%25)))"
        c=$((c+1))
 done