Skip to content

Instantly share code, notes, and snippets.

@ruicovelo
ruicovelo / parse_quoted_strings
Last active January 3, 2016 05:29
The simplest way I found to parse a string accepting words separated by <space> and grouping togetther words inside quotes. Does not support nested quotes... yet...
from pyparsing import printable,quotedString,Word,OneOrMore
#text = 'words out of quotes "words inside quotes" more words out "and more words in"'
frase=OneOrMore(Word(printable) | quotedString)
@ruicovelo
ruicovelo / tcx_parse_simple
Created February 1, 2015 17:37
Awkward way for getting run date, duration and distance from a set of tcx files
ls|while read file; do DATE=$(grep -m 1 StartTime "$file" | cut -d'.' -f 1| tr -s 'T' ' '| cut -d'"' -f2); TIME=$(grep -m 1 TotalTime "$file"| cut -d'>' -f2 | cut -d'<' -f1); DISTANCE=$(grep -m 1 DistanceMeters "$file"| cut -d'>' -f2 | cut -d'<' -f1); echo -e "$DATE\t$TIME\t$DISTANCE";done
@ruicovelo
ruicovelo / .vimrc
Last active June 6, 2016 12:52
My default .vimrc (work in progress)
# defaults
syntax on
filetype plugin indent on
set shiftwidth=2
set softtabstop=2
set tabstop=2
# per filetype
autocmd filetype python setlocal ts=4 sw=4 expandtab smartindent
autocmd filetype ruby setlocal ts=2 sw=2 expandtab smartindent