I always preferred accessing assets from the web root like this <img src="/images" /> or in my css as url(/images). Simple, consistent.

However, when forced to delve a little deeper, I had to make some additional distinctions.

First, “/” starts at the web root (obviously), but what’s the root if the page is accessed by the filesystem (e.g.
<base href="file:///C:/Documents and Settings/bentrupk/project" />)? It’s after the 3rd slash. If for some reason you need/want to work locally from the filesystem, you’ll probably need to switch to relative URLs.

So when you say “./”, is it relative to current page or the asset that loaded it (e.g. css files)? What if you have a base tag? The answer is that it’s relative to the base href (if it’s set). Otherwise, it’s relative to the page or the css file that referenced it.

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