Tuesday, February 19, 2013

user friendly search on windows

Windows with its cmd.exe seems not to be user friendly environment for developer. But this may be changed easily, you need only to install few programs we miss from normal systems. See http://gnuwin32.sourceforge.net and download coreutils, findutils, sed, awk, grep etc. and put them to PATH. As find.exe confilicts with windows file.exe I always rename it to gfind.exe . You have to be careful with quoting - only double quote is welcomed. Also paths may be tricki, remember to replace / with \. Eg. xargs needs extra backslash to interpret one properly.

Let's find all inserts in sql files.

find . -name '*.sql' | xargs grep insert 
It is the win32 version:
gfind . -name "*.sql" | sed s!/!\\\\!g | xargs grep insert

Summary: having in mind few simple rules you may make your system much easier to talk to.

Monday, February 11, 2013

picking up python

Recently I dived into jython, which is now scripting layer of application I' maintaining. Coming from Java/Scala I have some notices:
  • indentation matters
  • it actually does not matter that much, as I indent my code :>
  • method's first argument is always self
  • this point may have some exceptions, but for me a thumb rule is :%s/()/(self)/ in my vim :>
  • there is no null, but None
  • even if it's still jvm
  • None starts with capital letter, just like False, True and some others...
  • this one really surprised me
  • you do not write new to create new object
  • just call constructor, but
  • you have to return explicitly
  • which hurts when you're used to scala's brevity