miércoles, 17 de mayo de 2017

Descarregar programes de RAC1 desde la linea de comandes

Fa anys que sóc seguidor de "La Competència", i no sempre puc escoltarla en directe. Bé, hi ha la opcio de descarregar programes desde "rac1 a la carta".


El tema es que es un conyàs anar manualment a la web i descarregar el mp3. Fins aquesta setmana, el següent zsh script m'ha deixat descarregar el mp3 del dia:

function lacomp () {
    typeset -A days
    days[Sun]=Diumenge
    days[dom]=Diumenge
    days[Mon]=Dilluns
    days[lun]=Dilluns
    days[Tue]=Dimarts
    days[mar]=Dimarts
    days[Wed]=Dimecres
    days[mié]=Dimecres
    days[Thu]=Dijous
    days[jue]=Dijous
    days[Fri]=Divendres
    days[vie]=Divendres
    days[Sat]=Dissabte
    days[sab]=Dissabte
    #echo $(${days[$(date +%a)]})
    echo $(date +%a)
    wget "http://www.racalacarta.com/download.php?file=download.php-file=$(date +%m)$(date +%d)%2012h%20(${days[$(date +%a)]}%20$(date +%d-%m-%y))%20%20%20LA%20COMPETENCIA.mp3"
    return
    }

Doncs ara resulta que han canviat la web, i m'he hagut de fer un altre script per a descarregar l'últim programa de la competencia

function lacompeti () {
    curl http://www.rac1.cat/a-la-carta/la-competencia | pup 'a.fa-arrow-down attr{href} ' | head -1 | xargs wget
    ls -tr *mp3*download | tail -1 | xargs mplayer
}

jueves, 11 de mayo de 2017

Git 2.13 has been released

As you can see in github blog, there's a new git version (2.13).

There are some internal and some external changes, but the one that stroke me as most useful for me is conditional configurations.

Conditional includes, means that you can preset in your ~/.gitconfig some conditions, like

[includeIf "gitdir:~/work/"]
  path = .gitconfig-work
[includeIf "gitdir:~/play/"]
  path = .gitconfig-play
 
Now you can put whatever options you want into those files:

$ cat ~/.gitconfig-work
[user]
name = Serious Q. Programmer
email = serious.programmer@business.example.com

$ cat ~/.gitconfig-play
[user]
name = Random J. Hacker
email = rmsfan1979@example.com  

After that, you'll be able to commit away in any project in your computer, and git will do The Proper Thing.  This is just awesome, that all the hackery I had to simulate this can now go away.  I'm going to add this to my configs NOW. :)


As this is a git post, I'll take the opportunity to mention this blogpost about filter branch. Also, this one about packfiles. Both are advanced topics, but you know..... it's fun :)