Room of a pleinolijf

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

Leave a 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

Williams unveils its 2014 F1 car


It’s the dreaded anteaters ! Runaway !!

Originally posted on Motorsport:

WilliamsSo – now we get a real look at 2014 F1 car and more specifically that nose and, like Cyrano turning to face Roxanne for the first time, it’s hard not to be shocked. That is one hell of a conk. Don’t blame the design team at Williams, they are only responding to the rule changes and it’s expected that by next Tuesday — by which time we will have seen all but one of the new cars — the F1 paddock will resemble a colony of proboscis monkeys.

View original 426 more words

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.


Get every new post delivered to your Inbox.

Join 719 other followers