How to install Garmin Extractor in Linux (for Garmin Forerunner 310XT and others)

To download the .fit files from your garmin in Linux you can use the following command line tool:
python garmin.py

but before to use it you need to install it.

#I like to install into ~/opt change the commands to install it somewhere else
mkdir -p ~/opt
cd ~/opt

#get the latest version from here: https://github.com/mart-e/Garmin-Forerunner-610-Extractor
wget https://github.com/mart-e/Garmin-Forerunner-610-Extractor/archive/master.zip
unzip master.zip
cd Garmin-Forerunner-610-Extractor-master/

#install the dependencies (this should work for Debian/Ubuntu/Mint …)
sudo aptitude install python python-pip
sudo pip install –pre pyusb
sudo aptitude install udev
sudo cp -iv resources/ant-usbstick2.rules /etc/udev/rules.d
#REBOOT OR
sudo udevadm trigger
#PLUG OUT AND IN AGAIN THE ANT+ USB FROM PORT
#OPTIONAL – if you have a previous installation
#OLD=$(ls -d “/old_home/.config/garmin-extractor/”[0-9]*)
#cp -Rv $OLD ~/.config/garmin-extractor/
python garmin.py
#done

Now you just need to upload (manually) the .fit files to garmin connect or other site of your choice.

facebooktwittergoogle_plusredditpinterestlinkedinmail
Posted in Linux. Tags: , , , , . No Comments »
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Pub.

Playing with TAR

So you want to change the output directory o TAR? Use the -C /new/dir parameter.

You want to extract just some files of the .TGZ? simple: tar -xf cbz.tar --wildcards --no-anchored '*.php'

All options are available on the man page … I post it here because I’m too lazy to read it all the times;-)

PS: Use -C prior to the –wild… options.

facebooktwittergoogle_plusredditpinterestlinkedinmail
Posted in Linux. No Comments »
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Pub.

Move your Linux root around

The partition of my root Linux was getting really full, so I decided to move it to a bigger partition.
I didn’t had the time for a fresh install, so I decided to hack around 😉
It can be done with a system running. Mount the new partition, in /mnt/newPart for instance.

Copy the contents skipping the stuff that don’t matter:

rsync -aAXv /* /mnt/newPart/ –exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/home/*/.gvfs,/var/lib/pacman/sync/*}

Check the partitions UUIDs with blkid, take note of the one corresponding to your new partition sdb1.

Modify the new fstab at /mnt/newPart/etc/fstab and change the root’s UUID to the new one.

Now update grub  (update-grub2) to find the new installation, but not everything is ready yet.
You need to update the /boot/grub/grub.cfg (chmod +w it first, otherwise is read-only), as seen here.
On my case the new installation is on /dev/sdb1 so for grub it will be hd1,1, that’s the keyword that I’ve search for in the file.
You’ll find a line starting as linux /boot/… root=UUID=xxxx… now you need to replace that xxxx…. with the UUID that you got for the new disk.
Save and reboot, but don’t forget to select to boot from the new partition.
If everything is OK, the final step is to re- install correctly grub (where are still using sda, no change in the BIOS disk order is needed):

grub-install /dev/sda
update-grub2

Continue to enjoy the same old Linux in your brand new hard-drive/partition 😉

I’ve tried this in Ubuntu 10.4, but I guess it should work with any Linux out there with grub2 and fstab that uses UUID.

facebooktwittergoogle_plusredditpinterestlinkedinmail
Posted in Linux. 1 Comment »
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Pub.

Time your shell script operations

This is a note to self (so I don’t forgot about it) – it is not rocket science 😉

If you need to check how long it takes to run part of your bash script you can use the use PS4 trick, as explained partially here, but it is a bit messy and I don’t like to do the math by hand 😛

In order to test the performance bottleneck of one of my shell scripts I draft a small set of functions.
One to start the clock ticking, another to check how long it passed since the last mark and another to reset the clock.

You can download/copy into a file of your choice and then source it inside your script. The output is the nanoseconds passed between operations. If you make (any) use of it please let me know. I don’t think it will blow up your computer, but you’re at your own risk 😉

#######################################
# Bruno Lucas – v1.0 – 2012/10/22 #
#######################################
TIME_TICKER=0

echoerr() { echo -e “$@” 1>&2; }

function time_start()
{

TIME_TICKER=`date “+%s%N”`

}

#You can pass a message delimited by single quoted
function time_mark()
{

CURR=`date +%s%N`
DIFF=`echo “$CURR – $TIME_TICKER” | bc`
echoerr “$DIFF\t$1”
TIME_TICKER=$CURR

}

function time_reset()
{

TIME_TICKER=0

}

To use:

source timer.sh

time_start

some_op_of_mine 1 2 3 4

time_mark ‘After x’

and you’ll get something like ‘13789137   After x’ telling the elapsed time.

PS: The echoerr function was stolen from here, it echos the content to STDERR, instead of STDOUT.

PS1: Copy/paste from HTML can sometimes come with errors, always check the source code prior to execution.

 

facebooktwittergoogle_plusredditpinterestlinkedinmail
Posted in Linux, Tech. Tags: , , , , . No Comments »
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Grabbing magnet links from EZTV

To get all the magnetic links from a show that was posted on EZTV just use the following command:

wget eztv.it/show -O – | grep magnet | cut -f6 -d ‘”‘  > show.magnet.link.newer.first.txt

to sort by the order that the show was broadcast use the tac command:

wget eztv.it/show -O – | grep magnet | cut -f6 -d ‘”‘  | tac > show.magnet.link.chronological.order.txt

You want to trough-in after the grep magnet , a grep 720 if you’re looking for HD version or a grep -v 720 if want to make sure just to get SD versions. A grep -i S04E would filter Season 4 only episodes.

Notice that the argument for the cut is ‘ ” ‘ (that is, single quote, normal quote, single quote, not grave accent `) – HTML sometimes messes this up …

facebooktwittergoogle_plusredditpinterestlinkedinmail
Posted in Linux. No Comments »
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Salvar stream/programa do site da RTP

Por vezes quero ver offline (longe do browser e na TV via XBMC) algum programa da RTP. Para tal dei um olhinho ao HTML da página e pedi ajuda à minha amiga bash.

#!/bin/bash

URL=”$1″
PAGE=`wget -c “$URL” -O -`
START=`echo “$PAGE” | grep ‘addVariable(“streamer”‘ | cut -f4 -d'”‘`
END=`echo “$PAGE” | grep ‘addVariable(“file”‘ | cut -f4 -d'”‘ `
FILE=`echo $START/$END`
OUT=`basename $FILE`
mplayer “$FILE” -dumpstream -dumpfile “$OUT”

Para além das coisas normais de Linux (e Unix) usa o mplayer para salvar a stream. Podem salvar o código bnm ficheiro, dar-lhe permissões de execução e invocar com o URL da página da RTP em questão.
Funciona com os programas que testei 😛 (Jan 2012) – como se sabe estas coisas vão funcionado até que alguém do lado de lá se lembre de mudar a página 🙂

facebooktwittergoogle_plusredditpinterestlinkedinmail
Posted in Linux, Tutorial. Tags: , , , . No Comments »
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Bash, Ficheiros e Extensões

Alguns truques de bash úteis (e post para eu me lembrar deles):

FICH=”/home/bruno/abc.txt”

FICH_SEM_DIR=`basename $FICH`
echo “O ficheiro sem o caminho absoluto e’ $FICH_SEM_DIR “#abc.txt

NOME_FICH=${FICH_SEM_DIR%.*}
echo “O ficheiro sem o caminho absoluto e sem extensao e’ $NOME_FICH ” #abc

EXTENSAO_DO_FICH=${FICH_SEM_DIR#*.}
echo “A extensao do ficheiro e’ $EXTENSAO_DO_FICH “#txt

#se soubermos a priori a extensão do ficheiro é mais simples

FICH_SEM_DIR_SEM_EXTENSAO=`basename $FICH .txt`
echo “O ficheiro sem o caminho absoluto e sem extensao e’ $FICH_SEM_DIR_SEM_EXTENSAO “#abc

facebooktwittergoogle_plusredditpinterestlinkedinmail
Posted in Linux. Tags: , , . No Comments »
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Detach a running process – Linux

Sometimes I start a job remotely and only after I remember that I may need to log-off, but the process must continue to run afterwards. This can be done with command disown. On the same shell where your process is running type Ctrl+Z, to pause the program, you’ll see the job id, something like [1], you need it for the disown command, now restart the job in background with the command bg and you’re ready to issue the disown command:

disown -h %1

you can also use the pid1 of the process (use jobs -l on that same shell and you’ll get a longer number that is the pid of the process you want to detach):

disown -h pid

after that you can close the shell with exit or Ctrl+D.

If you start your program with nohup2 or screen you don’t have to worry about log-off and running processes.

This command can also be used in Unix (such as BSD/MacOS X/etc.) but their might be implementation differences.

1 After some interaction on Google+ with CNF we found out that the pid is accepted but it is not documented. I’ve changed the post to reflect a more appropriated use of the disown command (according to the manual).

2 disown -h is is basically a nohup a posteriori.

Solution found on serverFault.

facebooktwittergoogle_plusredditpinterestlinkedinmail
Posted in Linux. Tags: , . 2 Comments »
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...