Wednesday, June 29, 2011

Best windows scripting language

I was writing a Batch script and I was looking for a way of listing
all files of a directory whose filename matched a regex. I gave up of
doing that in a BAT file and I did it in a Python script.

Then I found out that I also had to replace some content in those
files, and the sed tool was perfect for that. I downloaded some
Windows binaries for that tool, but none of those supported the
features I needed. I grabbed some Python snippets that would make the
same as sed does, but I thought: "PowerShell can do this in one line",
and it did.

Now my code is divided in 3 files (bat, py and ps1) and I feel I could
use a single language. Is there any language that could do alone what
my scripts do together without increasing the LOC number

Tuesday, April 26, 2011

stopwatch.Elapsed.Ticks is different from stopwatch.ElapsedTicks

The .NET class `System.Diagnostics.Stopwatch` has a little secret.
is the number of 100 nanoseconds elapsed since the start of the stopwatch
is the number of timer ticks, and I don't know what it means

Friday, March 25, 2011

Hudson vs Jenkins, which one should I use?

Hudson and Jenkins are continuous integration servers. They are both forks of the same codebase created by Kohsuke Kawaguchi, former employee of Oracle, the company which owns the Hudson name.

Since Kohsuke abandoned Hudson to work on Jenkins, we wondered which fork would be more actively maintaned and improved. We can draw some metrics analysing their repositories.

From GitHub perspective Jenkins is the clear winner with 630 vs 175 commits since the fork, 18k vs 12k pageviews, 401 vs 82 watchers and 160 vs 12 forks.

Accordingly to OhLoh Jenkins has fewer users (53 vs 344), but more active contributors (209 vs 131).

Sunday, March 13, 2011

How to configure your Android device to show up on "adb devices"

Installing the Google USB Driver package isn't enough to make your android device to show up in the "adb devices" list. You have to follow these instructions too:

Tuesday, March 8, 2011

Expanded version of Static Maps Creator

Wouldn't be easier to edit static maps on Google Maps' My Maps screen? Yes it is!
And since Pamela Fox published her "My Maps -> Static Maps converter" it became possible.

But it lacked many feature that I implemented in my version:

  • Polygon simplification
    When the generated URL exceeds 2048 characters, the polyline resolution is reduced to fit this limit. You can see that the following msid works in this version while it didn't in Pamela's: 204800902137920655010.000497ccb8f8082d2c1fd
  • Additional output formats for changes propagation
    With Pamela's version you had to copy the image URL and paste in your site. Any changes you made to your Map wouldn't replicate to your site. It accepts the following outputs:
    • HTML output: iframe it
    • URL output: retrieve the url
    • JSONC output: retrieve a XSS compatible JSON. It accepts the `callback` parameter indicating which function should be called. The default value is `callback`.
    • Image: a JS that inserts the map in the same position as the "script" tag is in the HTML
    • ImageTest: a live HTML demo for the /image output
  • Parameter forwarding
    The following parameters are now forwarded to the Static Maps API
    • sensor (default = false)
    • size (default = 640x640)
    • maptype
    • language
    • format
    • center
    • zoom

    The current implementation also forwards the `color` and `fillcolor` parameters, but those should be read from the KML in the future.

Monday, February 7, 2011

What I should install to develop Python Google App Engine apps?

You'll certainly need:
You'll probably need:
You can install either 32 or 64 bit versions of Python. But PIL installer will have trouble to find Python 64 bit. It needs a Windows Registry manual update to enable the installation.

Monday, January 31, 2011

What is the Windows Communication Foundation (WCF)?

WCF is a communication library implemented as of version 3.0. NET Framework allows to isolate the "service implementation" of "communication protocol". Besides facilitating the serialization and deserialization of data, this library also offers interchangeable implementations of the main communication protocols. for example:

  • TCP
  • SOAP
  • Named Pipes
  • Message Queues

WCF requires data to be communicated and communication methods are defined at compile time, but the communication protocols, addresses, authentication methods, methods of serialization, encryption method and other details of the communication can be defined in time execution. The configuration of these items can be done without writing code, because for most of the more popular enough to just change an entry in the configuration file.

Some protocols have been implemented in WCF for interoperability with other languages and development platforms, and can be consumed by clients implemented in.. NET WCF also allows you to expose metadata about the service, facilitating the consumption of these.

Services using WCF in IIS or can run normal applications, whether the command line, graphical applications or Windows services. WCF can be used in various settings, allowing quick and efficient implementation of:

  • communication between processes on the same machine (eg. named pipes)
  • webservices
  • web APIs
  • comunicação desconectada (ex: message queue, envie e esqueça)
  • bi-directional communication (eg signature and publication)

The WCF was also implemented in the Mono framework, but only partially.

Translated automatically from my original post in Portuguese.

Tuesday, January 11, 2011

How to make Log4Net to work with a Windows Service assembly?

There are 2 main concerns with using Log4Net with Windows Service:

1. XmlConfigurator must have its Watch property set to true
2. The output log file must be written to a folder where the service user has writing rights

To solve this you can add this line to your AssemblyInfo.cs:

[assembly: log4net.Config.XmlConfigurator(Watch = true)]

And you have to choose a suitable output path such as:

<file value="${ALLUSERSPROFILE}\Company\Product.log" />

Monday, January 10, 2011

Why use "using" instead of calling the "Dispose" method directly?

The following statement:

using(disposable) { }

Has 2 main advantages over the alternative:


  • It handles null variables gracefully
  • It can be easily extended so you can use

using(disposable2) { }

instead of