Skip to content

Instantly share code, notes, and snippets.

View MartyLake's full-sized avatar

Matthieu Talbot MartyLake

  • Expressive
  • France
View GitHub Profile
@MartyLake
MartyLake / .bash_rc
Created November 29, 2018 10:38
Bash alias to format files that changed before commit
#format only files that have a diff
alias gformat="git diff --name-only --ignore-submodules | xargs -I {} sh -c 'export f="{}"; cd \$(git rev-parse --show-toplevel) && [[ -f \$f ]] && echo formatting \$f && clang-format -i --style=file \$f || echo directory \$f'"
#fix osx gitgui bug + format all files + open git gui and gitk (I use these a lot to commit)
alias gh="git config --local --unset gui.geometry && git push& gformat && git gui & gitk &"
#!/bin/sh
#
# This pre-commit hook checks if clang-format-7
# is installed, and if so, uses the installed version to format
# the staged changes.
#
# Installation instructions from : https://github.com/arduino/ArduinoCore-arc32/wiki/Creating-a-pre-commit-hook-for-clang-format
# cd your-repository
# curl https://gist.githubusercontent.com/MartyLake/17ecdf00d6036b0f5773fa7bcd313e69/raw > .git/hooks/pre-commit
# chmod a+x .git/hooks/pre-commit
@MartyLake
MartyLake / Makefile
Created November 17, 2017 13:31
Notify when long operation completes
all:
long_operation.sh
notify:
display -resize 1000x1000 '${HOME}/done.jpg'
#if you want to get notified at the end of long operetion, just use:
# ’make all notify’
@MartyLake
MartyLake / Makefile
Created November 6, 2017 17:27
makefile uses an embedded python script to populate a local variable
#from https://stackoverflow.com/questions/17125269/embed-python-in-makefile-to-set-make-variables
define NEWLINE
endef
define DETECT_SDK
import os
locations = [
@MartyLake
MartyLake / filter_file.sh
Created September 19, 2017 12:23
filters a big file quickly with bash
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
input_file="in.csv"
output_file="out.csv"
NUMOFLINES=$(wc -l < ${input_file})
it=0
@MartyLake
MartyLake / consolidateM3u.sh
Created May 28, 2017 22:18
consolidate m3u files to a folder
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
#set -x #debug mode
HELPSTRING="Usage:
$ sh consolidateM3u.sh -p \"./playlist.m3u\" -o \"./outputDir/\""
function printHelp {
echo "$HELPSTRING"
}
@MartyLake
MartyLake / .vimrc
Last active October 19, 2016 09:37
set encoding=utf-8 " The encoding displayed.
set fileencoding=utf-8 " The encoding written to file.
set guifont=Source_Code_Pro:h12:cANSI:qDRAFT
set syntax=on
set backspace=2 " make backspace work like most other apps
set whichwrap+=<,>,h,l,[,] "left and right will go back to previous/next line
set number "display line numbers
set nolist "IDK, related to wrap and linebreak
set wrap "wrap text when window is too short
### Keybase proof
I hereby claim:
* I am martylake on github.
* I am martylake (https://keybase.io/martylake) on keybase.
* I have a public key whose fingerprint is C0C4 31E4 4649 39DA CE93 0F78 F300 56ED 2AB9 606F
To claim this, I am signing this object:
@MartyLake
MartyLake / post push hook
Created October 26, 2014 13:42
git tools
#!/bin/sh
#
# Automaticaly push every commit but not branch
BRANCH_NAME=$(git branch | grep '*' | sed 's/* //')
if [ $BRANCH_NAME != '(no branch)' ] && [ $BRANCH_NAME != 'master' ]
then
# your regularly scheduled hook
exec git push
@MartyLake
MartyLake / .bash_profile
Last active August 29, 2015 14:07
ZSH conf
#!/bin/bash
#a black
#b red
#c green
#d brown
#e blue
#f magenta
#g cyan
#h light grey