Category Archives: tips

The Scary Programming (Variable Names)

terror

Ranting is not my favorite way to express, I’m more like a constructive guy. But also, the blog is a reflection of what I’m doing right now. And for the title of the post you can guess I’m not doing a lot of GIS.

Lately I’ve been spending my time reading some questionable code, which made me think about the habits of programming. There’s no exact science here, but it is true that bad handled code can explode really fast creating a series of problems.

  • Maintenance hells.
  • A bug fixed, uncovers another bug.
  • Hard to get somebody up to speed.
  • Lots of snorting (iup that’s me).
  • Clear increase of gray hair (iup, that’s me).

I started drafting a post about this topic. Then, it exploded in size. So I decided to split it in digestible bits of enjoyment.

The original title was: The Code Apocalypse but I settled for something milder because… that’s my style :-D.

Variable Names

Leave a comment

Filed under code, tips, TSP

Quick Replace

This one is going to be short, it is something that would fit better under commandlinefu, tips and tricks!

What do we want to do?

Look for al the cpp files under a directory and modify all the text with foo to bar.

How to do it?

First we find all the cpp files under the current directory
find . -name "*.cpp" -print

And a possible command to replace from a file is using sed.
sed -i 's/foo/bar/g'

We just have to connect those two together to replace in all the files with a name ending in .cpp, that’s what pipes are for.
find . -name "*.cpp" -print | xargs sed -i 's/foo/bar/g'

Ta-Dah

Leave a comment

November 1, 2014 · 6:35 pm

The monster environment

LaTeX_logodnd

As I commented, I am working on a Dungeons & Dragons (D&D) \LaTeX class to write small adventures.

Objective

The monster environment should deal with creating the corresponding table and all that it is necessary. A monster has a set of attributes (common to all monsters), and a set of powers different to each monster. In D&D 4e this is typically presented in a table, which I think is the best possible presentation.

Typical d&d 4e monster stats table.

Typical d&d 4e monster stats table.

Stats generated with the LaTeX class

Stats generated with the LaTeX class (There is a small error).

let me see

3 Comments

Filed under code, documents, tips

Python: Command Line waiting feedback. And some Background on why!

4.2.39 Escape sequence
A string of bit combinations that is used for control purposes in code extension procedures. The first of these bit combinations represents the control function ESCAPE.
ECMA-48 Control Functions for Coded Character Sets

more

1 Comment

Filed under code, curious, tips

ModernCV


My time at ITC is temporal, since my current CV dates from 4 years ago (I was not even a computer engineer) it’s time to prepare another one.

Show me the code!

1 Comment

Filed under code, tips, tools

Trailing Whitespaces Vim

Trailing whitespaces are a pain in the ass. Adding, deleting and modifying code can lead to invisible spaces at the end of the line. This is “bad” and useless.

Here comes Vim!
:%s/\s\+$//

A substitution command :%s/<search>/<substitute>/
Where the search is for trailing whitespaces \s\+$ and the substitute is “nothing”.

Writing this every time is too much effort, it’s a good idea to define a user command:
:command Deltw :%s/\s\+$//

Or better, add the line to your vimrc file:
command Deltw :%s/\s\+$//

now just typing the command Deltw deletes those annoyances.


References

Vim patterns ⇒GO
Vim user_commands manual ⇒GO

Leave a comment

Filed under tips, vim