Saturday 9 October 2010

Usefull windows batch script to convert all files in directory using ImageMagic

This little snippet desaturates, resizes to half and converts to png all files in given directory using ImageMagic.
F:\Canon\Textbook>for %file in (.\*) do convert %file -resize 50% -modulate 100,0 %file.png
Make sure that path to ImageMagic binaries is in your PATH environment variable.

Monday 13 September 2010

Issues of Upgrading memory on DELL Inspiron 640m

Recently my relative asked me to upgrade memory on his DELL Inspiron 640m notebook.
Gladly an offer of compatible RAM modules can be easily found on ebay.
The specs of compatible RAM are DDR2-667 PC2-5300 200 pins SODIMM and DDR2-533 PC2-4200 200 pins SODIMM (2x1Gb is maximum for Inspiron 640m).
Naturally I chose the fastest one.
New Kingstone modules came after 2 weeks of waiting, and THAT IS very reasonable time to deliver from Hong-Kong to Moscow, Russia.
It took time to plug in 2 modules, cause Module A is not so easily replaced as Module B. The dock of Modules B is situated under the bottom of the laptop. To reach Module A one should remove hinge cover and the keyboard (btw some samsung laptops have both modules under the keyboard).
The disappointment came after both modules were installed.
Memory speed showed as 533 both in Windows and in Bios setup.
After some googling (you see it's hard not to find needed info on the net today) the answer came out.
This laptop model is shipped with one of two processor types. The fastest one supports 667Mhz RAM and the other supports only 533Mhz. Pity that my relative had the second one.
So if you ever have to choose between compatible RAMs for your laptop first check if your CPU really supports desired RAM speed.

Friday 3 September 2010

CB Compiler speed up and Total Commander as Horisontal Diff Tool

Today's post is about application of some tools.

First one is patching of Borland C++ Builder 6 with Andreas Hausladen's C++ Compiler Enhancements. Andreas has various patches and fixes for Borland, Codegear and Embarcadero products on his personal page. This particular one speeds up compilation of C++ projects by the direct call of the compiler with appropriate arguments. Original call to the compiler that the IDE makes for some reason takes much longer than the direct call to bcc32 from command line. Patching forces IDE to use the direct call. In addition this patch makes it easier to make use of precompiled headers, which can speed up compilation even further.
So it's definately recomended to install this patch.
Older versions (5 and 6) of BCB are not officially supporthed, though it's still possible to patch these IDEs. As I understand there's just no more guarantee that everything will go fine with BCB 5 and 6.
Btw another option to speed up compilation is to use RAM-disks, as suggests Kudzu. I have not tried it by myself, but hope to put my hands on it and cover results here.

Anoter useful applience is using of Total Commander to compare files in the horisontal split view.
When faced the need to compare two files with long lines, I started to search the web for diff tool that offered horisontal split. In fact I searched for some free tool. To my surprise according to Wiki there were only a few such tools. Namely:
  • ExamDiff Pro (shareware)
  • jEdit (java editor)
  • Ediff (part of emacs)
  • and... Total Commander (not free but an already licensed one)
It took only half a minute to find Comparison command in TC's menu, to select files and to switch to the horisontal view. Yet another appliance of the great file manager.

Sunday 22 August 2010

Focused browsing: limiting open tabs

Last week I've been intensively searching for some info related to the current project. As a result at the end of week there were two firefox windows with about 50 tabs opened in total. Most of them were there just to remind of some related info, which I intended to read later.
If you ever had so much tabs to read in your face, then you know that it can be "a little" frustrating.
At that time this post on lifehacker about rebuilding attention came out.
It mentioned 'No More Tabs' Chrome extension which prevents too many tabs from being opened at the same time.
Searching for extension with same functionality for firefox (again through lifehacker) gave a link to 'Window and Tab limiter', which does exactly the same. In addition it counts not only tabs but windows too.
When you open a new tab and hit your limit it asks you to close one of opened tabs/windows first.
I set my limit to 7 tabs. Two of them are always the the same AppTabbed goosh.org and gmail.com. Now it takes some time to think what tab to close, but at least there is no more 50 opened tabs in my face.

Sunday 15 August 2010

Installing Delphi components on BCB6

Today I've been installing CoolTrayIcon components on BCB6.
I've done it once, but totally forgot how I managed to do it.
The install.txt sais:
1. Select "New Component..." from the menu
2. In "Ancestor type", select "TTrayIcon  [trayicon]"
3. In "Class Name", type "TCoolTrayIcon"
4. In "Palette Page", type "Tray Icons" (or another tab you want to install to)
5. In "Unit file name", select "RegisterTrayIcons.pas" (which is found in the
   CoolTrayIcon package). Also, include CoolTrayIcon.pas and TextTrayIcon.pas,
   or you might get an error regarding "IMGLIST.OBJ".
6. Click on the "Install" button.
If you do exatly that you'll finish with a bunch of linker errors. Particular one is
Outline::TCustomOutline::~TCustomOutline()' referenced from C:\PROGRAM
FILES\BORLAND\CBUILDER6\LIB\BCBSMP.LIB|.\cdiroutl.cpp
Not very straightforward googling results in the following solution:
 this is quite common when installing Delphi components into BCB. You
need to add bcbsmp.bpi into the 'Requires' part of the package. (It's
in the small 'Package' window under 'Requires')
I figured out a way to eliminate the above error message.
add...
..\CBUilder6\Lib\Debug\vclx.bpi
The Pascal component probably 'uses' a VCL sample component. This is a
tricky area for Pascal component usage in BCB as BCB comes with native
C++ sample VCL components and by-design excludes the native Pascal VCL
sample components.
Once I've done it everything went fine in my work environment.
But today I went into another linker error when trying to repeat installation in my home environment:
[Linker Fatal Error] Fatal: Unable to open file 'c:\PROGRA~2\BORLAN~1\Projects\Lib\cooltrayicon.bpi'
Again googling resulted in
Yes, BCB wanted to create files in the folders Projects\Lib and
Projects\Bpl which didn't exist
At last creating Lib directory under Projects resulted in successfull install.
Damn! So wast amount of time was spent just to install one component!

Thursday 5 August 2010

When implementing some complex logic in SQL try first to think in terms of sets and relations.
Think of procedural way only when you definately cannot manage only with sets and relations. Using analytic functions and simple relational operators leads to more straightforward and error-free way of doing tough things then writing complex stored procedures.
Plus debugging stored procedures is not always convinient when dealing with large amounts of data.

Wednesday 4 August 2010

SQL loader hangs when you have uncommited changes on tables you're trying to load to.

Monday 2 August 2010

Sometimes you would prefer to use database engine to pass information between threads.
Idea from Multithreading - The Delphi Way. Martin Harvey.

Tuesday 8 June 2010

Shell script to convert all files from 866 to cp1251 using iconv.

#! /bin/sh
for f in ../mac/*.mac
do 
 cp $f $f.old
 rm -f $f
 iconv -f 866 -t CP1251 $f.old>$f
done
rm -f ../mac/*.old
Find version:
find . -name '*.txt' -exec iconv --verbose -f windows-1252 -t utf-8 {} > {} \;

Friday 28 May 2010

Replace text in multiple files

A simple perl command to replace all occurencies of 'RESULT_FAILURE' with 'RESULT_FAIL' in all *.sql files in current directory:

perl -pi -e 's/RESULT_FAILURE/RESULT_FAIL/g' *.sql