Saturday, October 23, 2010

iTunes search with command f

To use Command-F to get to the search field in iTunes you have to execute the following in Terminal.

defaults write com.apple.iTunes NSUserKeyEquivalents -dict-add "Target Search Field" "@F"

You have to restart iTunes to make it work.

Tuesday, October 19, 2010

gitignore and already tracked files

If a file is already being tracked by Git, adding the file to .gitignore won’t stop Git from tracking it.

You’ll need to do

git rm --cached <file>

to keep the file in your tree and then ignore it.

Sunday, October 17, 2010

SVG JavaScript Libraries

SVG has been in development since 1999 and in 2010 we can say that all major modern web browsers except Microsoft Internet Explorer, support and render SVG markup directly. The Internet Explorer 9 beta supports SVG.

But dealing with SVG documents remained painful, don't despair there are JavaScript libraries to help.


Protovis
Great for data visualization.
It only works in browsers that have native SVG support.


Raphael
It's a good starter library, easy to do a LOT of things with SVG quickly. Well written and documented. Lots of examples and Demos. Very extensible architecture. Great with animation.

But note that there are ways of expressing things in SVG that are not possible in Raphael. There are no "groups". This implies that you can't implement layers of Coordinate Transfomations. Instead there is only one coordinate transform available.
If your design depends on nested coordinate transforms, Raphael is not for you.

It supports Firefox 3.0+, Safari 3.0+, Chrome 5.0+, Opera 9.5+ and Internet Explorer 6.0+.


jQuery SVG
Well written and documented. Lots of examples and demos. Supports most SVG elements, allows native access to elements easily.

It only works in browsers that have native SVG support.


SVG Web
It uses flash to render in non-SVG compliant browsers.

Monday, October 4, 2010

List open ports on Mac OS X

sudo lsof -i -P | grep -i "listen"

Monday, September 20, 2010

FDTG Principles for Developers

this is a small reminder for me no to forget these principles.

Flexibility
Be ready to change your plans when they’re not working the way you expected; don’t count on things remaining stable.

Decentralization
Centralized systems look strong, but when they fail, they fail catastrophically.

Transparency
Don’t hide your systems; transparency makes it easier to figure out where a problem may lie. Share your plans and preparations, and listen when people point out flaws.

Graceful Failure
Failure happens, so make sure that a failure state won’t make things worse than they are already.

Monday, August 23, 2010

HTML Comments as strings

Reading HTML comments from a DOM tree with JavaScript is easy.

var nodes = document.body.childNodes,
comments = [];

for (var i = 0; i < nodes.length; i++) {

// if the nodeType is 8
if (nodes[i].nodeType == 8) {

// this is a comment
comments.push(nodes[i]);
}
}

Let's say that the comments array is not empty, so the type of comments[0] is a Comment. That's great but how can you read its content?

This is what the W3C DOM-Level-1 spec says. It implements the Comment interface.

interface Comment : CharacterData {
};

This does not really help us but don't despair. It also implements the Node interface.

...
readonly attribute DOMString nodeName;
attribute DOMString nodeValue;
...

Yes, it's read-only but you can get the comment as a string by using its nodeValue.

comments[0].nodeValue


W3C DOM-Level 3 specifies something called textContent. This can also do the job, you can read about them here, textContent vs. innerText

Thursday, August 5, 2010

Blame does not fix bugs

It's always seems hard to deal with people. Here are few thoughts that I'd like to share.

Blame does not fix bugs, the outcome is important, not the credit, the blame, or the ongoing intellectual superiority contest.
You want to focus on fixing the problem, instead of blaming others.

Criticize ideas, not people, keep it professional, not personal.
Ask questions that allows someone to figure out the problem for themselves.

and there is one more thing, negativity kills innovation so be constructive.