syntax highlight

Thursday, 21 May 2009

A case for LaTeX

So, after struggling with you word processor to get an acceptable format you decide to hunt the repos (you're using Linux, right?) for a better alternative. We already know why would you choose LyX but why would you choose LaTeX?


Let's begin by listing some of its advantages

  • Wide range of applications - LaTeX is a widely used format, with lots of years, users and fields of application. It's not used only to create papers or just presentations, it can be used in a wide range of applications.
  • There are "packages" prepared for each type of document - related to the previous point, you can find packages to create a CV, a presentation, posters, etc.
  • No need to format every single element - everything comes with a reasonable default format. You may fight a little bit whenever you need to change the default format (though you'll find it less necessary each day) but 90 percent of the time "it just works". With regular word processors it's usually the other way around (it is for me!)
  • Works from a console - OK, this may be an advantage or a disadvantage, according to whom you ask. It sure is an advantage for us, the crazy console people, who don't like to drop the CLI just for a couple of slides.
  • Great templates - no need to work in the design of the documents, that's already taken care of.
  • Plain text format - easy to integrate with any source code management system.
  • Easy to integrate with external media (images, for example) - did you just change that image? No problem, just "recompile" to get it on your document.
  • The best math system

It has some downsides too

  • Steep learning curve
  • Requires some familiarity with the console
  • There's a lot of markup to learn - this can lead to a low signal to noise ratio for some packages like Beamer and the need to RTFM more often than usual.
  • Creating a LaTeX document requires certain syntax - it's not quite like programming, but programmers will be much more comfortable around it
  • Weird error messages - the LaTeX compiler will create an enormous amount of output and error messages may not allways be easy to comprehend.
  • It's a one way ticket - you may be Word - impaired for the rest of your life

Who should use LaTeX?

As previously stated, programmers will be more comfortable around plain LaTeX but that's not the only pre requisite - you should be somewhat familiar with the console in Linux (no idea about LaTeX on Windows) and have some patience to read a couple of manuals. Once you have mastered the basics it's much easier, so don't get discouraged.

If you feel you don't fit the profile perhaps LyX is a better alternative than plain LaTeX; it's very easy to use and quite user friendly. It won't be that great for presentations and other, more "advanced", documents though.

What kind of work can you do with LaTeX?

That's an easy one, check My Articles section for some examples. You can create any kind of document but it's better suited for those in which you care most about the content and don't want to get bogged down with pesky design details.

Editors

Last (for this entry) but not least, what editor can you use to create LaTeX documents? Well, LaTeX is basically plain text so any editor will do. There are some LaTeX-specific editors, I like ViM myself. There'll be a complete post dedicated to LaTeX + Vim, coming soon.

This article will be the first in a series of LaTeX survival guide so stay tuned.

Tuesday, 19 May 2009

apt-get install new computer III

Check the other two parts of this series:

I recently updated to Ubuntu 9.04 and had to reinstall my work computer. Since the stuff I use for work (mostly c++ programming) was left out in the previous two posts I'll post it here:

  • Install build tools:
    sudo apt-get install g++ gdb build-essential g++-4.2 omniorb4 omniidl4-python omniidl4 libxerces-c2-dev
  • Can't live without VIM:
    sudo apt-get install vim gvim vim-common vim-doc vim-full vim-gnome vim-gtk
  • Some additional tools:
    sudo apt-get install ddd devhelp doxygen doxygen-gui exuberant-ctags ctags  subversion
  • Install bandwith monitor:
    sudo apt-get install ifstat
  • Don't you hate when you need to read an Office document while working on the console? Me too, try antiword:
    sudo apt-get install antiword

Done, a couple of apt-get's and you are ready to build your c++ projects! (Ok, actually only the first one is needed, the others are nice-to-have programs).

Thursday, 14 May 2009

Everything is a file A.K.A. Battery state on Linux

I present to you the latest release from Wheel Reinventions Inc. - Already Invented dept. - a script to check the remaining battery time from Linux console.







echo -n "Hours remaining: " 
&& echo "$(cat /proc/acpi/battery/BAT0/state
     | grep 'remaining capacity'
     | awk '{print $3}') /
   $(cat /proc/acpi/battery/BAT0/state
     | grep 'present rate'
     | awk '{print $3}')"
   | bc -l


Yes, I was bored, so? I'm planning to release a new bogosort implementation after this one, what do you think?

Jokes aside, this nifty script shows how flexible can be the model "everything is a file" which Unix-y systems implement. With a couple of pipes (and an almost magical incantation for those uninitiated in the console cult) you can do lots of stuff with very little work

This concept could be associated with the way polymorfism works in a programming language, but that's an entry for another day.

Tuesday, 12 May 2009

LaTeX!

Some time ago I wrote a review about LyX for DPOTD (recommended link) and now I think it's time for an update: what can you do when LyX is not enough?


I'll quote myself; the original article ends (almost) like this:
What LyX isn’t for

Although LyX may be a valuable piece in anyone toolkit it’s worth noticing it isn’t exactly the Swiss army knife of the text editors. If you need to define a very customized layout or format, like slides for a presentation, this is the wrong tool for the job.

After having prepared several presentations with LyX (even my CV!) I'd like to write some more on this last part. Even if I thought that my original comment was mistaken I write once again the same: when you have to create a presentation LyX is not the tool for the job, LaTeX is.

As I explained in that article, LyX is a front-end for LaTeX but at the same time it's only a small part of LaTeX. Doing several presentations in LyX (using Beamer, a package I'll talk about in another post) I noticed that most of my documents where "ERT", evil red text, which is nothing else than plain TeX code: that means, each time more, I was using LaTeX functionality not available from LyX. This is the reason I've decided to write a how-to LaTeX, a small survival guide for those want to start using with the tips and tricks I've learned in this time.

The target for these posts series will be, mainly, programmers or other advanced users, without fear of working a little bit in the console, markup languages and maybe a makefile.

Soon the first part :)

Thursday, 7 May 2009

Vim Tip: Visual Mode

There's normal mode, command mode and a third, less known to the beginners, visual mode. What's this mode about?

Using Vim on visual mode can make some rather complex tasks and regex operations go away with a couple of keystrokes and it's as easy as selecting the text you want with the cursor.

Move your cursor over the first part of the text you're trying to select and press Ctrl + V to set Vim to visual mode, then move the cursor to the last part of the text you're trying to select (it works in blocks, not character by character nor line by line... try it, it's easier than it may seem).

What can you do after selecting text this way? Pretty much anything else you'd do with normal text, like cut (x) and paste (p). This is specially useful when working with formatted text (i.e. programming).

Visual mode can also work with lines (use Shift + V instead. Notice the uppercase V) and with other modes; check the manual for more information.

Tuesday, 5 May 2009

Fixing keyboard problems in Ubuntu J.J.

I recently metioned in my Ubuntu J.J. review I was experiencing some issues with the keyboard in Opera. Well, the solution is simple, though not easy to find: the culprit was a missing language pack.

While installing the OS I didn't have Internet connection (the Squid server died and left me with no repos to work with after installing) so it didn't download some required language files, thus screwing up non Gnome programs (Opera, in my case).

To fix this problem go to System > Administration > Language Support (1) and a notification should pop up if there are packages missing; install them and then uncheck "Use Input Method Engine ..." (2), then restart the session.

Everything should work fine now (áéíóú :)).

(1) Sistema > Administración > Soporte de Idiomas
(2) Usar motores de método de entrada (IME) para ...

Monday, 27 April 2009

Vim Tip: Find Next

In normal mode, move the cursor to any word. How do you search for the next occurrence of that word?

Press the * key to search forwards for the current word, or press # to search backwards.

Using * or # searches for the exact word at the cursor (searching for rain would not find rainbow).

Use g* or g# if you don't want to search for the exact word.

Ubuntu J.J.

I've been using Ubuntu 8.10 for couple of months and soon began to think about switching to Debian or some other - more stable - distro. At work Ubuntu 8.10 seemd too unstable, with frequent crashes and slow. Instead of switching I decided to upgrade to 9.04 soon after its release, something I've always avoided (best to wait for a couple of months, until it gets more stable. Even better if it is an LTS). So far I must say this is the best Ubuntu relase I've seen.

Some highlights after the first couple of days:


  • The install was flawless and quick. In fact I didn't even see it install, just left it running and went to another PC to install 8.04 (I was at FLISOL) and came back to a fully functioning system.

  • Configuring my dual monitor setup at the office required some work but not more than 8.04 and 8.10.

  • I'm still a little uncomfortable with the notification system but it's not worse than before (though I'm not sure if it's better).

  • Still having some problems with SCIM on Opera, not sure who's at fault there.

  • The boot times are FAST. In fact the whole thing seems fast and stable.

  • The graphics handling are improved. Compiz works much better, I can even run it with my dual monitr setup (something I couldn't do with 8.10).


All in all, a great release and a must upgrade for sure. Ubuntu FTW!

Thursday, 23 April 2009

FLISOL / Presentación

Con motivo del FLISOL voy a estar dando con Juanman (de GNUTN, el LUG de la UTN) una versión actualizada de la charla GNU/Linux: Introducción y Programación Gráfica (link al post original) que ya dimos en la UTN el año pasado, con muy buenos resultados.

La charla, que a pedido del departamento de marketing ahora se llama GNU/Linux: Guía de supervivencia, va a ser el sábado 25 de abril del 2009 en FM La Tribu, Lambaré 873, de 12:45 a 13:30 (link al programa completo). Dejo un link a la presentación que estaremos utilizando.

Quedan todos invitados!

Monday, 20 April 2009

Vim Tip: Using markers

Set a marker if you whish Vim to remember a cursor position Use m* to mark current position (use a to z for position names) and then '* to move to mark * (again, a to z).

This trick can be very useful when editing a large file (or lots of files) in case you need to quickly edit something and then return to the previous spot.

Thursday, 16 April 2009

FLISOL

Está abierta la inscripción para participar de FLISOL, Festival Latinoamericano de Instalación de Software Libre.

El Grupo de Usuarios de Software Libre de Capital Federal (CaFeLUG) abrió el registro para participar de FLISOL, el Festival Latinoamericano de Instalación de Software Libre, que este año se realizará el sábado 25 de abril, de 10 a 20 hs. en FM La Tribu, ubicada en Lambare 873, Buenos Aires.

Mas info: http://flisol.net/FLISOL2009/Argentina
Mas info II: http://www.cafelug.org.ar/modules/news/

PD: Voy a estar dando una charla en el FLISOL :D

Friday, 27 March 2009

Vim tips: Using macros

Clik-click tap, clik-click tap, clik-click tap. A team mate is performing some kind of repetitive operation with text and it's becoming more and more annoying. Good news, there's a way to keep your mental sanity and help this guy to be more productive: replace him with a sed/awk script teach him how to use Vim macros!

Vim macros can repeat for you a sequence of commands. Press qq to start recording, then q again to stop. Use @q to execute a macro. Let's try it:

This - random garbage
is - random garbage
a - random garbage
sample - random garbage
text - random garbage

So, how would you get rid of the random garbage? Move the cursor to the beggining of the first line, press qq to start recording then f- to move the cursor to the dash and d$ to delete the rest of the line. Now move the cursor to the begging of the next line (0j) and press q to stop recording. Now press 4@q to repeat the macro for times and check the results; you should have something like this:

This
is
a
sample
text

Neat, huh? You can also store any number of macros using a different letter after the q to start recording, for example qn to record and @n to execute. Also, use @@ to execute once again the last executed macro (from any buffer).

There are some more things you can do with macros (like editing before executing one) but the best source for that is the manual.

Monday, 23 March 2009

Valgrind - OCI: Suppressions file FTW!

Update: There's a new Valgrind suppressions file @ this link.

Working [1] on a C++ project with Oracle I found that Valgrind reported lots of warnings related to OCI, for which, regardless of being false positives [2] or not, there's little I can do about (other than migrating to MySQL, that is). As the error report kept growing I found that Valgrind will refuse to keep track of new errors after a million or so:

More than 1000000 errors detected. I'm not reporting any more. Final error counts may be inaccurate. Go fix your program!

The solution in this case is a suppresions file for Valgrind. After spending a good deal of time unsuccsesfuly trying to get one I had to do it myself and upload it for the next one to run into this problem:

Link to the file: Valgrind / OCI suppressions.

Saturday, 14 March 2009

Vim tips: Moving the cursor to a letter

Let's face it, Vim is the best editor in the world, and from now on there'll be a spot in the homepage with a "Vim Tip of the Week" (check the sidebar).

For the first one a basic tip: Moving to a letter

While in command mode press ' f' and any other letter; the cursor will move to the first occurence of this letter. This can be combined with other commands and a number of repetitions (e.g. ' d2f.', to delete until the second dot).

As a sidenote, I guess there must be a Word Press plugin to display the latest post in a category but I coudn't find it, so I hacked my own: tip-of-the-week

Tip of the Week

I recently added a new plugin to display the latest post within a category; there must be another one out there but I coudn't find it, so I hacked my own. I plan to upload it to WP's plugin repository (some day) so I may as well use this post a man page (?)

  1. Download the plugin from // TODO

  2. Unzip / untar the file in wp-content/plugins

  3. Enable the new plugin

  4. Configure the category to be searched (in my case I used "Vim Tips") in the settings tab

  5. Add the plugin as a widget (or copy&paste the code as needed, it's in the readme)

  6. Post something within the new category, if there's nothing

  7. The excerpt from the post and its title will be displayed in the sidebar (or wherever you configured the new plugin)


Easy to use. Hope you like it.

Friday, 6 March 2009

Introducción a GNU Linux

Subo una presentación que usamos para dar una charla de introducción a GNU/Linux en la UTN a principios del 2008 con el grupo GNUTN, orientada al desarrollo. La charla salió muy bien pero todavía no hubo quorum para armar una nueva.

Link a la presentación (PDF)

 

  

También dejo link en la sección de artículos.

Monday, 2 March 2009

Valgrind FTW

Una presentación que armé para el trabajo con una introducción a Valgrind, herramienta para profiling y debugging, principalmente para C/C++ en Linux (es posible usarlo con otros lenguajes pero nunca probé): Link al artículo (PDF)

También dejo el link en la sección de artículos.

Saturday, 31 January 2009

Changing default shortcuts in gnome

Another of those thing I usually forget: changing default shortcut actions in gnome. In this case, I'm using MOC as my music player (see apt-get install new computer II and while it's great it won't integrate nicely with gnome. Fortunately (as most GNU/Linux applications do) it can be commanded via CLI so it isn't hard to change this.

Now, gnome keyboard shortcuts already have defined actions, so how can we change them to invoke  a custom command? Easy enough:
  1. Open gconf-editor
  2. Go to apps > metacity > keybinding_commands
  3. Set a command from the list. In my case I'm going to set command_1 to "mocp -S", command_2 to "mocp -f" and command_3 to "mocp -r"
  4. Go to apps > metacity > global_keybinding
  5. Set the corresponding run_command_* to the keyboard shortcut. For me that's 0xA2 for run_command_1, 0xE9 for run_command_2 and 0xEA for run_command_3; beware it changes between keyboards.
Troubleshooting tips:
  • If you use gconf-editor for a key binding don't use it again System > Preferences > Key bindings
  • For hex value keybindings (like the ones I used on the example) use uppercase
  • If it's not working and you can't figure out why try with an already working command and a simple keybinding (e.g. gnome-screenshot and ctrl-p) then change each one in turn, see where it breaks. Divide and conquer!!

Sunday, 28 December 2008

apt-get install new computer II

Ahora si, termino el post que empecé en apt-get install new computer (parte 1)
sudo apt-get install lyx

http://debaday.debian.net/2008/01/20/lyx-a-text-editor-that-stays-out-of-the-way/
sudo apt-get install tilda

Link a DPOTD
sudo apt-get install mmv

Link a DPOTD
sudo apt-get install unclutter

Link a DPOTD
sudo apt-get install katapult

Link a DPOTD
sudo apt-get install moc

Link a DPOTD

# SA tools
sudo apt-get install knetworkmanager xdiskusage iptraf sshfs apt-listbugs


# Media stuff: flv player, shnsplit/cuebreakpoints (flac), winrar
apt-get install ffmpeg shntool cuetools flac wavpack unrar vlc


# Conky, sensores y plugins
apt-get install conky libxext-dev lm-sensors build-essential checkinstall wmctrl


Casi terminó por ser un lista de links a DPOTD, jeje (y me juego a que los últimos también están pero no los busqué).

Tuesday, 4 November 2008

TDD

Testability Explorer: Measuring Testability



In order to unit-test a class, it is important that the class can be instantiated in isolation as part of a unit-test. The most common pitfalls of testing are mixing object-graph instantiation with application-logic and relying on global state.



-- Google testing blog

Soon: “Notas sobre TDD”, continuación de “Notas sobre metodologías ágiles”