Bookmarklet: Scroll to the first new tweet

The Twitter web interface polls for new tweets and displays a notification when any are found. Clicking on that notification will show all of the new tweets. I've found there is a point with a relatively small number of new tweets – between 30 and 200 – where I want to skim them all, but it's a hassle to return to the position where I left off reading.

New Tweets Notification

The visual indicator for the newest tweet is very subtle and virtually unnoticeable while scrolling fast.

Newest Tweet Indicator - A slightly darker line

Solution

It's a fairly simple problem to solve with a bookmarklet – a tiny bit of javascript that is manually executed by opening a bookmark.

Right-click and bookmark the following link, or drag it to your bookmarks toolbar or menu: First New Tweet

This may not work in a feed reader. If that's the case, manually add the bookmarklet or view the original post. Internet Explorer may prompt you about adding a Favorite that is not safe; ignore that, or get a better browser.

There is a known bug (#86643) affecting some versions of Chrome that results in a bookmark that does not contain a name. Right click and Edit the bookmark to fix that.

To use the bookmarklet, open it the way you would a normal bookmark. If there are new tweets, the browser will automatically scroll to the oldest new tweet – which will be right above the last tweet visible prior to loading the newest tweets.

Read more about bookmarklets at Wikipedia.

Source Code

Unminified code, complete with a modified version of Dustin Diaz's getElementsByClass to accommodate Internet Explorer. I briefly tested this on Google Chrome 13, Firefox 4 and IE 8. This isn't meant to be pretty.

javascript:(function(){
  if( document.getElementsByClassName ) {
    var t=document.getElementsByClassName("last-new-tweet")[0];
    if(t) {
      window.scrollTo(0, t.offsetTop + t.offsetParent.offsetTop );
    }
  } else {
    var els = document.getElementsByTagName("div"), elsLen = els.length, pattern = new RegExp("(^|\\s)last-new-tweet(\\s|$)");
    for (var i = 0; i < elsLen; i++) {
      if ( pattern.test(els[i].className) ) {
       window.scrollTo(0, els[i].offsetTop + els[i].offsetParent.offsetTop );
       break;
      }
    }
  }
})();

Minified code, in case you'd like to manually create your own bookmarklet.

javascript:(function(){if(document.getElementsByClassName){var t=document.getElementsByClassName("last-new-tweet")[0];if(t){window.scrollTo(0,t.offsetTop+t.offsetParent.offsetTop);}}else{var els=document.getElementsByTagName("div"),elsLen=els.length,pattern=new RegExp("(^|\\s)last-new-tweet(\\s|$)");for(var i=0;i<elsLen;i++){if(pattern.test(els[i].className)){window.scrollTo(0,els[i].offsetTop+els[i].offsetParent.offsetTop);break;}}}})();

Unhide the Library folder in OS X 10.7 Lion

If you're running one of the 10.7 Lion Developer previews, you've probably noticed that your ~/Library folder is hidden. You can navigate to it by pressing CMD+SHIFT+G and opening the Go to Folder window and entering ~/Library or you can use chflags command and remove the hidden flag.

Open a new Terminal window and run the following command:

chflags nohidden ~/Library

Dear RIM, plan for the future.

I've often wondered why my BlackBerry Torch doesn't recognize the stereo headset from my iPhone, and in such an incredibly poor way. If you plug in the headset, which has a four conductor TRSS 3.5 mm plug (there are three colored plastic rings on it), the BlackBerry continues to play audio through the built-in speaker, and the only thing coming from the headset is what sounds like something shorting out.

A little time on the TRS connector Wikipedia page suggests that this is exactly what's happening. Emphasis mine:

TRRS plugs do not work properly with a TRS stereo jack if the ground contact in the jack connects to the microphone contact on the plug. It is therefore a good practice to implement new TRS headphone jacks using actually a TRRS mechanical jacks and connecting ground to sleeve as well as the second ring contact. This way such jacks will provide better compatibility with different TRRS cell phone headsets.

So RIM used an old TRS jack with a poorly placed ground and now any TRSS plug will short it out. This is unique for the Torch, and isn't an issue for any of the other half-dozen BlackBerry devices I regularly use. The utility of the volume controls on a $29 headset is enough that I don't even bother using the $400 Torch as a phone anymore.

Regenerate SpringBoard on a jailbroken iPhone

Useful if you're installing packages from the command line and want the homescreen icons to be visible.
Install UIKit Tools (apt-get install uikittools) and from the command line run sudo -u mobile uicache

If sudo isn't installed, install that with apt-get install sudo or

su mobile
uicache

And while you're on the command line, make sure to change the password for the root and mobile users.

  1. SSH to your iPhone
  2. su -
  3. Enter the root password, alpine by default.
  4. passwd
  5. Enter your new root password
  6. passwd mobile
  7. Enter the new password for the mobile user

© 2007-2012, Corey Gilmore | Posts RSS Feed | Comments RSS Feed | Contact

 

The views expressed on these pages are mine alone and not those of any past or present employer. All information presented on this site was obtained lawfully and not through disclosure under the terms of an NDA.