Skip to content

Instantly share code, notes, and snippets.

View tkalfigo's full-sized avatar

Thalis K. tkalfigo

  • Berlin, Germany
View GitHub Profile
@tkalfigo
tkalfigo / gist:5695629
Last active February 1, 2017 14:35
Place in .bashrc so that psql can navigate using cursor keys result sets that are wider than your terminal.
#Place this in ~/.bashrc or ~/.bash_profile so that psql can show rows that are wider than the terminal using cursor keys
export PAGER=less;
export LESS='-iMFXSx4R';
@tkalfigo
tkalfigo / wal_archive_scp.sh
Last active June 21, 2019 11:48
Bash shell script for WAL archiving over ssh to remote host when doing replication with Postgresql
#!/bin/bash -x
PG_DATA_DIR="/home/postgresql/data";
DEST_HOST="example.com";
DEST_DIR="/home/remote_user/WAL_ARCHIVE";
SCP_USERNAME="remote_user";
# uses ssmtp to send email [for setup see: http://www.havetheknowhow.com/Configure-the-server/Install-ssmtp.html]
EMAIL_RECIPIENT="[email protected]";
EMAIL_MSG="To: [email protected]\nFrom: [email protected]\nSubject: Replication error\n\n";
#in case of error, how long to sleep before retrying
@tkalfigo
tkalfigo / gist:5695645
Last active December 18, 2015 00:18
How to resume an interrupted scp
$ rsync --partial --progress -av --rsh=ssh local_file [email protected]:~/
$ rsync --partial --progress -av --rsh=ssh [email protected]:~/remoteFolder/ ./localFolder/
Or shorter version
$ rsync -av -P -e ssh SRC DEST
If ssh is on a non default port:
@tkalfigo
tkalfigo / .psqlrc
Last active September 11, 2017 22:00
My .psqlrc
\set QUIET 1
\pset null '(null)'
\pset linestyle unicode
\pset border 2
\timing
\set ON_ERROR_ROLLBACK interactive
\set HISTFILE ~/.psql_history- :HOST - :DBNAME
\set HISTSIZE 2000
\set PROMPT1 '%n@%/[%M:%>] # '
\set PROMPT2 '> '
@tkalfigo
tkalfigo / gist:8093636
Last active July 4, 2017 19:03
Useful git aliases
# alias gitlo='git log --no-walk --tags --pretty="%h %d %s" --decorate=full --oneline'
alias gitlo='git log --pretty="%h %ad %d %s (%an)" --decorate=full --graph -n 30 | grep -E --color "^|tag: "'
alias gitloa='git log --no-walk --tags --pretty="%h %d %s" --decorate=full [email protected] --oneline'
alias gitbra="git branch -vva"
alias gitsta="git status"
alias gitdif="git diff --color-words"
alias gitlosum="git log --stat --summary"
alias gitdifstat="git diff --stat --summary"
alias gitpull="git pull --rebase"
alias gitpru="git remote prune origin"
Date.prototype.prettyPrint = function () {
return ['Jan.', 'Feb.', 'Mar.',
'Apr.', 'May', 'Jun.',
'Jul.', 'Aug.', 'Sep.',
'Oct.', 'Nov.', 'Dec.'][this.getMonth()] + " " +
(function (d) {
var s = d.toString(), l = s[s.length-1];
return s+(['st','nd','rd'][l-1] || 'th');
})(this.getDate()) + ", " +
this.getFullYear() + " " +
@tkalfigo
tkalfigo / gist:8830556
Last active February 1, 2017 14:26
Set bash shell prompt to display git branch when in versioned folder
export PS1="\[\e]0;\u@\h:\w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$(__git_ps1)\$ "
@tkalfigo
tkalfigo / gist:8850946
Last active February 1, 2017 14:26
Script to run meld by default on git diff's (~/.git_meld_diff.js)
#!/usr/bin/env node
var exec = require('child_process').exec;
function cb(error, stdout, stderr) {
if (error !== null) {
console.log('exec error: ' + error);
}
}
exec('/usr/bin/meld ' + process.argv[3] + ' ' + process.argv[2] , cb);
@tkalfigo
tkalfigo / gist:9134406
Last active February 1, 2017 14:25
~/.gitconfig
[user]
name = Thalis Kalfigkopoulos
email = [email protected]
[push]
default = simple
[diff]
external = /home/tkalfigo/.git_meld_diff.js
[color]
branch = auto
diff = auto
@tkalfigo
tkalfigo / gist:f94b4ceae6a038edff64
Created June 19, 2014 13:04
md5 checksum on a directory
find somedir -type f -exec md5sum {} \; | sort -k 34 | md5sum