Room of a pleinolijf

Ask yourself this: how do I want to be remembered ?

1 Comment

Deleting Files and Folders With Paths/Names That Are Too Long for Windows

As a follow-up on the previous post, I found a better alternative to do this if you already use node.js. There’s a util available on GitHub, called rimraf, that seems to exist purely to help you and me out with this irritating problem (on a Windows machine).

And it’s easy-peasy. Simply open your favourite node.js prompt (I like to set up everything in the excellent Cmder, btw), and install rimraf like so:

npm install -g rimraf

Then, to actually see the ‘magic’ happen, execute:

rimraf <directory_to_delete>

Could it be any easier ?



Unable to Delete File when Source Path Name Too Long

I regularly suffer from this annoying Windows treat: being unable to delete files that are located in a path which name is too long. Specifically, this occurs on files created by Node.js. Maybe that might be the reason. But it’s still illogical, since the file was allowed to be written by the OS in the first place.

2015-06-02 12_39_43-path name too long at DuckDuckGo

An example: C:\SourceTree\dso\node_modules\grunt-spritesmith\node_modules\spritesmith\node_modules\pixelsmith\node_modules\get-pixels\node_modules\ndarray-pack\node_modules\cwise-compiler\node_modules\uniq\test

You would want to do that if you want to ‘clean’ your npm install folder, for example.

With tips and tricks suggested on support forums, -at least in my case- I was unable to delete this file/folder. Nothing will work, not even an Adminstrator PowerShell console.

The only solution ? 7-Zip. Yep, that’s right, the popular compression tool. When you do Shift-Del (bypassing the Recycle Bin), it actually uses it’s own internal file engine to delete the files, instead of hooking into the operating system. As a bonus, it deletes the files faster as well.

How ? Simply open the 7-Zip File Manager, and navigate to the big bad folder (containing the files) in question. Select what you want to see gone, and press Shift-Del. Done and done.

Leave a comment

Alphabetical Regular Expression for Non-English Languages

Just a quick tip I want to put out there. Whenever you need to match alphabetical characters using a RegEx in an environment that will contain non-english languages (which have diacritics like à, é, õ, Ü, ç, etc…) you can do so like this:


By the way, don’t make my mistake of shortening it to :


Because that will include a number of special characters like the dollar and ampersand signs.

You can use the pattern as an input filter to disallow any characters that are not alphabetic (but allow an apostrophe and a whitespace for example):


Leave a comment

Be wary of closures when using delegates

Just recently, I got caught out by a closure.  A closure is a piece of code that can be ‘executed later’, while still retaining the environment in which it was created.  A lot of developers mistakenly think anonymous delegates, like lambda expressions, are by definition closures.  They can be, but don’t have to (and usually aren’t).

I’ll illustrate with the actual code snippet that caught me out.  Unfortunately, at my current client, I can’t make use of the excellent Visual Studio add-in ReSharper, which would have alerted me on this with a “Access to modified closure” warning.

foreach (string keyword in keywords)
   ToolStripMenuItem keywordTsmi = new ToolStripMenuItem(text: keyword, image: null,
      onClick: (sender, e) => Clipboard.SetText(keyword));

In this bit, I am filling up a context menu with new sub menu items, containing keywords that are copied to the clipboard when clicked on.

Obviously, this compiles just fine, and the submenu is correctly filled with all the distinct keywords.  However, no matter which keyword you click, it would always copy the last keyword in the list.  With this functionality being not-very-much-in-your-face, it slipped through (user) testing.  I’ll be the first to admit we need more unit tests 😉

The solution is dead-simple:

foreach (string keyword in keywords)
   var keyw = keyword;
   ToolStripMenuItem keywordTsmi = new ToolStripMenuItem(text: keyw, image: null,
      onClick: (sender, e) => Clipboard.SetText(keyw));

By assigning the value to a local-scope variable, the compiler will save a separate reference for each keyword, instead of only one that gets modified with each loop (hence the ReSharper warning).  Because the latter is simply the standard behaviour when you use a delegate with a variable like that.

Leave a comment

Suppress Compiler Warnings in Visual Studio

Just a quick post to put this out there.  Chances are you already know of this, but I can imagine far from everybody does.


When building a project or solution, Visual Studio will report on what’s happening in the Output window.  (By the way, you can control the verbosity of said window in the Tools – Options… – Projects and Solutions – Build and Run screen.  And the first thing I do on a new system configuration, is enable the ‘Show Output window when build starts’ option in the screen before that.)  It will print informational lines of text, but also, and more importantly, warnings and errors while compiling.

Obviously, your attention should be focused on the errors, as they will likely prevent you from running your application.  Call it neurotical behaviour, but I always aim to have an as clear Output window as I can, so the warnings receive equal attention from me (although not as diligently of course).

But sometimes warnings will keep being generated by Visual Studio, even though you intentionally wrote the code the way you did.  An example can be fields that are declared and assigned, but only used in a

#if (!DEBUG)

statement, like a bunch of license key registrations meant for production.



To keep the warnings from always popping up in the Output window when building, use the #pragma preprocessor directive.

#pragma warning disable 414, 3021

You can get the warning numbers by building  your code. If you can’t or won’t, you can also wrap the code in question in a

#pragma warning disable


#pragma warning restore

‘block’. This will disable all warnings in between, so use with caution !


PS: VSCommands by Squared Infinity is a great extension for VS that will color-code the lines in the output window to increase readability.  You can even define your own custom formatting.


How changing my blog’s address was a bad idea, and a reflection on blogs vs social media

I changed my blog’s name (and corresponding URL) around september 2012, because I had come up with a half-decent alias to use globally (on Twitter, this blog, handles in games, on forums, etc…). pleinolijf is an anagram of my real name, and it’s a word that ‘could’ exist in my native language, as in it’s linguistically correct; it’s a concatenation of two existing words.

Anyway, I wanted to change as many logins and usernames as possible so as to have a uniform, global name to use with online services, including my WordPress blog.

I only noticed this a few days back, as I haven’t been very actively blogging since the beginning of 2009. Up until then, my blog was averaging about 2,000 visitors a day, even when quasi no new content had been added over the three-year timespan from then up until now. When I checked my stats again after cobwebs had gathered over them, I noticed a huge drop in visitors all of a sudden. The drop occurred mid-way September 2012, which is around the time I changed the blog’s name (and URL) I think. I obviously hadn’t thought it through, because the change of address meant that all the links that pointed to posts of mine now effectively went nowhere. So my posts before Sept. 2012 were no longer getting any hits. The average visit count for my blog in total was one a day. ONE.



Now, I could change the address back to the former, but since I don’t generate any money with my blog, I honestly can’t be bothered. To me, it’s important that my user logins and urls are consistent (with the new pseudonym I created).

The good news however, is that I am inclined to create new content and use my blog again to do this. I think the drop of activity had come from the popularity of Facebook over the years. Especially for short posts (sharing a clip on YouTube, posting a link to interesting stuff, …), social media are a better platform. It’s just that I notice I am slowly but surely beginning to be more inclined to really create content, instead of only sharing links.

The latter is ideal for Facebook and Twitter, but the former is what blogs were made for. I hope this feeling persists and that new posts with proper content created by me will start (and keep) appearing here, and with that, the visitor counter going back up.


Connecting Oracle SQL Developer to database without tnsnames.ora

Just a quick tip if you need to reconfigure an Oracle database connection for use in Oracle’s SQL Developer.

I recently had to reinstall Windows on my computer, and sighed heavily when I realised that meant I also had to reconfigure the connection to an Oracle database I use. That meant installing XEClient, creating a tnsnames.ora file in the right location, and adding the service connection.

But it only took me a couple of minutes to search the Internet for an easier solution that required only setting up a connection string in SQL Developer and be done with it.

In SQL Developer, you can connect in several different ways, and one of them is ‘advanced’. When you select that, you get only one textbox in which you can form a JDBC URL. This is how it should look like:

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=<ip-address or hostname>)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=<service-name>)))

Aaand done. Wish I figured this out sooner, instead of messing around with the infamous tnsnames.ora file.