Ubuntu Day

Spanish only: GNU/Linux, Guía de Supervivencia – Versión Ubuntu Day

Released under WTFPL if you care to know. Source code to be available soon too.


CM WTF

Seen on a cablemodem’s configuration page:

<form action="http:/loginData.htm" method="GET">
Long version: The other day, while stranded on a CLI (using ssh) I did a wget $IP, to see a modem’s status web page. I’d have thought an electronic device (which, obviously, is much more difficult to upgrade than a software product, and that’s difficult enough as it is) is a little bit better tested than that. I should have known better by now. comcast_cablemodem

sed magic: a simple guide

The other day I had to create one of those “enum to string” functions. They really suck, always getting out of sync, so I made a script to auto-update the header file containing this function… just add a target to the makefile and you’re done! 11Sed

Anyway, this is the part of the script I came up with to get the enum elements:


cat enum_definition.h | sed -n ‘/enum OID/,/};/ s/(.*)/1/p’

Nice voodoo, isn’t it? How the hell are you supposed to understand that? Well, you’re not, sed is write-only-code, but you can try reading http://www.grymoire.com/Unix/Sed.html#toc-uh-25, a great sed introduction.

Have fun!


gdb: graphic (tui) mode

A little known fact about gdb is that you can use it in graphics mode, called TUI. Yes, you can obviously use DDD or a similar front end but that’s not even nearly as cool as using a console based GUI (!), is it? 343px-Escudo_de_Tui.svg

The easiest way is to start gdb like this:


gdb -tui

That will display the usual gdb console plus a code listing, similar to the code listing you get using the “list” command but shown in another window. Alternatively you can press C-X C-A (both, in that order) while in gdb to switch between TUI mode and back.

Don’t know enough about gdb? Read http://beej.us/guide/bggdb/, a great gdb intro.


First Ubuntu Day in Buenos Aires

On sat. 26 of september, this saturday, I’ll be on the first Ubuntu Day in Buenos Aires. Of course, I’ll be a speaker there, it’s time to undust the old GNU/Linux Survival Guide Again.

simpTHOH_Survival_v5_72

See you @ Ubuntu Day 🙂


Vim Tip: Rot 13

vim_editor Are you still puzzled by last week’s C++ question, yet you are too lazy to actually search for a Rot13 decoder OR use gcc to check if it works? Well, Vim can do the trick, just use g? to convert text to Rot13

You may combine it with block selection or you can just convert the whole damn thing using “ggg?G”. gg goes to the beggining, g? converts to rot13, G goes to the end.

This is all very nice but I’m still trying to figure out a way to convert back from rot13 to normal text, can anyone provide a clue?


Console foo: Scheduling commands

You can easily schedule a command using “at”, which recognizes a nicely formatted date string. For example:

$ at today 3:00 AM

This will open a prompt. So, for example:

$ at today 3:30 PM
&gt; wget foobar.com/a_huge_file
&gt; C-D

Will schedule a download of a huge file, today at 3:00 AM. Nice, isn’t it?
To check the whole list of accepted formats check the man for at.

At-at

One last note: at will “remember” the current environment variables, so PWD, USER, OLD_DIR and all that will be the same. This means if you schedule a command with a relative path it’ll still work!


C++: incredibly useless stuff

Would this compile? What does it do?

int main() {
    http://nicolasb.com.ar
    return 0;
}

Answer in rot 13:

Vg jbexf. uggc: vf n ynory, // vf n pbzzrag, gur erfg bs gur yvar vf vtaberq.
</center


Nice Ubuntu fonts + Vim Tip

manuscrito It’s not unusual to hear someone complain about Ubuntu fonts. Apparently they are ugly. I guess that depends very much on a personal opinion, however not everyone knows there are alternative fonts in the common repositories (I think multiverse even has non-free fonts ported from Windows).

Someone recommended me Inconsolata as a nice programming font (it’s monospaced). I’m using it right now and it’s not bad. Let’s see how can you install it:

sudo apt-get install ttf-inconsolata

incoshow

Easy and it looks even better when used with gVim. You can go to Edit > Select font to change the font preference, however this won’t set a new default for the next time you start gVim. To do this we need to add it to the .vimrc, and again, to do this we need to know the font’s name.

Type “:set guifont?” to see the font’s name. In my case it’s “Inconsolata Medium 14” (I changed size and type). Now add the following to your .vimrc:

if has('gui_running')
     set guifont=Inconsolata Medium 14
 endif

Notice I added a backslash before the spaces, otherwise Vim will try to parse Medium and 14 as separated parameters to “Inconsolata”, which obviously won’t understand. Have fun with your new fonts.


non-vacations

After some sick time, lots of work, prepearing my new blog (monosinfinitos.com.ar, go check it) and several other,personal stuff regular blog updates will resume tomorrow and continue at least for a week. That’s about the buffer size I’ve left, after that I’ll have to write something new or take a longer vacation… we’ll see.

In the meantime, enjoy a pretty picture.

inf.3.9.dore