Skip to content

Instantly share code, notes, and snippets.

View klingtnet's full-sized avatar
a damn fine cup of coffee

Andreas Linz klingtnet

a damn fine cup of coffee
View GitHub Profile
### Keybase proof
I hereby claim:
* I am klingtnet on github.
* I am klingtnet (https://keybase.io/klingtnet) on keybase.
* I have a public key whose fingerprint is F1E8 B1CC E0B7 FBF0 8E7E 33A2 A57E A370 7387 1146
To claim this, I am signing this object:
@klingtnet
klingtnet / cm13-wifi-fix.md
Last active October 8, 2016 10:58
How to update CM nighly builds

These instrctions may only work the phone I used, a Samsung N7105 aka t0lte but should be applicable to other models with minor modifications. Make sure that you have adb available, e.g. by installing the android-tools package in Arch linux.

Now, download the latest nighly release (image and recovery): $ wget 'https://download.cyanogenmod.org/get/t0lte-latest.zip' && wget 'https://download.cyanogenmod.org/get/t0lte-latest-recovery.img'

Extract the boot image from the release archive; If you forgot to do this, then you will encounter random errors like that you can't enable wifi anymore, and trust me I've lost some hours of my life fixing this issue :( $ unzip t0lte-latest.zip boot.img

Reboot you phone into recovery:

@klingtnet
klingtnet / gnumake-environment-variable-conditional.md
Last active January 12, 2017 11:38
GNU Make: Branch if an environment variable is set
.PHONY: all

ifdef IFSETUSEMYVALUE
FOO:=$(IFSETUSEMYVALUE)
else
FOO:="another value"
endif

all:
@klingtnet
klingtnet / single-vs-double-brackets.md
Last active February 24, 2017 20:42
Evaluation differences between `[[` and `[` in bash

I have two scripts, the first has some conditional expression using the single bracket (POSIX) notation [, the second is using bash style double brackets. Both scripts look functionally equivalent but the first returns exit code 0 and the second exit code 1.

$ cat single-square-bracket.sh
#!/bin/bash

value=0

if [ $value -ne 0 ]; then
@klingtnet
klingtnet / journalctl.log
Last active March 15, 2017 19:20
hibernation-freeze.log
Mar 15 00:17:40 kn-elitebook systemd[1]: Reached target Sleep.
Mar 15 00:17:40 kn-elitebook systemd[1]: Starting Hibernate...
Mar 15 00:17:40 kn-elitebook systemd-sleep[4892]: Suspending system...
Mar 15 00:17:40 kn-elitebook kernel: PM: Hibernation mode set to 'platform'
Mar 15 18:27:32 kn-elitebook kernel: PM: Syncing filesystems ...
Mar 15 18:27:32 kn-elitebook kernel: done.
Mar 15 18:27:32 kn-elitebook kernel: Freezing user space processes ... (elapsed 0.001 seconds) done.
Mar 15 18:27:32 kn-elitebook kernel: PM: Marking nosave pages: [mem 0x00000000-0x00000fff]
Mar 15 18:27:32 kn-elitebook kernel: PM: Marking nosave pages: [mem 0x0009d000-0x000fffff]
Mar 15 18:27:32 kn-elitebook kernel: PM: Marking nosave pages: [mem 0xdfde0000-0xffffffff]
@klingtnet
klingtnet / signal-handler.py
Created May 9, 2017 10:54
Python signal handling
#!/usr/bin/env python3
import signal
import sys
import time
def handler(signr, stackframe):
print("Killed with {}".format(signr))
sys.exit(1)
@klingtnet
klingtnet / gitlabartifactdownloader.go
Created June 22, 2017 09:04
Download and unzip zipped artifacts from gitlab with go
package main
import "fmt"
import "net/http"
import "archive/zip"
import "bytes"
import "io/ioutil"
import "strconv"
func main() {
#!/usr/bin/env python3
# This is a python implementation of the one-liner script
# shown in https://unnikked.ga/scraping-a-subreddit-with-a-one-liner-6322f74134df
# The python version is not downloading in parallel.
from os import path
import sys
import requests
@klingtnet
klingtnet / pbkdf2-password-hash.go
Created July 10, 2017 12:14
Generate pbkdf2 password hashes
package main
import (
"crypto/sha1"
"fmt"
"math/rand"
"os"
"strconv"
"time"
@klingtnet
klingtnet / renew-expired-gpg-key.md
Last active July 13, 2017 09:00
Renew an Expired GPG Key

How to update an expired GPG key

  • gpg --list-secret-keys someone@somewhere.com and copy the ID of the key pair you wish to renew
  • gpg --edit-key <ID>
  • check if there are sub keys shown, if so, renew them as well
  • subkeys must be selected with key <subkey-ID>
  • in the dialog enter expire
  • enter the desired renewal interval, e.g. 1y
  • save
  • upload your key (and subkey): gpg --send-keys