Ubiquity tab count

I've been looking for ages for an easy way to show the number of tabs I have open without needing an extension.

(The problem is that Greasemonkey and such don't get access to the browser chrome, whereas extensions do)

Well, I compromised by installing Ubiquity.

Now an alt-space, 'tabs', will show "n tabs in m windows".

Here's the script:

CmdUtils.CreateCommand({
name: 'tabs',
description: 'Count the number of tabs and windows you have open',
icon: 'http://www.spreadfirefox.com/files/spreadfirefox_RCS_favicon.png',
author: { name: 'Joshua May', email: 'notjosh@gmail.com'},
homepage: 'http://notjosh.com/',
execute: function()
{
var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator);
var counts = this._count(wm);

var messageTemplate = '${tabs} tab${tabPlural} open in ${windows} window${windowPlural}';

displayMessage(CmdUtils.renderTemplate(messageTemplate, {
'tabs': counts.tab,
'windows': counts.window,
'tabPlural': 1 != counts.tab ? 's' : '',
'windowPlural': 1 != counts.window ? 's' : '',
}));
},
_count: function(wm)
{
var windowIterator = wm.getEnumerator('navigator:browser');

var window;
var counts = {
window: 0,
tab: 0
};

while (windowIterator.hasMoreElements())
{
window = windowIterator.getNext();
counts.window++;
counts.tab += window.document.getElementById('content').mTabs.length;
}

return counts;
}
});


Friday, November 7. 2008

0 Comments

Thunderbird 3 (Shredder) and Growl Notifications

Since formatting a couple of weeks back, I thought I'd give Shredder Alpha 3 a go (Shredder is just the codename for Thunderbird 3).

As far as functionality goes, it's pretty nifty. Having tabbed inboxes is nifty, but there's no tabbed compose window, which is my only real gripe.

Anyway, I wanted Growl notifications of new messages, so I installed the Growl Notifications add-on (which has served me well in past, and is in a sense the 'official' Growl add-on).

Well, it didn't work.

I got my debug on today, and saw that it was whinging about grINotificationsList not being defined. I dug through a lot of code, and ventured deep into Obj-C land, which was the second time in two days (two different projects), and mighty unfamiliar. Eventually I stumbled on this Mozilla bug to try and find the XPCOM change between 1.8 and 1.9 to patch the extension.

Long story short, Growl is now built into Thunderbird. You don't need an extension. Although, I needed to pull a nightly build to have it working. But that might have also been a conflict with the broken plugin.

I'm not big on the format (now it says "[emailaddress] has [n] new message(s)", instead of the subject/intro line that the old add-on had). I'm going to see if I can listen to an event and call it myself with my own format, but it seems the default response is hard coded in your platform's FillToolTipInfo method. Hm. At the very least, you can change the (new)BiffNotification_message(s) in messenger.properties.

I feel a bit unaccomplished now though - I've spent all this time figuring out what's going on, and now I've got nothing to show for it - no patch, nothing!

*finds something to work on with deliverables*

Thursday, November 6. 2008

0 Comments

No swap? No worries!

Well, tonight I solved an issue that's been bugging me a while. I now have a swap partition which is actually being used - already helping a lot!

The background: I'm hosting my site(s) on Slicehost on a 256mb VPS. I also run screen with weechat, which over time can consume an assload of memory. So every now and again, processes are just dying because weechat is taking over, and for some bizarre reason, I've got no swap.

Well, tonight I reclaimed my swap.

I initially thought I just never had swap to begin with - I'm a pretty early Slicehost adopter (two years now!), so I just thought early in the piece there were hiccups. Turns out an Ubuntu update somehow nuked fstab, and I'd never noticed.

The fix was pretty simple, I just found the new UUID by running `ls /dev/disk/by-uuid/ -al`, and updated fstab. `free -m` was still reporting no swap, though, and I didn't really want to reboot. Turns out `sudo swapon /dev/sda2` activated the swap, and suddenly it was all working perfectly.

So there you go. Swaptastic!

(A couple of hours in and it's already making massive difference. Why didn't I do this a year ago?)

Monday, November 3. 2008

0 Comments

Who needs a job anyway?

So, I'm unemployed.

Economic crisis and all that bollocks. They didn't foresee any more investment funding coming in before they ran out of cash..and with no actual revenue model (and userbase), the writing was on the wall. I found out on Thursday, and by Friday I'd handed in my laptop and it was all over.

There was a 50% "downsizing", which basically took them back to the team they had before the more recent of us started 9 months ago.

It was a pretty fun ride, and I learnt a lot of (useful) things. And as far as I know, I built the world's most secure and awesome OpenID provider ever. But now they don't have anyone to maintain it, I'm guessing it won't really ever see the light of day, which is a real pity - means I've got virtually nothing to show for my last few months at work. Sigh. I've gotta check my employment contracts and see if I'll be able to salvage it some other form..don't think it'll work though, really.

It's a bit of a prick of a time to be looking for work at the moment, too, given that Christmas is coming up, as well as OSDC, and two weddings in Canberra.

So, at least until the new year I'll be looking for some contract/freelance work to tide me over. Give me a yell if you've got anything for me, yeah?

In the meantime, I'm gonna spend some days getting some sadly neglected symfony plugins back up to scratch (as well as release a few new ones). Gotta keep busy, gotta keep goin' forward.

Tuesday, October 28. 2008

3 Comments

Lyrics: Off Minor - Some Blood

I scoured the 'net for ages looking for these lyrics. No joy. Then the sheet they were printed on randomly appeared again..so to save the hassle next time, I present Off Minor - Some Blood.

And, urm, if you're into Off Minor flip some beans on the tracks (available on vinyl or download). And think about the words, don't just remember them to be shouted next time you see them, yeah?

Anyway.. the lyrics. This is how they're printed. They don't seem to match word-for-word with what's sung, so, figure it out yourself.

Neologist

Neologist says:
"Whereas words once served a sentence now are sentenced,
serving our every agenda."
We pour poison
into the people's ear and yet they're still eager
to tip their heads.
And should you date search for what truth is
A twisted tongue will torture your thesis.
And should you say 'this is injustice'
A cunning mind will redefine what is is
This is not torture
This is not surveillance
This is not injustice
This is poetic license permitted by a nations silence

Some Blood

this fluid is confined to single file lines.
this life is allogenic
and it ruddy hues remind me that
you're in me but not of me,
from origins unknown.
in me but not of me,
your gift in anonymity draws
questions of identity.
the heterogeneity of me
and you, what separates us now becomes obscure.
diffusely lost in me, you still endure.

Everything Explicit

what's best left unsaid?
a speaker spend, a listener left with regrets in his stead
in a life of loss, silence can cost you more than you expect.
held tongues relate a bitter taste when prone to reminisce.
anamnestic, recipient absent, the circuit's dead
we live these linear lives unidirectional, towards an inevitable end
we must make everything explicit
that's how we left it: unsaid.
now i'm at a loss for words

To An Ex

"Oh, sweetest piece of me" you say "I've found your place in me has grown too small to fit and still grows smaller everyday"
The me in you has changed, the you in me still stays the same, each has no bearing on the other, so we could say of one another.
So sweetest piece of me, it seems we'll take each other piece by piece apart and place each in the safest place within our holding hearts.

No Conversationalist I

Regarding allegations that I am an extra-terrestrial,
she stated, somewhat sadly, "Unfortunately it's feasible."
I started to say "What can I say?" instead stopped and said no more
For I was born brain-backwards with words awkward,
Ending dialogues at forewords

Practice Absence

This is prophylaxis, a practiced absence, a safer distance.
He is a fine clinician to diagnose this, a sound decision.
This is a family practice, it's anesthetic, it's nonreactive.
This is a termination, a fine resemblance, but no relation.
At the end of all things.

Monday, October 27. 2008

1 Comment

I'm living a little better

I've been meaning to blog about a lot of things, but haven't made myself the time recently - weekends have been spent at the snow, and quite literally through winter days are shorter. Well, the sun's setting later now, and this weekend marks the first weekend toward summer where I'm not going to the snow.

This year has seen a fair chunk of positive change in my life, which I'm rather pleased with. I'm going to try and document it, so I can refer back to it if I start to slump.

I suppose I've been pondering for a while how to be less wasteful in general, and live my life a little more efficiently. To my uneducated mind, that simply meant locking myself indoors and never doing anything 'fun'. Not a very healthy lifestyle, no no.

So, back in May, after going to the markets and stocking right up on meat, Danielle and myself decided to go vegetarian. Not because 'meat is murder', but more because 'meat is inefficient' more than anything. Granted, Australia has a lot of land for grazing, it still takes a lot of effort to get from there to here. Hell, even cooking meat is more effort.

To be perfectly honest, though, even if I was still eating meat, going vegetarian has been an awesome joyride - trying new foods, having to come up with new ideas to keep it interesting, etc. You know, throwing yourself in the deep-end and trying to stay afloat. So far, so good. There's a lot of meat still in the freezer that the puppies are slowly working through, though. Soon!

Hrm, so after decided less meat = good came the transition to eating locally. Again, this wasn't really motivated by the "right" reason - 'local is efficient' - but rather, it was more that the Preston markets were over crowded with smelly people, smokers, and people always in a rush. So we rocked up bright and early to the farmer's markets at the Collingwood Children's Farm and blew a whole truckload of cash. I mean, it wasn't any cheaper, but the atmosphere was nicer with less smokers and more cute puppies. And, you know, better food. And lots of it. Apples, chocolate, eggs, strawberries, pumpkins. All in season, all fresh and all local. It was a delight to feast on!

What else? I don't think I've bought bread in two months now (the bread machine is getting a right workout!). In fact, the oven is getting a workout more now, too, as we make more things from scratch. I made the best cupcakes I've ever made last night, without a single packet! And we've made mousse, sticky date pudding, chocolate brioche, hot cross buns and more in just the last few weeks. All from scratch. (Mostly) all delicious.

OH! Making your own pasta from scratch - I highly recommend it! Since buying the pasta roller on eBay, it's ridiculously easy, too (rolling and cutting it was a pain in the bum!)

I'm drinking "organic" milk now, instead of the generic Pura stuff. Which is distinctly more expensive (I paid $5.25 for two litres at the supermarket, and the checkout chick gasped and exclaimed "wow, this is expensive!"), but it seems to be more 'authentic' in a sense. There's cream around the top, and we discovered yesterday after microwaving it, that there were little fatty bubbles on top from the melted butter. It was gross at first, but smiles crossed our faces when we thought about it a little more rationally.

In perspective, though, I think $5.25 for two litres of milk is rather cheap. I pay more than that for a daily ticket to sit on a train (which, incidentally, gets me to work slower than riding). I can think of many things worse than milk to spend my money on. Hell, $5.25 for a packet of cigarettes (cigarettes! Eugh!) is cheaper than that, and infinitely less useful.

We've just started buying bath milk, too. To drink. Despite the warning labels saying "NOT FOR HUMAN CONSUMPTION" and all that. Apparently though, some dairy farm was shut down or fined tens of thousands of dollars from a staff member jokingly suggesting something along the lines of "that looks good enough to drink!" (that's right, not even suggesting something *should* drink it), so they're never going to tell you to drink it. So what is it? It's just raw milk. Unpasteurised. Not heated first. Capiche?

So, the verdict on raw milk? Well, it's milk. Tastes pretty much like milk. I guess it's milkier milk than normal (just like the strawberries from the Farmer's markets are strawberrier than normal strawberries). It doesn't seem to leave you with a lingering aftertaste though, which is the worst part of milk. It's $6 for two litres though. More expensive, but not by much..

I'm seemingly more opposed to takeaway food of late. Occasionally we'll fetch some hot chips from the local takeaway, but that's generally the extent of it. Or if we're eating out, we've found some unreal vegetarian restaurants around the place that really appeal to what we're into. Unlicensed, no EFTPOS, but amazingly delicious food. It's great.

There's the (somewhat sad looking) vege patch in the backyard too. And the worms. They're nice. Yum!

I'm still a long way from I suppose a model whole-food eater or whatever, but I'm sincerely enjoying the flavours and the time spent preparing good quality food - even if it's a simple dish, it's so much more satisfying when the food has flavour that hasn't come from a bottle..

I suppose I'll write more in somewhat specific detail in future - it's just a bit of a braindump since it's been so long. Stay tuned. All two of you.

Friday, September 5. 2008

0 Comments

Google Hosting Popular JS Libraries

I saw this randomly this morning, but I can't find the source.

In any case, Google are now hosting many popular JavaScript libraries (jQuery, prototype/script.aculo.us, MooTools, dojo) on their own servers - cached, compressed and minified, ready to consume.

It's as simple as you expect:
<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js"></script>

(though, there's a longer, "better" way to do it if you're that way inclined, also)

See it here and the announcement at AJAX Search API Blog

Wednesday, May 28. 2008

2 Comments

sfPropelParanoidBehavior vs Propel 1.3

Just a quick one, mostly for my sake.

If you're trying to use sfPropelParanoidBehavior with (recent? Since r474 (see http://propel.phpdb.org/trac/changeset/474)) Propel 1.3, you'll notice the selects aren't filtering out the deleted items.

Easy fix!

In plugins/sfPropelParanoidBehavior/config/config.php, change (on line 9) Peer:doSelectRS to read Peer:doSelectStmt. Leave the doSelectRS in the array, that's the callback in the plugin which is fine.

Friday, March 14. 2008

0 Comments

Custom Caching in symfony

Just quickly, because it's handy and simple.

I'm building a page that's reading a twitter-feed to display on the front page. I don't want to be hitting twitter on every page hit though (obviously), so we need to cache the data. Could it be any simpler? (Thanks symfony! *cheesy wink*)

Let's dive into the code:

<?php
public function executeIndex()
{
    $cache = new sfFileCache(array('cache_dir' => '/tmp/twitter'));

    if (!$cache->has('tweet'))
    {
        $status = TwitterFeed::getLatestTweet(sfConfig::get('app_twitter_user_id'));
        $cache->set('tweet', $status, 600); // 10 mins cache expiry
    }

    $this->status = $cache->get('tweet', '');
}


Holy crap, that was too easy!

That said, it'd be stupid if it were any harder.

Now, a few tweaks you could do. You could, instead of caching to /tmp, you could cache to sf_cache_dir, so that a symfony cc would also clear that cached data. Could be handy, but might not be what you want.

I suppose if you weren't so lazy, you'd pull those out into app.yml variables. I would, if I were you! It's a pity I'm lazy, really.

Thursday, February 21. 2008

0 Comments

Symfony 1.1 Form Templating

So, I'm tired of how the forms look in symfony 1.1. I mean c'mon, tables? We can do better than that.

Note: we can do better than my solution too, I'm sure, but this is way better than tables!

So inside of /lib/widget, I've created sfWidgetFormSchemaFormatterJosh.class.php which looks a little like:

class sfWidgetFormSchemaFormatterPulse extends sfWidgetFormSchemaFormatter
{

  protected
    $rowFormat      = "<div class=\"form-row\">\n %error%%label%\n %field%%help%\n%hidden_fields%\n</div>",
    $errorRowFormat = "<div class=\"error\">\n%errors%</div>\n";
}


And, from there we need to tell our form to use our own formatter, so in your sfForm (child) class, in either configure() or setup() (I use setup() - I don't know if there is a difference, really. Is there? Anyone?), add the following line:

$this->getWidgetSchema()->setFormFormatterName('pulse');

And that's it! Quite simple really. (When the form is rendered, symfony will look for $class = 'sfWidgetFormSchemaFormatter' . ucfirst($name); (where $name is 'josh', or whatever you called your formatter), and does the rendering using that class!)

For full customisation, have a look in sfWidgetFormSchemaFormatter, and look at the protected variables at the top. They're what you have to play with.

For examples of other implementations, symfony have their own formatters: sfWidgetFormSchemaFormatterTable (default) and sfWidgetFormSchemaFormatterList.

Good luck!

Saturday, February 9. 2008

0 Comments