Skip to content

Instantly share code, notes, and snippets.

@caiobegotti
caiobegotti / logtrap.sh
Created Oct 8, 2014
Log trapper, useful when you want to log all commands with a timestamp for further analysis (e.g. if your script echoes to a log file)
View logtrap.sh
#!/bin/bash
function logtrap() {
local last="${BASH_COMMAND}"
local exitcode=${?}
# any format is ok but this will be printed BEFORE all commands, not after
echo "TRAPLOG: [$(date +%T)] [${exitcode}] [${last}]"
}
@caiobegotti
caiobegotti / volp.abl.sh
Created Jan 5, 2015
Busca palavra no dicionário da ABL já pelo acordo ortográfico
View volp.abl.sh
#!/bin/bash -eu
# public domain
#
# caio1982@gmail.com
input=${1}
term=$(echo ${input} | xmlstarlet esc | sed -e 's/\&\#\x/\%/;s/\;//')
lynx -dump http://www.academia.org.br/sistema_busca_palavras_portuguesas/volta_voca_org.asp?palavra=${term} | sed -e '1!d' -e 's/^.* \([a-z]\+\) .*/\1/g'
View gist:2307114
Shell:
cat *.xml | sed 's/\([A-Z][[:alpha:]]\{0,\}\. [A-Z]\)/| \1/g' | tr '|' '\n' | sed 's/^\( .\{25\}\).*$/\1/g'
Cn. Octauii praecidi capu
P. Crassi
Sp. Albinus, homines cons
M. Antonii, omnium eloque
C. Caesaris, in quo mihi
C. Marius tum, cum Cimbri
@caiobegotti
caiobegotti / 1SE-hack
Created Jan 23, 2014
Hack to work around the limitations of 1SE.app for iOS
View 1SE-hack
# an special function because it requires the IP of my iphone
rtw-backup-one-second-everyday () { rsync -avz --stats --progress --rsh=ssh root@${1}:/private/var/mobile/Applications/.../Documents/* ~/one-second-everyday/; }
# special case for the damn 1SE app on iphone
# which does not offer an option to disable overlays
# nor change the date format, nor hide its logos
function rtw-one-second-list() {
originalfile=$(find ~/one-second-everyday/ -iname '*STORED_ONE_SECOND_VIDEOS_ARRAY_FILE_PATH*' | head -1)
originallist=$(basename ${originalfile})
indexlist=/tmp/${originallist}.plist
View movie-stats-csv.sh
#!/bin/bash
# public domain
# caio begotti
set -euo pipefail
CSVFILE=$(mktemp)
wget https://raw.githubusercontent.com/caiobegotti/Scripts/master/rottentomatoes-ratings-exporter.csv --quiet -O ${CSVFILE}