Clickable Custom Header in WordPress (.com) using Sandbox theme

Beside this minimalistic blog, I have another blog (that is actually more of a web-site) for which I decided to go with the Sandbox Theme, cause I wanted to customize my page. Yes, you have to buy the Custom CSS upgrade (10 bucks.. a year?!).

One of the most difficult (less documented) tasks has been to change the blog title with a custom image and keep it clickable, so that users can always come back to the main page easily.

The only tutorial I found that is still online is this, as well as some posts in which sunburntkamel (the author) talks about it.

The trick is to expand the a element to the size of your image, and display the title itself off-screen.

My title is center-aligned, so this is the code:

#blog-title {
margin: 0 auto;
position: relative;
width: 361px;
}

#blog-title a {
background: transparent url('http://myblog.files.wordpress.com/2011/06/my_logo.png') top center no-repeat;
display: block;
height: 250px;
text-indent: -9999px;
}

So, as you can see, the text is 9999 pixels left of the display, and the image is as large as the clickable portion of the page! yippie!

Advertisements

Escape slashes in shell script variables with sed

sed is a tool of wonder, the in-place replacement (or deletion) of lines in files matching some regexp being my favorite use of it. But some basic functions are quite under-documented (the same old problem of powerful commands having man pages just too long to be read thoroughly).

What I wanted to do is to drop all lines in a file containing a path stored in a variable in my bash script. Problem is, slashes must be escaped for sed to understand that it must treat them as literal, but I have a reference to a variable so I just can’t do something like

sed -i \/path\/to\/delete/d /path/to/file

I found out (on this thread on stackoverflow) that you can use any character you want as separator, and one thing that is usually not known is that you must escape the first occurrence of the separator to have sed use it, unless you are using the s command (replacing patterns, as in sed -i 's/abc/def/' file, while I’m only deleting matches).

So, this is it:

PATH_TO_BE_DELETED="/path/to/delete"
sed -i "\,$PATH_TO_BE_DELETED,d" /path/to/file

I used commas as I know that my paths won’t ever include them, but you can use whatever you want or need.

Note that you also have to use double quotes instead of single ones, or your variable is interpreted as literal!

A nice list of useful one-liners for sed can be found here.