Nicolás Brailovsky


A modern blog

Archive for the ‘Uncategorized’ Category

Tech Support

author Posted by: nico on date Aug 24th, 2009 | filed Filed under: Uncategorized

Two comics this month, but I’m sure it’s worth it:

This advice would have saved me a couple years of life. Normal post tomorrow.

Something to add to your news reader

author Posted by: nico on date Aug 20th, 2009 | filed Filed under: Uncategorized

C++: Magic member callbacks

author Posted by: nico on date Jul 21st, 2009 | filed Filed under: Uncategorized
Short post about C++ this time – though calling it a request would be more appropiate. I’m trying to create some kind of magic callback to do this:

  1. class Caller {
  2.         Callback c;
  3.         public:
  4.         Caller(Callback c) : c(c) {}
  5.         void doit(){ c(this); }
  6. };

Shouldn’t be too difficult, right? There are some hidden complexities, of course, mostly regarding the callback parameter type, but the idea is simple, keep the caller dependant only in the callback, not in the callee.

Templates are not a valid solution as the callee may have more than one callback (i.e. expect more than a single object to finish and call the callback) so the whole idea of this is having the callback “bind” to a member method when created, doesn’t matter which one.

I have a solution, tough I’m not too happy about it for now. I’ll post it next week, unless someone comes up with a better idea (you know how to submit it if you do, right?).

cpp

self.uptime = 725328000

author Posted by: nico on date May 23rd, 2009 | filed Filed under: Uncategorized
Today it’s been 725328000 seconds of uptime since I was promoted from Release Candidate to V1.0. Still waiting for security updates though. new-super-mario-bros

Vim tips: Using macros

author Posted by: nico on date Mar 27th, 2009 | filed Filed under: Linux, Uncategorized, Vim Tips
vim_editor 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.