Archive

Archive for the ‘hacks’ Category

Scoped Tweets to reduce noise for your followers

May 1st, 2011

I've been using a technique for a while now to reduce twitter noise, and I suppose it deserves documenting. I like to keep my tweet volume low (specifically your regular broadcast tweets, rather than replies.

When attending a conference…

I'll oftentimes write a tweet as a reply to the conference's twitter account. For example, I'm off to JSConf right now. So I might do

@JSConf just landed. here in PDX. anyone wanna share a cab? also beerz. nao.

Similarly when using twitter as the backchannel, I don't search just the #jsconf hashtag, but purely 'jsconf' so I get both the hashtags and the replies.

When targetting a smaller portion of your followers…

Sometimes I wanna tweet some info that's interesting to only some folks, like strictly people interested in javascript language details or straight up designers. I'll pick a pretty popular person in that area and shoot it of almost like a reply to them:

@kangax et al, Annotated ECMAScript 5.1 now @ http://es5.github.com incl. links to MDC and @DmitrySoshnikov's research

Wha?

This all makes sense because of how twitter handles replies. If I reply to @homeboy1 and you don't follow him, you don't see that one in your timeline. If you do, you do.

So there it is.. mostly I see it as a polite thing to do when at a conference and the rest of your followers want to put you on mute for 3 days. :)

Paul Irish hacks

Get Gyazo for seriously-instant screen-grabbing

January 22nd, 2009

I've been a big proponent of Jing for screencapture for a while. I still love it, and it's top notch for sharing video, but I've come to enjoy a free tool called Gyazo for screenshots. Both of these tools are invaluable when it comes to web development QA.

Below you'll see a screencast demonstrating gyazo to the #jquery IRC channel:

Both Jing and Gyazo provide hosting for you (infinite, eternal store, as far as I've seen), and they both automatically copy the url to your clipboard. Gyazo is a bit quicker for images, and also doesn't have a business model, which is comforting. :)

And it's cross-browser as long as you don't mind some Japanese text:

Oh and open source. :) I think you can even host your own image repo if you don't want to use gyazo.com.

Handy tip, keep the shortcut somewhere totally handy. On Windows, I keep mine with the quick launch icons.

2009.10.07: I'm now self-hosting my gyazo images thanks to Ben Alman who ported the ruby upload script to PHP.

Paul Irish hacks

How To: Speed Up The MacRumorsLive Ajax Refresh

June 9th, 2008

title_macrumors.gifBy default, MacRumorsLive polls the server for updates only every 60 seconds. I know, I know.. <enter sad puppy face here> If you're like me, you probably want that action with a touch more zip to it! And thus…

To poke the server every 10 seconds for a new update, drop this badboy into the location bar on your MacRumorsLive tab and hit enter:

javascript:(function(){var booyah=10,str='ro[0].firstChild.nodeValue',countdown='document.getElementById("ti").innerHTML  = (rr-x) + " seconds till next update..."; setTimeout';rr=booyah;eval('d = '+d.toString().replace(str,booyah));eval('ppd = '+ppd.toString().replace(str,booyah));eval("l = "+l.toString().replace('setTimeout',countdown));x=5;})();

btw- this doesn't work in IE. Deal with it.

Update (11:41am): It now has a countdown till next update. countdown.PNG

Paul Irish hacks

Quick internationalized sort in javascript

April 21st, 2008

Let's take a list of countries that was originally alphabetized in English, but is now translated to French.

var arr = ["Argentine", "Australie", "Autriche", "Belgique", "Brésil", "Canada", "Chili", 
"Chine", "Costa Rica ", "République Tchèque", "Danemark", "Équateur", "El Salvador ", 
"Finlande", "France", "Allemagne", "Guatemala", "Hong Kong", "Hongrie", "Inde", "Irlande", 
"Italie", "Japon", "Corée du Sud", "Luxembourg", "Mexique", "Pays-Bas", "Nouvelle-Zélande", 
"Norvège", "Panama", "Pologne", "Portugal", "Russie", "Slovaquie", "Espagne", 
"la Suède", "Suisse", "Turquie", "Royaume-Uni", "Uruguay", "États-Unis"]

You can see the incorrect sort order for Germany ("Allemagne") and the US ("États-Unis").
Running the standard javascript Array.sort() will sort it according to the American English language:

arr.sort();
/*==>
["Allemagne", "Argentine", "Australie", "Autriche", "Belgique", "Brésil", "Canada", "Chili", 
"Chine", "Corée du Sud", "Costa Rica ", "Danemark", "El Salvador ", "Espagne", "Finlande", 
"France", "Guatemala", "Hong Kong", "Hongrie", "Inde", "Irlande", "Italie", "Japon", 
"Luxembourg", "Mexique", "Norvège", "Nouvelle-Zélande", "Panama", "Pays-Bas", "Pologne", 
"Portugal", "Royaume-Uni", "Russie", "République Tchèque", "Slovaquie", "Suisse", "Turquie",
 "Uruguay", "la Suède", "Équateur", "États-Unis"] */

Note the misplacement of the last three entries. A real internationalized sort of this would be a huge motherbitch to implement, but here is a quick and hacky way to get your ducks in order:

  arr.sort(function(a,b){
 
    function normalize(str){
       return str
               .toLowerCase()
               .replace(/è|é|ê|ë/,'e').replace(/ò|ó|ô|õ|ö/,'o').replace(/ì|í|î|ï/,'i')
               .replace(/à|á|â|ã|ä|å|æ/,'a').replace(/ù|ú|û|ü/,'u');
    }
 
    a = normalize(a);
    b = normalize(b);
 
    return ((a < b) ? -1 : ((a > b) ? 1 : 0));
  });
/*==>
["Allemagne", "Argentine", "Australie", "Autriche", "Belgique", "Brésil", "Canada", "Chili", 
"Chine", "Corée du Sud", "Costa Rica ", "Danemark", "El Salvador ", "Équateur", "Espagne",
 "États-Unis", "Finlande", "France", "Guatemala", "Hong Kong", "Hongrie", "Inde", "Irlande", 
"Italie", "Japon", "la Suède", "Luxembourg", "Mexique", "Norvège", "Nouvelle-Zélande", 
"Panama", "Pays-Bas", "Pologne", "Portugal", "République Tchèque", "Royaume-Uni", 
"Russie", "Slovaquie", "Suisse", "Turquie", "Uruguay"] */

It's not perfect (I bet that "la Suède" should actually be in the S's), but it'll get you a bit closer without too much effort.

2009.10.29: A much better method:
  arr.sort(function(a, b) {
    if (typeof a === 'string' && typeof b === 'string') {
      return a.toLowerCase().localeCompare(b.toLowerCase());
    });

Paul Irish hacks, javascript

what makes you sustainably happy?

April 18th, 2008

i wonder about the personal fulfillment of:

  • doing what we think we should be doing
  • doing what we want to be doing
  • doing what we think makes us happy

because those three are certainly different..

Paul Irish front-end development, hacks

i left this space here for you to play. <3