Thursday, June 30, 2011

Changing the default google domain in Chrome

On a mac, make sure that you closed the Chrome browser.

Go to

cd ~/Library/Application\ Support/Google/Chrome

and edit the 'Local State' file,
change the following lines to whatever google domain you want.

"last_known_google_url": "",
"last_prompted_google_url": "",

start the browser.

If you use profiles you have to go to that profile folder and change the 'Local State' file there
cd ~/Library/Application\ Support/Google/Chrome/[PROFILE NAME]

Application Cache whitelisting the master entry

An application cache is a set of cached resources consisting of:

Master entries
These are documents that were added to the cache because a browsing context was navigated to that document and the document indicated that this was its cache, using the manifest attribute.

Explicit entries
These are the resources that were listed in the cache's manifest in an
explicit section (CACHE).

Fallback entries
These are the resources that were listed in the cache's manifest in a fallback section.

The resource that declares the manifest (with the manifest attribute) will always get taken from the cache, whether it is listed in the cache or not, even if it is listed in an online whitelist namespace.
This means that your HTML that includes the manifest file will be always a master entry which is cached and accessed from the cache even the client is online.
Let's face it, this is a pain in the neck in same cases.

There is a simple workaround
1. create an OTHER HTML that will include the manifest file
2. from the ORIGINAL HTML remove the manifest include and create an iframe that includes the OTHER HTML

In this case the master entry will be this OTHER HTML, which does not affect whitelisting the ORIGINAL HTML.

I'd like to emphases that this is just a workaround and i'd like to have a better solution.

You can also follow the related whatwg discussion.

Tuesday, June 28, 2011

Migrating to Dotcloud CLI 0.4.x with 'pip: error: no such option: -u'

Checking the version number
$ dotcloud --version
DotCloud CLI version 0.3.1

Installing Pip (it is a tool for installing and managing Python packages)
$ sudo easy_install pip

Installing the dotcloud CLI 0.4.x
$ sudo pip install --upgrade dotcloud

In the dotcloud migration document they use pip -U but in Pip version 1.0.1 there is no such an option.

Checking the version number again.
$ dotcloud --version
DotCloud CLI version 0.4.0

All right.

Friday, June 24, 2011

Image width/height with Imagemagick in Command line

Imagemagick comes handy when you need information from an image.

# width
w=`identify -format "%w" image.png`

# height
h=`identify -format "%h" image.png`

More information on Imagemagick's identify.

Friday, June 3, 2011

URL shortener algorithm

Here is a simple hashing algorithm that generates a short string for a given ID. This can be used for example in an URL shortener where you store the full URL under an ID and use this algorithm to generate a sort string to reference that ID.

more on that on stackoverflow or on