Reset the Postgres User Password

Suppose that you are running PostgreSQL as your database server but you forgot the password of the postgres account. You can't connect on the shell using psql nor using the pgAdmin application. By the way... Yes, I am guilty as charged... been there, done that.

The key thing is to get around the server asking you for a password. You can do that by editing the pg_hba.conf file with the editor of your choice. In my case, running Ubuntu 8.10, I issued the following command at the shell:

sudo emacs /etc/postgresql/8.3/main/pg_hba.conf

In this file you will find the following lines:

# Database administrative login by UNIX sockets
local   all         postgres                          ident sameuser
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
# "local" is for Unix domain socket connections only
local   all         all                               ident sameuser

You will need to change it to look like this:

# Database administrative login by UNIX sockets
#local   all         postgres                          ident sameuser
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
# "local" is for Unix domain socket connections only
local   all         all                               trust #ident sameuser

What you have done when editing the pg_hba.conf file as indicated above is to tell the Postgres server that all connections originating at the local machine are trusted. Now you should be able to connect to your server by issuing the following command at the shell prompt:

psql -U postgres

At the Postgres prompt you may now reset the postgres user password by running the following statement:

postgres=# alter user postgres with password '<your password here>';

The postgres account has a new password and you can connect using it. Don't forget to revert back the changes that you made to pg_hba.conf.

Chrome: First Impressions

Last night I downloaded and played with Google Chrome. What follows are my first impressions about the browser as a whole and some of the specific features.

At home I am currently using Firefox 3 (FF3) and Internet Explorer 7 (IE7) with a bias towards FF3. At work I use IE7 exclusively. My opinions and impressions are based on my usage of the browsers above and I don't use any other browser currently.

The first thing I noticed is that the position of certain UI elements is different than what I am used to with FF3 and IE7. Chrome uses a tabbed interface, but the tabs are at the top of the window right below the title bar. There is no visible menu bar or toolbar in the Chrome UI. There is only a few command buttons embedded in the address bar.

According to what I read about Chrome , Google aimed for minimalism in the Chrome UI and for that they should receive an A+. This doesn't mean that I am for or against minimalism in web browser UI. It just means that I think they achieved their goal.

The next thing I noticed is that it lacks a status bar and, as a matter of fact, the status bar is completely gone. I am addicted to my status bar in IE7 and FF3, because I constantly look at it to know the status of page load and for other queues that it provides. The fact is that, at least so far, Chrome doesn't need a status bar. At the time of this writing I've been using Chrome for a couple of hours and I have not once felt the urge to look at the status bar to know where I am at with the download of a page. The truth is that Chrome downloads and renders web pages visibily faster than both IE7 and FF3. There is an interesting article about Chrome performance at Life Hacker

Although Chrome is a minimal browser, it's not completely devoid of features. On the very far right side of the address bar there are two buttons which bring up menus that allow you to get to these features. The first button brings up the page menu and it contains the expected page related commands such as copy, cut, paste and find. But it also has a few commands that are unique to Chrome: Create Application Shortcut and a Developer submenu.

Chrome Tools & Tabs

Chrome Tools & Tabs

The Create Application Shortcut command is great feature. How it works is you surf to web application that you like (e.g. Gmail) and then click on the Create Application Shortcut menu item and then Chrome asks you where you want to save a shortcut to the application. Once the shortcut is created you can just double-click it and it will launch the web app you chose inside a Chrome window. To be fair, this is not a novel feature and it has been done before by others with different names and formats. But this feature really says a lot about Google's intentions: The browser and the Internet are the application platform and Operating Systems as such are obsolete.

Before I discuss the Developer menu features, let me talk about the Tool menu briefly, which is the other button on the far right side of the address bar. This is where you can access your bookmarks (you can also use the Ctrl+B shortcut to view the bookmark bar), history, downloads, and the borser options dialog. There isn't anything earth shattering about these features or the browser options.

Now back in the page button, the Developer menu has commands that allow you to view a web page's source as well as access to a JavaScript debugger and console. The debugger window is pretty standard and allows you to set breakpoints and print output to the debug window.

The console, however, is more like a DOM inspector that allows you to inject JavaScript commands into the web page on the fly. It looks pretty cool, but I have only played with it a little bit at the time of writing this. The console window seems to be pretty heavy on the CPU load, though.

This next feature is great and it set me on a path to find more gems like it, which I did and list them all a little later. I am talking about the Task Manager dialog. Chrome runs a different process for each tab, which allows it to isolate the memory space used by each tab, which then isolates any crashes to said tab. In the task manager you can view (and kill) any of the Chrome processes.

But if you look at the bottom left corner of the Task Manager dialog, you will find a Stats for Nerds link. This link will take you to the Memory Usage page (about:memory) and it lists the memory usage for each one of your Chrome processes as well as your IE7 and FF3 processes for quick and easy comparison. This is a masterful move by Google: give the early adopters and power users the tools they need to look at the data and make up their own minds about which browser is technically superior.

Chrome Memory Usage

Chrome Memory Usage

There are other gems under the about: URL Scheme. A couple of notable ones are about:plugins and about:cache. There are also a few about: URLs that are Chrome specific: about:DNS lists the cached DNS recors; about:network gives stats and a monitoring interface for network usage (not unlike the HTTP protocol inspector tools such as HTTPWatch ); and about:stats displays several process statistics. There is even a cool easter egg at about:internets (check out the title of that page).

There is also lot of buzz generated around Chrome and most of it is great, but there were also some questions raised around some of the terms of the Chrome EULA. This has been cleared up and Google will be changing the license terms.

All in all, I think Chrome is a fresh and nice shift in browser technology, but at the same time Chrome is not an earth shattering paradigm shift. I am mildly impressed with it and will be watching closely to see where it goes. I will continue to use it for the time being.

The Diatec Filco Majestouch Keyboard

Update: 2010-11-06 - I got a new Topre Realforce board.

Update: 2009-06-21 - I got a new Avant Prime board. I won't profess to be a connoisseur of exotic keyboards, but this week I got my hands on a Diatec Filco Majestouch FKB104M/EB (Filco) which found its way to me via a friend. These boards are not sold in the US and are available only through special order services from Japan. I was very lucky because the person who sold me this board is actually travelling to Japan and I already put in an order for one more.

The Filco is like nothing else I ever typed on (I am using it right now to write this). But first let me give you a little bit of history of how I got to the Filco.

Diatec Filco Majestouch FKB104M/EB

Diatec Filco Majestouch FKB104M/EB

A few years back, Microsoft manufactured a keyboard called the Natural Ergonomic Keyboard 4000 (Ergo 4K) and I got me one of those. With what I knew at the time I thought I was in keyboard heaven. A little while after that I got me a new laptop for work which had a docking station so I plugged the Ergo 4K into it and no problem. At that time I also started traveling quite a bit for work and it became apparent that I was having difficulties switching between the regular laptop keyboard and the Ergo 4K. The muscle memory that you build when using the Ergo 4K is unique and does not translate very well to anything else. So I needed a keyboard standard that I could use both at my desk at work and while travelling with minimum disruption. This is when I started researching keyboards seriously and learning about the features of high end keyboards. I decided to go with the Happy Hacking Keyboard Lite 2 (HHKB Lite) for my purposes. The HHKB Lite is light and you can pack it in a bag and easily take it with you at any time and it is definitely a world apart from the Ergo 4K. But the thing about the HHKB Lite is that it is a very minimal board. It does provide all the functionality of any 101 or 104 keys board, but it does so via Function key combinations. At work I live inside of 3 tools: GNU Emacs, Visual Studio and SQL Server Management Studio. The HHKB Lite works like a charm for Emacs, but not so much for VS and SSMS. To run a simple query in SSMS I found myself hitting some unnatural key combination.

One influence from the HHKB Lite that I will always carry with me is the position of the CTRL key. I swap the position of the left CTRL key with the CAPS LOCK key as they are placed on most keyboards. I use a registry hack in Windows to accomplish that and change some configuration files in Linux to achieve the same result. Nonetheless, my quest for the perfect keyboard continued...

I tried several different boards, but they were all mediocre or just plain bad. The thing is that most keyboards sold in the US today use the rubber dome key switch technology (both the Ergo 4K and the HHKB Lite use a rubber dome key switch). Rubber dome technology is just fine for most people, or so I thought. Then I had the opportunity to test drive a Unicomp Customizer and my mind was opened to all the possibilities available in one's choice of key switches, and this influenced my future research and learning.

In my opinion (and I have no factual base to back this claim... yet), now that I have been able to play with a buckling spring board (the Unicomp) and a mechanical board (the Filco), I have to say that the rubber dome boards provide for a sloppy typing experience. The rubber dome boards are not very conducive to efficient, precise, and fast typing.

The first thing I noticed about the Filco as I was unpacking it is how heavy it felt. This is a full 104 keys modern keyboard, but the footprint is minimal compared to the Ergo 4K and yet the Filco weighs a little more. The key caps on the Filco have a different look to them. It is as if they have been polished. The key switches themselves are Cherry MX Series brown axis switches. They are a soft tactile switch type: If you press on a key very slowly and really try to pay attention to what is going on as you press the key, you will definitely notice that after a very short amount of travel the key actually gives in and travels the rest of the way down almost by itself. I once used an IBM electrical typewriter that had a very similar behaviour of the key presses. The Filco is also fairly quiet, but louder than rubber dome boards.

Filco Keyboard - Cherry Brown Key Axis

Cherry Brown Axis Key Switch

During continuous typing tasks I feel that my fingers flow better on top of the Filco keys. It took me about an hour of typing to get comfortable with the Filco and at the time of this writing I've typed with it for a few long sessions over a couple of days. I am definitely not a fast typer, but this keyboard has already improved my speed by 4 words per minute and my accuracy by 2 percent.

Is the Filco Majestouch the perfect keyboard? From all the boards I have tried so far, the Filco ranks way up there with the top 1. It is definitelly the most elegant keyboard I've ever had. It also provides the best typing experience I've ever had by a long shot. On the other hand, there are 3 things I would change on the Filco if I could: first, I would add a 2 port (at least) USB hub; second, I would add another foot or three to the cable; third and most important, I would swap the left CTRL and CAPS LOCK keys just like the PSU guys did in their Happy Hacking series.

I do, however, still feel that I need to continue to broaden my horizons by testing and using other boards. That's the only way to find my ultimate keyboard. What's next in my quest for the perfect keyboard (in no particular order): Das Keyboard III Ultimate, Topre Realforce 101, Happy Hacking Pro 2, Unicomp Customizer, the Original Model M, the Compact 1800 Series by Cherry, the Ultraslim 4100 Series by Cherry. I suppose I have my work cut out for me.

Guarantees

Suppose you have a function in C# with the following signature:

int f(int i) { ... }

Given this signature, can you guarantee to me what the return type of the function is? Seems like a no brainer, right? Not so fast... examine this code for a second:

int f(int i) { return i / 0; }

In this instance, function f will not return an int at all, but it will rather raise an exception. I just wanted to illustrate the point that even in a statically typed language like C#, there is no guarantee that you will get back exactly what the language is advertising to you.

My Home Office Setup

I've been reading some of Jeff Atwood's entries about ergonomics and work area setup and I started to think about my own setup in the home office. And I figured out that I really use a lot of desk real state.

For years I've been using a metal tanker desk and it has served me so well that I will never part with it provided that I have the space to keep it and the strength to haul it around. The tanker desk does have a lot of storage space in all its drawers, but it lacks severely on the surface area property.

Tanker Desk

Tanker Desk (12.5 feet squared)

What I need most in my work space is the surface area because I am constantly reviewing and reading technical articles that I printed or I have a pile of books that I am using for reference. I need the room to spread out. At work I have a corner desk which gives me a lot of space to spread out, so I did a little research on that and I found that one of the best corner desks out there today is the IKEA Galant model.

New IKEA Gallant Desk

IKEA Galant Desk (25.7 feet squared)

The new desk definitely gives me the surface area I need (an extra 13.2 feet squared), but I also like it for the elbow support. My elbows are not hanging off the edge anymore. I also got me a drawer unit to go with it just to keep the most immediate office supplies that I need. In the end, my personal philosophy about ergonomics is: If it feels comfortable, do it. Like Jeff, I've been blessed that I haven't experienced any stress injuries to date.

Apple OS a Threat to Microsoft - Yes, But Not For The Reasons You'd Think

A few days ago a friend pointed me to an article that Gary Morgenthaler wrote for Business Week. Gary's main thesis is that Apple's products have a huge momentum in the market and that they are taking away market share from Microsoft. I agree with that thesis. What I don't agree with is the evidence he presents to support his thesis.

His theory is based on four main points:

  1. Apple <a href=""Spaces feature allows the user to run Windows applications and the Windows OS from within Apple OS X;
  2. The adaptability and flexibility of the Apple core OS X kernel allows Apple to move faster than Microsoft;
  3. As large companies become more mobile, Apple is strategically positioned to take a big bite of that market with its line of laptops and the iPhone; and
  4. Apple software development kits allow independent software vendors to create applications that run on OS X. I want to address each of these points individually.

Apple Spaces

Gary wrote Instantly you switch from a Macintosh operating system to a Microsoft Windows OS. He then adds This easy toggling on an Apple computer, enabled by a feature called Spaces,... and further down he continues Windows users, in the very near future, will be free to switch to Apple computers and mobile devices, drawn by a widening array of Mac software, without suffering the pain of giving up critical Windows-based applications right away.

He is mistaking a Virtual Desktop (VD) for a Virtual Machine (VM). Spaces is a VD, a feature that allows the user to work on more than one desktop at a time and to toggle a desktop from foreground to background and vice-versa. The type of software that allows the user to run an OS within another is a VM. There are also emulators that provide a compatibility layer, which is usually implemented as a library, and come in the form of Wine for Linux or Cygwin for Windows. Maybe Gary was thinking of Apple's Boot Camp feature that acts as a boot manager for OS X.

But I want to give Gary the benefit of the doubt and assume that he means a VM rather that a VD. A VM, however, does not give a strategic advantage to Apple. VM software is an ubiquitous commodity: There are VMWare, Parallels, VirtualPC, QEMU, and Xen just to name a few. This is more of a liability to Apple and to illustrate what I mean I want to rephrase one of the sentences I quoted above from Gary's article: Windows users, in the very near future, will be able to run Apple OS X from within Windows, without suffering the pain of paying for the Apple hardware premium. VMWare itself uses its own software to run OS X on Dell and HP computers.

The ability to run Windows OSs and applications on the Apple hardware is also facilitated by the fact that Apple has switched the CPUs in its entire product line to Intel. This also means that Apple has ported OS X to run on Intel chips. Which, in turn, means that OS X can, in theory, run on any Intel based device. As a matter of fact, many have already hacked the Apple OS X to run natively on non-Apple hardware and VMs.

OS X Kernel Flexibility and Adaptability

If you define flexible and adaptable as susceptible of modification and able to adjust oneself readily to different conditions, respectively, then the Apple OS X kernel is none of the above. At the core of Apple OS X is an operating system kernel that is based on the Mach kernel.

Mach implements a microkernel architecture, which means that the kernel itself provides only essential core services such address space, process management, and inter-process communication. The core of a microkernel architecture rarely changes. What changes are the other OS services (Memory manager, Networking, etc.), that don't necessarily run on kernel mode, and drivers as well.

Apple sells three models of laptops and three models of desktops. All of these devices have essentially the same exact innards across the board. What changes is the form factor. Equal hardware devices and peripherals require equal drivers and software across the entire product line. The OS does not have to change one bit to support that. Any changes can be supported with drivers for the different hardware components.

Windows, in the mean time, has to run on several different form factors of laptops and desktops, and several of them have manufacturer specific devices built-in. The Windows kernel, in this regard, is the flexible OS kernel, not the OS X kernel. The irony here is that Rick Rashid, Microsoft's Senior VP of Research, contributed a lot of work to the Mach kernel 17 years ago when he was affiliated with Carnegie Mellon University.

When Apple decided it was time to go through a major real change, it took them a year and a half to make the necessary modifications to the core of OS X. In June 2005, Apple announced that it would switch to Intel processors across the entire product line. They didn't actually ship the first Intel-based Mac until January 2007. Microsoft did take almost six years to ship a new OS and this is more of a reason for the current rise in market share for Apple. The Linux core group of developers, on the other hand, can crank out work like this in less than six months. I say that Apple's ability to deliver on major changes to its core technologies is above average for a large company. But it is not as easy as Gary has alluded to in his article.

Apple Products in Large Companies

Gary writes that Apple's products are well positioned to take off in the enterprise world. I will argue that most enterprises are going to compare a Lenovo or Dell laptop to an Apple laptop and say that they can't justify the extra cost of the Apple machine. Apple's products are well positioned to gain a lot of market share in the consumer market, however. I will discuss this again further down.

Gary also writes that Apple's recently introduced Leopard servers compete in a market of unhappy Vista server buyers... Vista server has not been launched yet. The current server offering from Redmond is Windows Server 2003, and it is doing very well still.

He also mentions that the iPhone will gain corporate customers for Apple because it will soon provide corporate email access and calendaring. I am wondering how it will accomplish that when the business is running an Exchange server and there isn't an Outlook client for the device.

Apple SDKs

An OS by itself has never really meant that much as a strategic advantage for any company. What really means something is the number of independent software vendors writing applications that run on your platform. Microsoft became what it is today because it understood this fact 20 years ago.

The fact that Apple has an SDK for the iPhone or for its lines of computers means that more Windows applications will be ported to OS X. But it doesn't necessarily means that the Mac or the iPhone will have more applications that run exclusively on them.

What OS X needs is a killer app like the Apache web server is for Linux and Office is for Windows. Some may argue that Photoshop is the killer app for the Mac, but it isn't exclusive to the Mac like Office and Apache are mostly exclusive to Windows and Linux.

Why is Apple Really a Threat to Microsoft

There are four reasons why Apple is a threat to Microsoft now. Gary hints at one of them in his article, but he doesn't explore it further.

The first reason is that Microsoft has really messed up bad with Windows Vista. Users and developers who in the past were willing to put up with Windows annoyances, have now left the platform in droves to Apple OS X or Linux. There is evidence of this everywhere: Dell went back to offering PCs running Windows XP and other free operating systems. Other PC manufacturers have followed suit. Developers are blogging about it. All this without mentioning the class action law suit filed against Microsoft on behalf of Vista users.

Second, Apple is not a hardware nor a software company. Apple sells cool. Their main product is the coolness factor and their technology is just an enabler for them to market the coolness factor. Cool has appeal to the masses and people are willing to pay a thousand dollars more for it. Cool is Apple's purple cow. People are willing to care about you, as Seth Godin so eloquently puts it. People are willing to be irrational, as those who, in one breath, say that they don't want to be locked into the Microsoft platform, and on the next breath, they buy into the Apple lock in. Apple locks you in even more than Microsoft because they control the whole experience: hardware and software. How does Apple get away with that and Microsoft doesn't?

The third factor is that Apple is able to do work under a veil of secrecy that none of its competitors can achieve. There is a great article on April 2008 Wired issue that explains how this works. In a nutshell, Microsoft has to share product plans and release schedules with its OEM partners so that hardware and software releases match. Apple doesn't have to do that for obvious reasons. Apple was able to work on the iPhone platform for three years before anyone even realized what they were up to.

The real ace up Apple's sleeve is Steve Jobs, though. He's known for being very hard to please and even a jerk at times, but he has charisma and inspires people to do great work and overcome insurmountable odds.

I am curious to know what you think.

XO: First Impressions

I had the XO for a few days now and I had the opportunity to play with it a little bit. The device is small; smaller than I expected. And, yet, it packs a lot of punch for the size and the components inside. It's definitely slower than your top-of-the-line two core machine, but you are not left twiddling your thumbs while waiting for things to load.

The screen presents great sharpness of image and is big enough for 99% of the tasks that I will ever perform with it. I'm not going to use the XO for extensive programming tasks, for instance. But the XO is great to take on trips with the family just to check on email and surf the web.

I have large hands, so the keyboard is unusable for me. Thankfully, I can easily plug my HHKB into one of the three USB ports and use it instead.

It comes with a built-in wireless network card that connects right up to my wireless network at home. I also read a little about the mesh networking capabilities of the XO, but haven't had the chance to actually play with it first-hand yet. Mesh networking is a fascinating technology, though.

A little perk that comes attached to the XO version that I have is the free year of T-Mobile HotSpot access. I activated mine today and it works like a charm.

The OS is a modified version of Fedora Linux, so I'm sure it is highly customizable. This weekend and the next few days I will be doing a lot of reading at the Laptop wiki site. They have an amazing amount of really great information about the machine itself, as well as projects and lessons to do with the kids. I also found some very useful posts by Bill Clementson about his experiences with his XO.

Anyway, I will keep you posted.

The Blinking Cursor

A friend asked me the other day what is The Blinking Cursor. It represents a space where everything is simple and uncomplicated. A place where there are no deadlines or budgets and technologies stand on their own merits rather than a ROI analysis.

Circa 1983, I got my first computer: a Sinclair ZX Spectrum 16K. The blinking cursor of my Spectrum was always there waiting for me, like a boy's first puppy with its tongue sticking out, as if saying come play with me.

I long for the blinking cursor, and this is the space where I write and share my feelings about technologies that take me back to the old state of mind.

New Toys

Today there were two packages in the mail for me: A XO Laptop from One Laptop per Child and a Happy Hacking Keyboard Lite 2. Those are my new toys.

HHKB

HHKB Lite 2

Back in November I paid $400 for the XO during the period when the OLPC was sending you a laptop if you donated the other one to a child in a third world country. Mine arrived today as the OLPC where having some supply problems. Technically, the XO is for my children, but since the twins are at age three now, I will experiment with it on my own also.

The new OLPC XO

XO Laptop

The purpose of the HHKB is to help me become a better, more efficient typist. I am writing this note with it and so far I like the way it feels, but it is a little weird due to different key positions. We will see how this goes.

The OLPC XO and HHKB

Perfect Match