Feeds:
Posts
Comments

Most useful websites use some form of pagination. However, link relations are not in widespread use.

I liked the explanation:

Regular links (<a href>) simply point to another page. Link relations are a way to explain why you’re pointing to another page. They finish the sentence “I’m pointing to this other page because…”

I know a few sites which, to my “View Source” surprise, make use of <a rel="next">.

I wrote a jQuery version under 5 minutes, but not all pages have jQuery. Adding jQuery to the current page is relatively simple (although not trivial: follow the evolution of the jQuerify bookmarklet here, here and finally, here) but the complexity of “importing” jQuery overtakes the even simpler task of finding an <a> tag with a rel attribute.

I also found a Prototype version which … wasn’t working … but …

I don’t need a JavaScript framework: I decided to use the browser DOM 3 XPath which would work on any browser I care about:

Anytime you are looking for a specific node or set of nodes buried inside of a document, consider using XPath to speed up the process in Firefox, Safari, Chrome, and Opera (Internet Explorer doesn’t support DOM 3 XPath).

Here’s the code:

location = document.evaluate(‘//*[translate(@rel,"NEXT","next")="next"]‘,
                             document,
                             null,
                             XPathResult.FIRST_ORDERED_NODE_TYPE,
                             null).singleNodeValue.href

A few notes:

  • the rel attribute may be attached to either a <link> or an <a> tag
  • I used translate to make the value of rel case-insensitive
  • there should only be one rel="next" on the page, the script grabs the first one (a reasonable compromise)

Since I can’t seem to be able to embed a bookmarklet in WordPress, here’s a page where you can grab it.

git add -i

I recently found out about git add’s interactive mode.

Yes, it allows you to add/revert files in/out of the index without typing the filenames … but, more importantly, it allows you to add only certain lines of a file rather than the whole thing.

Just watch GitCast #3 (4:24) and see how useful it can be.

This is the kind of stuff I used to do manually at commit time. Developing a feature is not always a linear process, but I still want my commits to be cohesive (an idea developed in the atomic coding screencast).

Ending up with messy commits is easy. This is especially true for my config files: I usually make changes and give them a few days before committing them. If I make other changes in the config files (while I’m hanging around there anyway), the result is a bunch of unrelated config changes.

Initially, I wrote this Vim plugin to emulate TextMate’s cmd-t functionality.

Here’s what you get:

  1. type ESC-t
  2. you get a new buffer filled with the “find” command
  3. search for the file you want with /
  4. press ENTER, it opens the file under the cursor

I consider this an 80/20 solution … it does most of what I need and it’s under 50 lines of code.

Review the code on github and download it here.

The plugin is also featured in this screencast.

What do you see when you open your browser?

Is it a blank page? (Nothing is faster!) Or is it a convenience page? (google.com?)

I open a new browser tab/window in two circumstances:

  1. I want to search something
  2. I want to open a bookmark

For problem #1, I used yubnub for a long time. Yubnub is supposed to be “a (social) command line for the web”, but to me the only interesting aspect is user-contributed search engine shortcuts. You want to use Google image: “gim hajime no ippo”. You want to use Google map: “gmap olympic stadium, montreal”. But it goes further, yubnub provides direct access to the search engines of specialized sites: amazon (.com/.ca), bestbuy, tigerdirect, apple trailers, newegg, the pirate bay … the list goes on and on. (There’s a command to find a yubnub command: ls) The idea of having to first go to a website and THEN do a search seems so backward to me … so 2001.

For problem #2, if you don’t want to go insane and have many computers, you have to look into synchronizing your bookmarks. What a pain! In fact, yubnub served as a kind of bookmark for sites I would do searches on … but there is still a list of other sites which don’t fit that pattern.

Here’s my solution to all these problems: home.acidfog.com.
default home page

Pretty simple, no?

Here’s the breakdown:
analysis1

  1. the logo: thematic
  2. the search field
  3. JavaScript-hijacked submit button
  4. JavaScript-hijacked “show links” anchor

When the page loads, the focus is placed on the search field automatically. On submit, it looks up in my JavaScript yubnub clone. Clicking on “links” makes a list of bookmarks appear. Finally, the page captures the “ESC” key and also shows the bookmarks. (vim habits)

I captured the essence of yubnub and distilled it into my own JavaScript code. This allowed me to completely stop using yubnub which was sometimes slow and sometimes down. Also, I’m not too keen on having yet another trace of EVERYTHING I’m searching appearing in the yubnub’s log files.

Another downside of using yubnub is that you have to agree with the shortcut command picked by the community. Since it’s my code, I can pick what I want.

Feel free to steal and extend on the general idea here.

This year, I’m going with SMART resolutions. I’m looking for statements like: one [thing] per [time period]. On the technical side, I’ve got:

  • half an hour of reading code per day
  • one (programming) project per month

I’ve got ~8 items on my list, but the 2 above are the ones I decided to do.

I’ve always found reading other people’s code challenging. (I might not be alone.) In a true agile way, I believe that if it hurts do it more often. This year, I’ll crack open a lot of code and force myself to read through it.

As for projects, 12 throwaway projects are just what the doctor ordered. These will serve multiple purposes:

  • force myself to code “crazy” things I wouldn’t normally invest time into
  • expose myself to more topics
  • serve as programming exercises

There are no downsides!

I bought a span-a-year wall calendar and I’m going to follow Seinfeld’s productivity secret.

I know resolutions are cheesy. However, by only picking a few in the might-have-done-anyway category, I’m setting myself up for success.

Bash’s $PS1 variable is what you see every time you get a prompt. It’s there, waiting for you to type something.

Some people go minimal … maybe just “$” like the Bourne shell. Others go crazy and cram as much information as possible … on multiple lines … in colors.

My $PS1 falls somewhere in the middle, but I realized today it was time for a change. One of the things I wanted was the current path. A lot of people like to put that in the “xterm title bar”, but I wanted it closer to the action.

After a bit of experimentation, I found that I could play with the PROMPT_COMMAND to faux-position the path in pale gray ON the same line as the prompt.

Here’s my variables.sh file which I put under ~/etc/bash/local/ — it works with the rest of my config files:

function prompt_command() {   

  printf \e[30;40;1m%*s\n\e[0m\e[1A" $COLUMNS "$PWD"

}

PS1="\[\e[31;43m\]\u@\h\[\e[0m\]

PROMPT_COMMAND=prompt_command

export LANG=”en_US.UTF-8

export LC_ALL=”en_US.UTF-8

export TERM=”xterm-256color

export FIND_OPTIONS=”-name .git -prune -o -name .hg -prune -o

The prompt_command function uses “printf” to print ($COLUMNS wide) the $PWD. There are escapes sequences to color it gray. Finally, the “\e[1A” sequence moves the cursor 1 line up. Consequently, the prompt itself prints on the same line as the PROMPT_COMMAND.

It looks something like:

terminal

What do you put in your $PS1?

I never intended to make money with booklife. There were 3 objectives for that project:

  1. Practice Rails.
  2. Track my books, obviously.
  3. Be able to track my friends’ books.

Consequently, booklife has already fulfilled its purpose.

I’ve received feedback, but there’s only finite time I can invest in developing new features. Making booklife open-source would allow people to contribute and scratch their if-only-there-was-that-feature-I-would-use-it itch :-D

The code can be found on github. Clone it, fork it, patch it — please — I’m looking forward to learning something from you.

Booklife update

Since booklife went up (December 7th), I’ve added the following features:

  • logo links back to login page
  • “add to my books” link when looking at other people’s books
  • a direct link to amazon from the ISBN
  • per user RSS feed

Subscribe to a user by clicking on the “RSS” icon in your browser.

Here’s my RSS feed.

I created a short screencast (3m40s) to show the ctrl-key shortcuts in action. I’m always surprised that people don’t know/use these more.

Cheatsheet:

shortcut what does it do?
ctrl-l clears the screen
ctrl-u erases the whole line
ctrl-a brings cursor to the beginning of the line
ctrl-e brings cursor to the end of the line
ctrl-k erases from cursor to the end of the line
ctrl-w erases the last word – the the previous space
ctrl-y pastes what you erased
ctrl-f erases the last word – to the previous slash
esc-. pastes last argument of previous line
esc-, completes, shows each match one-by-one every time it is pressed

Customizations from my .inputrc:

"\C-f": unix-filename-rubout

"\e,": menu-complete

I read a lot … enough to write a webapp to track what I want to read, what I’m reading and what I read. I give you booklife.

Booklife is an application to scratch one of my itch.

How I use it:

  • when I hear about a book, I put it somewhere in my lists
  • when I’m batching books to get the free delivery, I pick from my “to buy” list
  • when I’m planning to go to chapters/indigo, I print out a list of books to check out

Because it’s multi-user:

  • I can check who read what books, maybe to get a recommendation, maybe to borrow them
  • you can get a feeling from people based on the books they read

I’m going to let people use it for a while and see where this goes.

What now?

« Newer Posts - Older Posts »