I found discovered a couple sites that I want to share this morning.

The first is Commandlinefu.com. There are some really great gems here.
I also appreciate the twitter feeds for their most up voted (thus most useful) commands.
+3 votes
+10 votes

Also I’ll be watching this WP plugin. It looks very promising, but until I get some time to play with it or it becomes more popular/tested, I’m skeptical that it’ll accomplish what it claims without possibly breaking some things.

A couple of useful snippets to use in the console ….

// sometimes you want to quickly count all elements in a page
// to see how heavy it is. when you have more elements,
// it takes longer to search all of them in your RIA
document.getElementsByTagName('*').length;

// add a stylesheet dynamically
// this can be useful when diagnosing a print css file
// or any instance when certain styles may not be applied
// until a particular context or event
var fileref=document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", '/css/my-css-file.css');
document.getElementsByTagName("head")[0].appendChild(fileref);

Notes:

Marissa Mayer of Google talks about a better, faster, stronger web.

4 key elements of search
-comprehensiveness
-relevancy
-user experience
-speed

Web Index (pages) @ Google
1999 – 30,000,000
2009 – 300,000,000,000 (*10K more!)

Searches per day
1999 – 100,000
2009 – 1,000,000,000

UxD – how does Google make Google better?
A-B Testing!
Scenario: # Results: 10, 20, 30?
Users said “Give us 30 results per page”.
However, 30 results lead 25% fewer searches (when accounting for just 1st page results).
Why? It took longer.

Google Reader – made it faster in 2009! Users enjoyed it more.
What happened? “HTML wants to square.” Removed rounded corners and viewership went up.

Google Checkout – made a graphic into html via a table. User experience improved.

Google News – Tables “flash render” – user smaller tables if (used for layout) rather than one big table. KHB: Why not float divs?

Search Results – Chunked encoding – Google header is always non specific to results so it can be sent first independently.

Google Maps – Compressed images more.

Images 101: Small images cost $1.00, big images cost $1.01.

< 50% of Google users are on fast browsers.

*nix Commands

In: Uncategorized

13 Aug 2009

Because I’m prone to forget some of my useful, extended, piped commands, I though I would post a few:

Search specific file types for phrases, print the line numbers, dump the errors:

find -regex ".*\.ext$" | xargs grep -n searchText 2> /dev/null

Search specific files and mod only matching files via sed (creating .old backups)

find -regex ".*\.ext$" | xargs grep -l searchText 2> /dev/null | xargs sed -i.old 's/searchText/replaceText/g'

Find recently modified files
Ex. modified in the last 30 days

find -mtime -30 -type f

syntax note: -X: modified within X, X: modified exactly X ago, +X: unmodified for X

Find modified files in CVS
Ex. find files that you since Aug 1 (-D is very flexible with date formats)

cvs history -c -D"August 1"

Replacing Windows EOL (Seriously, I still come across this!)

# Press Ctrl-V then Ctrl-M to get ^M
sed -i.old 's/^M/\n/g' index.jsp 

Of course, you may have the dos2unix command available. Simply,

dos2unix oldfile newfile

Some useful CVS commands

#compare to versions of a file
cvs diff -r 1.1 -r 1.2 file

Find all files of a certain type and size and add them to an archive file.

find . -name "*\.css" -size +1b | xargs tar cvf css.tar

I picked up a few more performance tips from this article. Notably, to make links consistent by case. You’re liking already doing this as a single developer or perhaps a small team, but if there are many developers, I can imagine inconsistencies. Also you should always close your tags. If you’re writing proper XHTML, I’m sure you already are.

From this presentation, I picked up a few more tidbits. Never use the with statement. When it’s used, the javascript processor will have to examine the object (up the prototype chain) and the scope (up the scope chain) leading to expensive look-ups.

Never use eval if possible. This includes sending javascript strings to setTimeout and setInterval. Evaluated code must be compiled and interpreted.

Also this post discusses the potential security concerns and memory leaks associated with innerHTML.

Lastly, I want to point out an old tool that I was recently asked about for an IE6 problem. Drip can be useful for detecting those IE6 problems.