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? :)

Sunday, January 10, 2010

Bases

Why are so many ancient systems based 12? Because it is easy to do math with 12. According to Wikipedia:

12 is a highly composite number, the smallest number with four non-trivial factors (2, 3, 4, 6), and the smallest to include as factors all four numbers (1 to 4) within the subitizing range. As a result of this increased factorability of the radix and its divisibility by a wide range of the most elemental numbers (whereas ten has only two non-trivial factors: 2 and 5, with neither 3 nor 4), duodecimal representations fit more easily than decimal ones into many common patterns, as evidenced by the higher regularity observable in the duodecimal multiplication table. Of its factors, 2 and 3 are prime, which means the reciprocals of all 3-smooth numbers (such as 2, 3, 4, 6, 8, 9...) have a terminating representation in duodecimal. In particular, the five most elementary fractions (12, 13, 23, 14 and 34), all have a short terminating representation in duodecimal (0.6, 0.4, 0.8, 0.3 and 0.9, respectively), and twelve is the smallest radix with this feature (since it is the least common multiple of 3 and 4). This all makes it a more convenient number system for computing fractions than most other number systems in common use, such as the decimal, vigesimal, binary, octaland hexadecimal systems, although the sexagesimal system (where the reciprocals of all 5-smooth numbers terminate) does better in this respect (but at the cost of an unwieldily large multiplication table).

Here’s why so many ancient system are based 12 – they are simpler to compute. And this is why we still have 12 hours cycles. And this is probably why the non-scientific community took longer to give base 12 away – it is still a trading unit in use nowadays. At least in Portugal eggs come in half a dozen packages.

12 also have another cool property: dividing days in year by days in lunar cycle we get: 365,25 / 28: around 13. 12 is the nearest lower pair number to bridge the sun and lunar cycles. Probably irrelevant…

Ok, this guys gave some thought before choosing their base. But there are other cool number to simplify math. Take the babylonian numerals, based 60. More divisors, cool! And here’s why we 60 seconds in a minute, and 60 minutes in an hour and 360 degrees in a circle.

Finally we use base 10. What to do when we need to multiply by 13 or 14? It seems that we chose it simply because we are lazy and prefer counting fingers… :S

And then we have computers, but we all know that, right?

 

<update>

Here’s a divisor’s list (if I had to quickly bet on successful bases, I’d bet on the bold ones):

1 ( 1)  1
2 ( 2)  1 2
3 ( 2)  1 3
4 ( 3)  1 2 4
5 ( 2)  1 5
6 ( 4)  1 2 3 6
7 ( 2)  1 7
8 ( 4)  1 2 4 8
9 ( 3)  1 3 9
10 ( 4)  1 2 5 10
11 ( 2)  1 11
12 ( 6)  1 2 3 4 6 12
13 ( 2)  1 13
14 ( 4)  1 2 7 14
15 ( 4)  1 3 5 15
16 ( 5)  1 2 4 8 16
17 ( 2)  1 17
18 ( 6)  1 2 3 6 9 18
19 ( 2)  1 19
20 ( 6)  1 2 4 5 10 20
21 ( 4)  1 3 7 21
22 ( 4)  1 2 11 22
23 ( 2)  1 23
24 ( 8)  1 2 3 4 6 8 12 24
25 ( 3)  1 5 25
26 ( 4)  1 2 13 26
27 ( 4)  1 3 9 27
28 ( 6)  1 2 4 7 14 28
29 ( 2)  1 29
30 ( 8)  1 2 3 5 6 10 15 30
31 ( 2)  1 31
32 ( 6)  1 2 4 8 16 32
33 ( 4)  1 3 11 33
34 ( 4)  1 2 17 34
35 ( 4)  1 5 7 35
36 ( 9)  1 2 3 4 6 9 12 18 36
37 ( 2)  1 37
38 ( 4)  1 2 19 38
39 ( 4)  1 3 13 39
40 ( 8)  1 2 4 5 8 10 20 40
41 ( 2)  1 41
42 ( 8)  1 2 3 6 7 14 21 42
43 ( 2)  1 43
44 ( 6)  1 2 4 11 22 44
45 ( 6)  1 3 5 9 15 45
46 ( 4)  1 2 23 46
47 ( 2)  1 47
48 (10)  1 2 3 4 6 8 12 16 24 48
49 ( 3)  1 7 49
50 ( 6)  1 2 5 10 25 50
51 ( 4)  1 3 17 51
52 ( 6)  1 2 4 13 26 52
53 ( 2)  1 53
54 ( 8)  1 2 3 6 9 18 27 54
55 ( 4)  1 5 11 55
56 ( 8)  1 2 4 7 8 14 28 56
57 ( 4)  1 3 19 57
58 ( 4)  1 2 29 58
59 ( 2)  1 59
60 (12)  1 2 3 4 5 6 10 12 15 20 30 60

</update>

HTC Hero boot time sucks!

I’ve been trying out an HTC Hero. It’s a fair equipment with some cool functionalities, but there’s one little detail that doesn’t seem aligned with Google’s objectives: it takes ages to boot!

Here’s my experience:

Boot to desktop 1:34
desktop loading time 1:03
total 2:37

My Windows 7 boots considerably faster!

Please note that desktop loading time doesn’t allow me to use the mobile, so I have a 2:37 total boot time.

Probably some of this time is spent on the Android agenda widget.

Still a cool mobile.

Tuesday, January 05, 2010

Windows Azure MSDN benefits

It seems like there are some free benefits for MSDN Subscribers:

 

image

 

Heard about it here.

Installing HTC Hero on Windows 7

The proposed workaround stopped working. Why? I had a newer driver. Strange…

It seems like a newer driver update is available at WindowsUpdate :S Arghh!… I had to:

  • uninstall the driver – something like HTC Dream, if I remember correctly
  • disconnect the network
  • connect the phone
  • install driver locally according to the proposed workaround

Let me say my first experience with HTC Hero is a mixed one:

  • excelent: market!!!
  • good: cool hardware and display; cool desktop
  • --- : not so intuitive as expected… the menu and cancel buttons…
  • bad: no out of the box sync over USB; no network support over USB

Still a great mobile!

 

<update>

Cool things:

  • Icons look beautiful – they learned the lesson with Apple
  • Very well built
  • The gadgets makes the difference: accelerometer, compass, multi-touch
  • Google apps integration – incredible with gmail
  • Syncing with my carkit headset – didn’t ask for those dreadful ‘1111’, ‘1234’, … ‘9999’ low security stupid keys, just hacked them!
  • Getting a bunch of apps from Market; apps like Layar

Not so cool:

  • As a phone, it could be better:
    • Slow and cumbersome access to my 2K contact list, some bugs. Probably HTC software’s fault
    • Easy to miss receiving calls, and to miss we are making a call :S
    • Low cell signal
    • Not the greatest of phoning sound quality
  • Button position could be better. Back button is just hard to reach for right handed people
  • Slow access to my Exchange mail
  • Why do I have an alarm icon on the top of the phone?!?!
  • Ok, I know I’m not the typical phone user, but my after a bunch of installations my Hero is not as responsive as it used to…
  • Battery life could be better, could hardly make it through the day. But then again it is as appealing that I' could have overused it…
  • Couldn’t get the SDK up and running. Ok, probably my fault, I’ve downloaded Eclipse and SDK and tried to install it with no internet access. Well it seems that Google demands internet access on install. Go figure…

The verdict: I’ll probably wait for a faster CPU with a wider screen. And a cheaper one. Could Nexus On be the one?

</update>

 

<update II>

I’ve been using an average of nearly 20MB/day of 3G traffic. Oops, I’ve just wasted my monthly limit in less than a week. Be it because Android pushmail is too demanding on traffic or just because Android is a new gadget I’ve been exploring, one thing is for sure: I have to return this baby soon or upgrade my traffic account…

</update II>

Short MVC history lesson

Here’s a cool brief history of an old concept: http://kasparov.skife.org/blog/src/java/mvc.html

Monday, January 04, 2010

Bing vs google: oops

Ok, nowadays I can use either bing or google and hardly find any great difference. But sometime I still get some glitches in the matrix:

image

Sunday, January 03, 2010

TMN SilverBelt: take 2

After only a week of usage I’ve returned my SilverBelt and asked for a new unit. The only serious problem I had with it was the battery – it didn’t last for a day with the exact same usage as my old HTC 3300.

The new unit had the same problem, so I had to cut some waste. I started by opting out 3G over GSM. It saved me a bit, but not enough to get me through the day.

The workaround to get me through the day was quite drastic: I had to disable push mail, and opt for a 1h pooling. But now I can get through the day.

So my verdict is:

  • Cool display size – though a little “deaf”;
  • Windows Mobile 6.5 is heading in the right direction (and way), but it is still a no go; ZTE/TMN “shell “ is poor, to say the least;
  • Quite acceptable value for your money – ok, doesn’t support MultiTouch, accelerometer and digital compass, but we can’t really ask that for this price, can we? Ok, Pulse doesn’t support digital compass…
  • Unusable for a communicating kind of guy

So I’m again on ebay looking for a bargain on a:

  • iPhone 3GS
  • HTC Hero
  • T-Mobile Pulse

Until them, SilverBelt will do just fine.

PS: ok, some of these units don’t support PushMail, so this option is not entirely rational, is it? Who cares, its a gadget, if chosen without the heart will defy its purpose :)

Development Catharsis :: Copyright 2006 Mário Romano