Rants on C, GCC, …

I don’t know C, but as a seasoned Java programmer (not to mention that I do a lot of scripting) I really didn’t expect:

  • Makefile are idiotic (tab is significant!)
  • You need those stupid header files
  • Shared Objects are a mess
  • The order of the arguments on the GCC command line matters!

* * *

* * *

* * *

ffmpeg: split video and extract audio

This is the command to extract a piece from a video file in the most efficient manner:

ffmpeg -ss $START -i "My 21st Birthday" -t $DURATION -c:v copy -c:a copy "Funny moment.webm"

Where

  • $START is the start moment, in hh:mm:ss[.mmm] format
  • $DURATION is the length in the same format as above

Note that in this case the order of parameters matters! If the input file is given before -ss, ffmpeg will still decode the streams from the beginning of the file. Instead, if -ss is given first, the streams are first seek’d, and only after the start point decoding begins.

[More...]

* * *

Android tricks

This post will gather all those little tricks that speed up your Android development, because I found I often get stuck because of poor documentation.

[More...]

* * *

ACK: Better than GREP!

Better than grep!

On Ubuntu, you need to install the package ack-grep (oddly, the executable is also named ack-grep…)

Examples: find the usages of the variable $secret in the PHP files

$ ack-grep --php '\$secret'

* * *

Git with different SSH identities

Nowdays the best way to access remote Git repositories is through the HTTP transport. However most service still offer SSH connectivity, and there are times when you want to access different hosts with SSH identities different than the default one (id_rsa). Useful links

Disclaimer: I pasted content from the aforementioned sources. I hope I have the time to review it and clarify and make it my own. For the time, it’s only a reference for myself.

If you have an active ssh-agent that has your id_rsa key loaded, then the problem is likely that ssh is offering that key first. Unfuddle probably accepts it for authentication (e.g. in sshd) but rejects it for authorization to access the company repositories (e.g. in whatever internal software they use for authorization, possibly something akin to Gitolite). Perhaps there is a way to add your personal key to the company account (multiple people are not sharing the same corp_rsa public and private key files, are they?).

[More...]

* * *

Google OpenID URL

I’ve always thought that the URL for my Google OpenID were something like http://google.com/account/RaffaeleSgarro. Instead, it turns out that when a site request that URL to sign up (and in the case it doesn’t provide a Google icon), you can simply enter

https://www.google.com/accounts/o8/id

and it will redirect you to the Google server to confirm the authorization, and then back to the original site

* * *

* * *

XPath and namespaces

Let’s consider the following XML

<?xml version="1.0" encoding="UTF-8"?>
<notes>
   <note>
      <heading>Remember the milk</heading>
      <body>Don't forget me this weekend!</body>
   </note>
   <note>
      <heading>Call Anna</heading>
      <body>Don't forget me this weekend!</body>
   </note>
   <note>
      <heading>Feed the trolls</heading>
      <body>Don't forget me this weekend!</body>
   </note>
   <note>
      <heading>Hooray!</heading>
      <body>Don't forget me this weekend!</body>
   </note>
</notes>

[More...]

* * *