Skip to content

Instantly share code, notes, and snippets.

@caiobegotti
caiobegotti / gist:2307114
Created April 5, 2012 01:12
shell2python
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 January 23, 2014 16:45
Hack to work around the limitations of 1SE.app for iOS
# 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
@caiobegotti
caiobegotti / logtrap.sh
Created October 8, 2014 22:01
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)
#!/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 January 5, 2015 00:01
Busca palavra no dicionário da ABL já pelo acordo ortográfico
#!/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'
#!/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}