Posts for 2009 March
Vim tips: Using macros
Post by Nico Brailovsky @ 2009-03-27 | Permalink | Leave a comment
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.
Valgrind - OCI: Suppressions file FTW!
Post by Nico Brailovsky @ 2009-03-23 | Permalink | Leave a comment
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.
- Working at Intraway :)
- False positives are quite likely when compiling with -O2. See Valgrind FTW.
In reply to this post, Mattias commented @ 2009-04-02T08:17:41.000+02:00:
Great work, just what I'm looking for - but where is the file? (the link seems broken)
Original published here.
In reply to this post, nico commented @ 2009-04-03T12:06:30.000+02:00:
Should have been a temporary glitch, anyway this is the file:
{ OCI suppression Memcheck:Cond fun:slpmloclfv fun:slpmloc fun:lpmloadpkg fun:lfvLoadPkg }
{ OCI suppression Memcheck:Value4 fun:ztced_einit fun:ztcedgks fun:ztcedi fun:ztcebi fun:ztcei }
{ OCI suppression Memcheck:Value4 fun:ztcedecb fun:ztcedencbk fun:ztceb_encblk }
{ OCI suppression Memcheck:Cond fun:CMP_Compare fun:CMP_ModularReduce fun:Alg_ComputeModQ_GHash fun:A_X931RandomGenerateBytes fun:ztcr2rnd }
{ OCI suppression Memcheck:Cond fun:CMP_BitLengthOfCMPInt }
{ OCI suppression Memcheck:Cond fun:CMP_CMPIntToOctetString }
{ OCI suppression Memcheck:Cond fun:CMP_OctetStringToCMPInt }
{ OCI suppression Memcheck:Cond fun:CMP_SubtractInPlace fun:CMP_ModularReduce }
{ OCI suppression Memcheck:Cond fun:ztvo5ke fun:kpu8lgn fun:kpuauthxa }
{ OCI suppression Memcheck:Value4 fun:ztceaencbk fun:ztceb_encblk fun:ztcebn fun:ztcen }
{ OCI suppression Memcheck:Value4 fun:ztceaencbk fun:ztceb_encblk fun:ztceb_padding }
{ OCI suppression Memcheck:Cond fun:kzsrepw fun:kpu8lgn fun:kpuauthxa }
{ OCI suppression Memcheck:Value4 fun:ztceai fun:ztcebi fun:ztcei }
{ OCI suppression Memcheck:Value4 fun:ztucbtx fun:ztvo5pe fun:kzsrepw }
{ OCI suppression Memcheck:Value4 fun:ztceadecbk fun:ztceb_decblk }
{ OCI suppression Memcheck:Cond fun:ztceb_unpadding fun:ztcebf fun:ztcef }
{ OCI suppression Memcheck:Cond fun:nassky fun:nszssk fun:nszssk2 }
{ OCI suppression Memcheck:Cond fun:_intel_fast_memcmp obj:* }
{ OCI suppression Memcheck:Overlap fun:_intel_fast_memcpy fun:kpufprow fun:kpufch0 fun:kpufch }
Original published here.
In reply to this post, Mattias commented @ 2009-04-03T20:57:40.000+02:00:
Thanks! Since I use x86_64 I had to switch all the 'Value4' to 'Value8', and I also had to add a few extra suppressions (below), but after that it worked just perfectly. Nice to be able to get 0 errors for all our oracle tests ...
{ OCI suppression - Mattias Memcheck:Cond fun:ztcedec fun:ztvo5ed fun:ztvo5ver fun:kpu8lgn }
{ OCI suppression - Mattias Memcheck:Cond fun:ztcebf fun:ztcef fun:ztcedec fun:ztvo5ed }
{ OCI auppression - Mattias Memcheck:Value8 fun:ztceadecbk fun:ztcebn fun:ztcen fun:ztcedec }
{ OCI suppression - Mattias Memcheck:Value8 fun:ztceaencbk fun:ztcebn fun:ztcen fun:ztvo5pe }
{ OCI suppression - Mattias Memcheck:Value8 fun:ztceaencbk fun:ztcebn fun:ztcen fun:ztceenc }
{ OCI suppression - Mattias Memcheck:Value8 fun:ztcedecb fun:ztcedencbk fun:ztcebn fun:ztcen }
{ OCI suppression - Mattias Memcheck:Cond fun:CMP_ShiftRightByBits fun:CMP_ModularReduce fun:Alg_ComputeModQ_GHash fun:A_X931RandomGenerateBytes }
{ OCI suppression - Mattias Memcheck:Param write(buf) fun:__write_nocancel fun:snttwrite fun:nttwr fun:nsntwrn fun:nspsend }
{ OCI suppression - Mattias Memcheck:Overlap fun:_vgrZU_NONE__intel_fast_memcpy fun:kpufprow fun:kpufch0 fun:kpufch fun:OCIStmtFetch2 }
Original published here.
In reply to this post, Nicolás Brailovsky » Blog Archive » Valgrind – OCI: Suppressions file, Take II commented @ 2010-02-19T11:14:33.000+01:00:
[...] my OCI suppressions file? Well, since then I have updated it. Now it includes some more suppressions, for libnetsnmp, [...]
Original published here.
Vim tips: Moving the cursor to a letter
Post by Nico Brailovsky @ 2009-03-14 | Permalink | Leave a comment
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
Post by Nico Brailovsky @ 2009-03-14 | Permalink | Leave a comment
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 (?)
-
Download the plugin from // TODO
-
Unzip / untar the file in wp-content/plugins
-
Enable the new plugin
-
Configure the category to be searched (in my case I used "Vim Tips") in the settings tab
-
Add the plugin as a widget (or copy&paste the code as needed, it's in the readme)
-
Post something within the new category, if there's nothing
-
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.
Introducción a GNU Linux
Post by Nico Brailovsky @ 2009-03-06 | Permalink | Leave a comment
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.
-- src
También dejo link en la sección de artículos.
Valgrind FTW
Post by Nico Brailovsky @ 2009-03-02 | Permalink | Leave a comment
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.