Skip to content

Instantly share code, notes, and snippets.

View r10r's full-sized avatar

Ruben Jenster r10r

  • Drachenfels GmbH
  • Pforzheim
View GitHub Profile
@r10r
r10r / proc_task_children.go
Created October 9, 2020 14:17
Example how to parse /proc/{pid}/task/{tid}/children recursively (see 'man 2 proc')
package main
import (
"fmt"
"io/ioutil"
"os"
"strings"
)
func GetAllChildren(proc string, pid string) ([]string, error) {
@r10r
r10r / deadline.sh
Created July 8, 2020 09:49
Self terminate shell script after deadline.
#!/bin/sh
PID=$$
deadline() {
sleep $1
kill $PID
}
export deadline
deadline 2 &
@r10r
r10r / cmd_wrapper.sh
Last active July 6, 2020 10:08
Bash command wrapper with partial option parsing.
#!/bin/bash
cmd=mycmd
# parse a subset of all options
while true; do
while getopts c:u:b: arg 2>/dev/null; do
case $arg in
"a")
arga=$OPTARG
;;
@r10r
r10r / cmdline_usage_syntax.md
Last active July 10, 2018 11:22
Cmdline Best Practises

Help / Usage Syntax

Usage string format:

cmd_name [options] arg1_name [arg2_name]

  • List paths to config files and used environment variables.
  • Show links / hints for more detailed information.

Options

@r10r
r10r / golang_cheatsheet.md
Last active December 7, 2017 13:50
Golang Cheatsheet

List external dependencies

go list -f '{{.Deps}}' | tr "[" " " | tr "]" " " | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}'
@r10r
r10r / vimrc.local
Last active May 4, 2021 13:00
My vim config file
" location of this file
" global (debian): /etc/vim/vimrc.local
" user: ~/.vimrc
" Avoid that defaults overwrite custom configuration
" see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=837761
" run ':scriptnames' to show the import order
let skip_defaults_vim=1
source $VIMRUNTIME/defaults.vim
@r10r
r10r / README.md
Created August 14, 2016 11:22 — forked from eliquious/README.md
Golang OpenPGP examples

Building

go build -o goencrypt main.go

Generating Keys

@r10r
r10r / clearsign_test.go
Created July 19, 2016 13:22
Test golang OpenPGP message signing (clearsign).
package repository
import (
"bytes"
"crypto/rand"
"crypto/rsa"
"fmt"
"github.com/stretchr/testify/assert"
"golang.org/x/crypto/openpgp/clearsign"
"golang.org/x/crypto/openpgp/packet"
@r10r
r10r / redmine_release_notes.tmpl.yml
Last active July 8, 2016 17:03
Format to export Release Notes from Redmine to YAML
Name: %{name}
Date: %{date}
Id: %{id}
Description: %{description}
ResolvedIssues:
-
Subject: %{subject}
ReleaseNotes: '%{release_notes}'
Id: %{id}
Tracker: %{tracker}
@r10r
r10r / find.go
Created June 28, 2016 07:55
Simple directory listing with include / exclude pattern support.
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"regexp"
)