Just sharing some of my inconsequential lunch conversations with you... RSS  

Friday, January 29, 2010

Postponing reinstalling your Windows

As much as I like to pave my Windows machine every now and them, it’s not always possible. So every now and then, I run this cool utility from sysinternals: Autoruns:

This utility, which has the most comprehensive knowledge of auto-starting locations of any startup monitor, shows you what programs are configured to run during system bootup or login, and shows you the entries in the order Windows processes them. These programs include ones in your startup folder, Run, RunOnce, and other Registry keys. You can configure Autoruns to show other locations, including Explorer shell extensions, toolbars, browser helper objects, Winlogon notifications, auto-start services, and much more. Autoruns goes way beyond the MSConfig utility bundled with Windows Me and XP.

Autoruns' Hide Signed Microsoft Entries option helps you to zoom in on third-party auto-starting images that have been added to your system and it has support for looking at the auto-starting images configured for other accounts configured on a system. Also included in the download package is a command-line equivalent that can output in CSV format, Autorunsc.

Autoruns

 

Sure you’ll still have to make sure to have your disk regularly defragmented. As last resource before totally paving your OS, I can always rename my user folder, log in and copy the documents I need.

Thursday, January 28, 2010

Microsoft Solver Foundation

Solver Foundation is an extensible framework that helps you model and solve complex problems by:

  • Modeling and solving scenarios by using constraints, goals, and data.
  • Programming in the Optimization Modeling Language (OML), in C# imperatively, in F# functionally, or in any .NET Framework language.
  • Integrating third-party solvers, such as Gurobi, Mosek™, FICO™ Xpress, LINDO, CPLEX®, and lp_solve.
  • Using familiar interfaces in Microsoft Office Excel and SharePoint to create and solve models.

 

Here’s the architecture’s picture:

sf-arch.jpg

As expected, it’s not free, but it comes with a free evaluation version. And an academic one.

Friday, January 22, 2010

The obvious question finally asked!

image

And there you go, when it makes sense, on exit, we get a nice an non intrusive:

image

Hope to see it as a de facto standard.

Wednesday, January 20, 2010

Silly compiler season

I was revisiting an old geek post – a silly and inefficient way to swap integers avoiding an explicit temporary variable just for fun:

b = a + (a = b) - a;



On my first impression when reading this line of code I felt like simplifying the expression to something like:




b = (a = b);



Or even:



b = a - a + (a = b);



But I’m afraid it just doesn’t work. The original expression makes use of the order we are affecting the expression to get it done. Let me show what’s to IL:



    class Program
{
delegate void SwapDelegate (ref int a, ref int b);

const int MyConst1 = 123;
const int MyConst2 = 4567;

static void validate(string operation, SwapDelegate swapDelegate)
{
int a = MyConst1;
int b = MyConst2;
int oldA = a;
int oldB = b;

swapDelegate(ref a, ref b);

Console.WriteLine("{0} :: {1}", operation, oldA == b && oldB == a);
}

static void Main(string[] args)
{
// Swap: Ok
validate(
"b = a + (a = b) - a",
delegate(ref int a, ref int b)
{
b = a + (a = b) - a;
}
);


Reversing to IL we get:


validate("b = a + (a = b) - a", delegate (ref int a, ref int b) {
int CS$0$0000;
a = CS$0$0000 = b;
b = (a + CS$0$0000) - a;
});


As expected:




  1. the order is, as expected, relevant


  2. the temporary value is still there


  3. it is highly dependent on the order we write the expression – more, I’m not exactly sure the order we depend upon is guaranteed by the compiler


  4. on the imperative world, we should expect side-effects. And on some cases, we can even depend on them :)



 



Here are some results:



b = a + (a = b) - a   ::   True
b = a - a + (a = b) :: False
b = (a = b) :: False
b = a + (a = b) - b :: True
b = a - b + (a = b) :: True
b = (a = b) + a - b :: False
a = a + b - (b = a) :: True

Best Practices for form design

Web Form Design: Filling In ...Here’s the next book I have to read: Best Practices for form design. It’s written by Luke Wroblewski, current Chief Design Architect at Yahoo, former Lead User Interface Designer of eBay and Senior Interface Designer at the NCSA, the birthplace of the first popular graphical Web browser, NCSA Mosaic NCSA Mosaic (link corrected).

Here’s a presentation of the book.

Thanks for finding it, Tiago.

 

<update>

Sign of times…

image

</update>

SOLID principles

I’ve just loved Hanselman’s show #145, SOLID Principles with Uncle Bob - Robert C. Martin.

I’ve resisted the impulse to join Uncle Bob’s vs Joel Spolsky blog wars. I’m only interested in making reference to Bob’s far-sighted digest of fundamental OO principles. Let me copy them using the order someone have suggested to make it SOLID:

SRP

The Single Responsibility Principle

A class should have one, and only one, reason to change.

OCP

The Open Closed Principle

You should be able to extend a classes behavior, without modifying it.

LSP

The Liskov Substitution Principle

Derived classes must be substitutable for their base classes.

ISP

The Interface Segregation Principle

Make fine grained interfaces that are client specific.

DIP

The Dependency Inversion Principle

Depend on abstractions, not on concretions.

 

This are the class principles. Please follow the link to get the packages and coupling principles.

Monday, January 18, 2010

Leap Year

Every now and then I find someone that still believes leap days come in 4 year cycles, no exception made. Some of them are even programmers that never had to implement a leap year algorithm:

    public static class DateUtils
{
public static bool IsLeapYear(this int year)
{
return (year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0));
}
}



 



I used to get quite nervous with the fact, but not anymore. Why? This just doesn’t impact on today’s every days life :) Let me try and prove it to you:



            foreach (
var year in
Enumerable.Range(1582, 1500)
.Where(d => (d % 4 == 0) && d.IsLeapYear() == false)
)
{
Console.WriteLine("{0}", year);
}




So what am I getting? On the first 1500 years since the Gregorian calendar as defined the present algorithm, which of these 4 year cycles weren’t leap years?



image



 



Oops, it seems like no one I know was born of probably be alive on those days, who cares? “Press any key to continue”: yeap, seems right :)

1st Workshop “Internet of Things”

Yesterday we had our first Workshop on “Internet of Things”. This workshops joins Link consultants and Instituto Superior Técnico M.Sc. and PhD students on a series of state-of-the-art and business presentations. The areas of interest are RFID, logistics and enterprise information systems.

One of the presented projects was my current I&D project: rfrbNET: RFID track & trace federated network.

Sunday, January 17, 2010

Shutter count on EOS

Here’s a cool utility: EOSInfo.

I’ve only used it on EOS 50D and it works. I’ll have to install a driver on my Windows 7 x64 so I can use it against my old 10D – I’m curious to know it counts camera or shutter cycles. If I could choose, I’d definitely go for shutter – I buy shutters like most people buy printer tonners :)

Geotagging photos

Bilora photo-geotaggerI’ve been trying to geotag my photos using my PDA so I can cross-reference them by date. Though the process works it wastes by PDA’s battery on something like 1 1/2 hours.

A friend of mine is trying a cool new system: u-blox:

u-blox’ patented GPS Capture & Process technology enables mobile products to instantly capture a location using just a few millijoules of power. This is especially attractive for applications such as photo geotagging for cameras and camera accessories where users just want to point and shoot, and not waste precious time and battery power waiting for a conventional GPS position fix. The concept can easily be extended to ultra-low power position loggers that can record position data for months without recharging.


How it works
In contrast to real-time GPS receivers which can take an unacceptably long time to establish a position fix, GPS Capture & Process captures location data in a fraction of a second. It achieves this by separating the GPS signal capture and subsequent processing into two distinct steps:

  1. Capture: the raw output of an embedded GPS front-end is digitally captured and stored locally, for example in a camera’s memory each time a photo is taken.
  2. Process: when uploading photos for storage, u-Blox PC or Mac software also uploads the raw capture data and timestamp associated with each photo. With the help of u-blox’ online satellite positional data service, the raw data is quickly converted into a position fix.

The benefits to camera and logger manufacturers are clear:

  • Ultra-fast location capture: GPS signal data is captured on-demand in less than 200 ms – no waiting for acquisition of satellite orbital data necessary. Point and shoot performance!
  • Extremely low power solution: the GPS radio is on for a small fraction of a second per capture resulting in a negligible impact on battery life.
  • Fast time-to-market: complete end-to-end, globally available and reliable online geotagging and reverse geocoding service is available now.
  • Fast PC processing: geotagging and reverse-geocoding software and online service is optimized for Windows (XP, Vista and 7) and Mac and can typically compute a position fix from a capture in 0.4s per photo.

The system can work synced with the flash or operated manually. The online satellite positional data service is provided by u-blox, so this can be a problem the day they shut it down… and no, we can’t use it with a flash (I’m guessing this one…).

Probable the next generation of cameras will come equipped with geotagging capability, and this can be a great solution.

Cool gadget. Probably usable on a myriad of other scenarios…

Wednesday, January 13, 2010

Monitoring battery

I’m looking for a better tool to monitor my battery life-cycle. I’m trying out BatteryBar free edition, and it looks ok so far. Do you know a better free utility?

 

Battery meter popup shows detailed information

Status popup show detailed information about your battery's status



Battery is discharging with 2 hours, 46 minutes of battery life remaining.
Battery meter toolbar showing battery life remaining


Battery is charging with 46 minutes until the battery is fully charged.

Battery meter showing time to recharge the battery

Monday, January 11, 2010

Strongly typed rules!

I admit, I’m an old fashioned curly brackets kind of developer with a crush for early binding and strongly typed models!

Here’s a cool post from Scott Guthrie about my kind of views:

<%= Html.TextBoxFor(model => model.Name) %>



Don’t you just love it when everything breaks apart on compile time? :)

Development Catharsis :: Copyright 2006 Mário Romano