Skip to content

Instantly share code, notes, and snippets.

View domargan's full-sized avatar

Domagoj Margan domargan

View GitHub Profile
@domargan
domargan / sort-md-table.sh
Created August 8, 2020 00:42
Sorting markdown tables by column
#!/bin/bash
# Credit: https://christiantietze.de/posts/2017/05/sort-markdown-tables-shell/
# First argument is a path to table file in markdown format
# Second argument is the key column+1 to sort by
(head -n 2 $1 && tail -n +3 table.md | sort --field-separator=\| --key=$2) > sorted_table.md
@domargan
domargan / CMakeLists.txt
Created November 6, 2017 22:35
One (hacky) CMakeLists.txt to rule them all...
# Credits: sakra @ https://stackoverflow.com/a/6925256
cmake_minimum_required(VERSION 3.0)
project (Foo)
file(GLOB_RECURSE Foo_SOURCES "src/*.cpp")
file(GLOB_RECURSE Foo_HEADERS "src/*.h")
set (Foo_INCLUDE_DIRS "")
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
@domargan
domargan / gccp
Created February 20, 2017 14:48
Proper g++ compile
#/bin/sh
g++ -ansi -pedantic-errors -Wall $1 $2 $3
@domargan
domargan / memcheck
Created July 21, 2016 14:46
Display how much memory a process is using
while true; do ps -eo rss,pid,euser,args:100 --sort %mem | grep -v grep | grep -i $@ | awk '{printf $1/1024 "MB"; $1=""; print }' ; sleep 0.5s ; done