Skip to content

Instantly share code, notes, and snippets.

@gvieira
gvieira / .custom_bash
Last active December 20, 2015 18:28
I love zsh, but bash keeps things simpler. You can add it directly to .bash_profile or create a new file and source it in .bash_profile. References: - For git branch, the internet! - For prompt, https://github.com/sindresorhus/pure. - For theme, https://github.com/chriskempson/tomorrow-theme.
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
export PS1='\[\033[34m\]\w \[\033[1;30m\]$(parse_git_branch)\[\033[0m\]\n\[\033[1;35m\]❯ \[\033[0m\]'
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
@gvieira
gvieira / strer.bash
Created October 21, 2013 12:49
Adjust str encoding and rename it according to movie name.
# Set encoding to UTF-8
for f in *.srt; do iconv -f `file --mime-encoding -b "$f"` -t UTF-8 "$f" > "$f.u"; mv "$f.u" "$f"; done
# Rename according to movie
ls *.srt | while read f; do n=`grep -o 'S..E..' <<< "$f"`; m=`ls -1 *"$n"* | grep -v "\.srt$"`; o=${m%.*}; mv "$f" "$o.srt"; done
@gvieira
gvieira / JSPromise
Created April 6, 2016 14:31 — forked from timfreiheit/JSPromise
Android JavascriptInterface Promise
import android.os.Build;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import com.google.gson.Gson;
import java.util.concurrent.Callable;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;