Code for Concinnity

beautiful and elegant solutions


cmd-recycle: Delete files from Windows command line

Download links

I wrote another tool to do just this a while ago, but that one stopped working since I migrated to Windows 7 x64. Microsoft said the SHFileOpearation interface (which the old tool used) had been replaced by the IFileOperation interface. So I figured I would dig up my rusty C# again to update it.

Damn, I can’t believe it took a couple of hours, but the result worked amazingly. This one also supports wildcards:

1
recycle file1 file2 supports-wildcards\*.tmp

I’ve gone the extra mile and set up a proper repository this time around on GitHub. Probably some Windows gurus will mock me left and right with some obscure one-liners or something, lol.

Published by kizzx2, on January 6th, 2010 at 3:30 am. Filled under: Useful tips Tags: , , No Comments

Starting Windows’ Network and Sharing Center from command prompt

It has always looked not-so-cool to have to type “Sharing” at the start menu or worse yet, navigate through the Control Panel just to start it. Today I finally dug out how to do it from TechNet:

1
control /name Microsoft.NetworkAndSharingCenter

Looks like Microsoft decided to go down the verbose path. Maybe I’ll just stick with the old ways :p

Published by kizzx2, on December 29th, 2009 at 9:21 pm. Filled under: Useful tips Tags: , , , No Comments

Getting the currently running host name in Capistrano

I don’t know if it is so obvious that no people talked about it, or that people actually don’t need to use it. I find that for any non-trivial tasks, it is necessary. There is a thread on Google Groups that talked about it but it didn’t spell out the answer directly. So here it is:

1
current_host = capture("echo $CAPISTRANO:HOST$").strip

Kind of anti-climatic lol.

Published by kizzx2, on November 29th, 2009 at 3:31 pm. Filled under: Useful tips Tags: , No Comments

Stop Gmail Notifier from asking the password every time upon login

I use the very out-dated Gmail Notifier client. I know it hasn’t been updated since 3 years ago but very sadly it’s still the best Gmail client around (it’s lightweight, works properly and official).

Today I finally solved one annoyance I have with this application, is that it keeps popping out the password dialog box every time I login. Until stumbled upon the solution:

If you want Gmail Notifier to do NOT ask for password each time it starts, the next time that windows pops up asking for username and password, do not use it: just close it. The Gmail Notifier icon will get an (!) warnning after that. Just open Internet Explorer and go to http://mail.Google.Com/ and login with your mail and password, and choose to keep the session open. Then go to Gmail Notifier, yet with the (!) and with the right mouse button choose the option Check Mail Now.

It will not ask you again the password with a desktop window.

Oh well, so the answer turned out to be IE, lol! It looks like the Gmail Notifier client uses IE’s component to access the server, so the password session stored in IE can be used directly. Hooraay!

Published by kizzx2, on November 16th, 2009 at 3:45 pm. Filled under: Uncategorized Tags: 3 Comments

gvim — E303: Unable to open swap file for “[No Name]“, recovery impossible

vim is my editor of choice and I install it in Windows. All is working quite good except one little annoyance — when I open the editor fresh and started editing by going into insert mode, it will give this error message:

1
E303: Unable to open swap file for "[No Name]", recovery impossible

This is usually harmless, as soon as I save the file everything would be great, it’s just that 1 – 2 seconds of pause that doesn’t make me feel good, so today I tried to pin down the problem and here’s how it went:

1
2
3
4
5
6
7
:help E303
(So it's related to the swap file. Let's see where our swap file fails to be created.)
:set directory?
directory=.;c:\tmp;c:\temp
(Oh, those are the default %TEMP% which I moved to another drive! But anyway, the first priority should be the current directory. So let's see where we're now)
:pwd
C:\Windows\system32

Solution

OK it’s pretty obvious now. It probably needs a little bit of manual fixing. Let’s put this in our .vimrc

1
2
3
4
5
" Thanks for an anonymous guest to provide this generic, better solution
set directory=.,$TEMP

" This is line I used at first. The above line is better than this
set directory=.,d:\temp

Great, problem solved!

Published by kizzx2, on November 6th, 2009 at 3:58 am. Filled under: Useful tips Tags: , , , 7 Comments

Don’t gather business requirements: hire domain experts

Recently I’ve been spending a lot of time researching the topic of software requirements and specifications. The question that I have kept asking myself is “How I can build something the customer wants from the first place?” A lot (if not all) of the time, the customer can’t even describe the correct specifications and requirements because he won’t know it until he sees it.

Then today I read Steve Yegge’s blog post “Business Requirements are Bullshit” which gave me a pretty profound answer to my question:

Don’t gather business requirements: hire domain experts.

Published by kizzx2, on September 11th, 2009 at 10:36 pm. Filled under: Process Tags: , , No Comments

Super Awesome Advanced CakePHP Tips

Super Awesome Advanced CakePHP Tips is free e-book about the CakePHP Framework. It covers topics that are generally missed in the beginner books that are on the market.

The CakePHP framework hasn’t been known for good documentation since its debut almost a couple of years ago. Now that the official manual > Super Awesome Advanced CakePHP Tips is free e-book about the CakePHP Framework. It covers topics that are generally missed in the beginner books that are on the market.

The CakePHP framework hasn’t been known for good documentation since its debut almost a couple of years ago. Now that the official manual The Cookbook has reached some maturity that this framework is actually possible for more mortals, there still seems to be a lack of materials bridging the masters and the newbies.

Super Awesome Advanced CakePHP Tips by Matt Curry is a good bridge for this gap. It covers topics beyond the basics but that are actually lifesavers when it comes to more complicated CakePHP apps, such as caching, performance, unit testing, configuration/deployment and stuffs.

Reading through the short book gives me a feeling that Matt really knows a lot about this framework. I don’t know why this book isn’t more popular than it currently is (maybe it’s just me, lol).

Published by kizzx2, on August 31st, 2009 at 5:11 am. Filled under: CakePHPNo Comments

Pidgin: Changing font size in the conversation window

(This mainly serves as a reminder to myself because it is not really obvious)

By default, Pidgin uses the theme’s font in conversation window. Most of the time, though, that would be too small for my liking. There is an option in the preferences window that allows you the change the conversation font.

Pidgin Preferences Window

However…

If you change the font size via that option, then the other party will see your messages typed in that font. That’s not always desirable. For example, I may just want my fonts to be bigger so I can read the text easily, but the other person using a netbook probably doesn’t appreciate me robbing his screen real-estate.

So how do we do it? We do it with a plug-in: Extended Preferences

Plugin - Extended Preferences

Published by kizzx2, on July 17th, 2009 at 3:51 pm. Filled under: Uncategorized Tags: , , , No Comments

Software Requirements and Management

I’ve been reading about software project management, agile practices and stuffs for several months now, almost becoming the metaphorical PM that’s read 20 books on agile. Came across this post that’s hands down the most true, funniest description about software management I’ve seen.

Software Requirements Reality

A man is flying in a hot air balloon and realizes he is lost. He reduces height and spots a man down below. He lowers the balloon further and shouts: “Excuse me, can you tell me where I am?” The man below says: “Yes you’re in a hot air balloon, hovering 30 feet above this field.” “You must be a software developer,” says the balloonist. “I am,” replies the man. “How did you know?” “Well,” says the balloonist, “everything you have told me is technically correct, but it’s of no use to anyone.” The man below says, “You must work in business as a manager.” “I do,” replies the balloonist, “but how did you know?” “Well,” says the man, “you don’t know where you are or where you are going, but you expect me to be able to help. You’re in the same position you were before we met but now it’s my fault.”
Published by kizzx2, on June 5th, 2009 at 3:21 am. Filled under: Agile Tags: , , , No Comments

Ruby on Rails vs Django

The contest between the flagship MVC frameworks of the two of the best breed programming languages out there. Django is very interesting to study because it takes quite different approaches from that of Rails, and is probably one of the very few frameworks that isn’t a Rails clone.

1-minute summary

This funny piece kind of sums it up:

  • Person 1: “What do you do for a living?”
  • Person 2: “I work with computers.”
  • Person 1: “So do I! What do you do with computers?”
  • Person 2: “I’m a Web developer.”
  • Person 1: “So am I! Design, client-side programming or server-side programming?”
  • Person 2: “Server-side programming.”
  • Person 1: “Same here! Do you use dynamically typed languages or statically typed languages?”
  • Person 2: “Dynamically typed languages.”
  • Person 1: “So do I! Do you use a Web framework, or do you roll things on your own?”
  • Person 2: “I use a Web framework.”
  • Person 1: “So do I! Django or Rails?”
  • Person 2: “Django.”
  • Person 1: “Die, heretic scum!”

Opinionated, original opinions

  • The Django guys seem to be more pragmatic. They would say “maybe it’s too much magic for experienced programmers,” where the Rails folks would day “Look! It’s magic! The meta-programming is just elegant!”
  • The Django people wrote the official manual. Rails still don’t have many serious documentations at this point other than screencasts and RDoc. Understandable when DHH’s too busy participated in flame wars lol
  • Is it a co-incident that most resources I found regarding Rails vs Django are hosted on the Django’s Web site?

OK, those were focused on the communities more than the frameworks themselves. Heck, I said I was opinionated!

Something about the languages

A comment from a blog post: Why I moved from Ruby on Rails to Python/Django and back kind of ties up the Ruby vs Python issues quite nicely, and neutrally:

The fact that you need to be slightly more explicit in Django is actually considered a feature, since that increases readability and ease of maintenance. I do agree though that while Python is a pleasant language to develop and maintain code in, Ruby seems to be more focused at being fun. It feels like it lets you be ‘clever’ with your code in a way that Python won’t allow. For better and for worse, I’d guess that part is quite much just a matter of taste.

Let’s see the gurus sort it out

We also have a video of SnakesAndRubies, where we see “Adrian Holovaty, one of the creators (plural) of the Django framework for Python, and David Heinemeier Hansson, the creator (singular) of Ruby on Rails framework” go into debate.

Finally, some hard-core papers

For those of you who like hard-facts, people have wrote formal reports using scientific methods:

Opinionated summary

Disclaimer: I have only read the stuffs above when I write these. I myself, at this point, is a Rails person. I haven’t written a single line in Django (definitely worth a try when I get the time :)

After some heavy-reading, I came to the conclusion that Rails is basically a DSL written for MVC framework, and a heavy-duty DSL indeed. Django, on the other hand, really feels like an MVC framework written in Python.

What that means, very generally, is that you’d see a lot more magic in Rails than in Django.

Published by kizzx2, on June 2nd, 2009 at 1:18 am. Filled under: Web Tags: , , , , , , , No Comments