Archive for Uncategorized

Unix tools always work. Even when Windows ones don’t

In the video above, you can see, that we cannot drag and drop a file onto a PowerShell script. Conversely, we can easily do this with bash script having installed Git for Windows.

I needed to perform some trivial conversion within a SQL script, i.e. replace ROLLBACK with COMMIT. I thought I would implement it with PowerShell. I am not going to comment on the implementation itself, even though it turned out to be not that obvious. Then I realized, it would be nice, if I could drag and drop a file in question to apply the conversions on it.

This does not work with default configuration of PowerShell. I did not have time to hack it somewhere in the registry, as I assume it is doable. I switched to old, good bash shell instead.

It’s a pity I couldn’t do that with Windows native scripting technology. It is very interesting, that MinGW port of shell has been so carefully implemented, that even dragging and dropping works in non-native environment.

I recall the book Pragmatic Programmer: From Journeyman To Master. There is a whole subchapter about the power of Unix tools. The conclusion was, that over time we would come across plenty of distinguished file formats and tools to manipulate data stored with them. Some of them may become forgotten and abandoned years later, making it difficult to extract or modify the data. Some may work only on specific platforms.

But standard Unix tools like shell scripting, Perl, AWK will always exist. I should say: not only will they always exist, but also they will thrive and support almost every platform you can imagine. They work on plain text, which is easy to process. I am a strong proponent of before-mentioned technologies and I have successfully used them many times in everyday work. It sounds particularly strange among .NET developers, but this what it looks like. The PowerShell simply did not do the trick for me. Perl did. As it always does.

For the sake of the future reference I am including the actual scripts:

PowerShell script:

Bash script running Perl:

Bringing old projects back to life: RGBgen XP

The original application was written back in 2001 in Visual Basic 6. It is quite trivial application (despite the fact, that when I first created it being a kid, for me it was not). It is intended for easily creating hexadecimal RGB codes using sliders. I know, there are plenty of similar tools, also inform of online apps. HoweverI still like the “mechanics” of the UI and its simplicity. It turns out, that I still need it.

However, the originally compiled executable does not work on modern Windows system. I decided to check if it is possible to fix this. I took my Visual Basic 6 installation CD, started snapshotted virtual machine running Windows XP and opened source project files. The application had simple HTML editor and used a few really esoteric OCX controls. In fact, they were not essential for the application’s core functionality. After removing unnecessary references from the project and disabling some of the UI components, I recompiled the source code so that it uses only “out of the box” Visual Basic libraries. The Windows operating system includes Visual Basic 6 runtime DLL even now and finally I managed to run the application on my Windows 7 64-bit machine.

If you want to give it a try, you can download it from my Skydrive


Hello world!

Welcome to my main technical blog! Recently I have decided to diverge my concept of blogging. On this blog I will publish all new technical articles only in English. My old blog — still exists, but only less important, Polish-specific articles will be published there. There are several reasons why I decided to build a new blog. Firstly, target audience is incomparably bigger for English content. Secondly, the old platform — is real pain in the neck. It has many limitations and it is just inconvenient. Therefore, installing and starting own, decent platform such as WordPress is an obvious choice for any non-amateur writer.