Saturday, October 31, 2009

Speeding up Firefox

If you use Firefox and have found it slow starting up or laggy typing into the address bar, install the oddly named 'Vacuum Places Improved' add-on from https://addons.mozilla.org/en-US/firefox/addon/13878.

It adds a little icon to the status bar allowing you to defragment Firefox's places.sqlite database file with a single click- that's the file that holds all the information about your browsing history etc.

I've installed it in FF on all the computers I use and noticed a considerable improvement. On my laptop the places.sqlite file was initially 25Mb and after 'vacuuming' its 15Mb. On my desktop, Firefox had almost ground to a halt, often taking over a minute to start up, and when you clicked into the address bar it took around 10 seconds before you could actually type anything! After 'vacuuming', FF starts up in 10 seconds and typing into the address bar is fine.

I highly recommend this if you use Firefox and notice any performance issues. Obviously its not going to solve memory leak (FF's other big problem) but it's a big help nonetheless.

Just to explain - the extension doesn't delete anything, it just optimises the file that holds all the data so that that data can be found more quickly.

You can set the statusbar icon to be hidden and only reappear a certain number of days from the last 'vacuum' to remind you to run it, or it can set to automatically run every x number of days.

Thursday, October 8, 2009

Changing the document root in XAMPP

I know this has been covered many times before but I've found myself Googling for this info a number of times now and thought if I wrote it here then at least I'd know where to look next time!

After installing XAMPP on Windows, the document root, by default, is set to C:/xampp/htdocs (that is, if you installed xampp into the root of the C: drive).

In this particular case I wanted to change the root directory to the sites directory in my Dropbox (C:/Documents and Settings/[username]/My Documents/My Dropbox/sites/)

To do this, open xampp/apache/conf/httpd.conf and edit the 'DocumentRoot' setting (line 188 in the version I have) to the required path (as above). Several lines below where it says "This should be changed to whatever you set DocumentRoot to" (line 215) change the Directory path to the same thing.

Open xampp/php/php.ini and edit the 'doc_root' setting (line 804) to be the same path as above.

Save both files and restart apache. This should do the trick.

UPDATE: As pointed out in the comments, I'd forgotten about my MySQL data. To move the MySQL data into Dropbox:

Open xampp/mysql/bin/my.ini and:
- under [mysqld]:
- change datadir (line 30) to the full path to the mysql data directory on Dropbox.
- change log_error (line 45) to the same path as above PLUS '/mysql.err'.
- change general_log_file (line 48) to the same path as above PLUS '/mysql.log'.
- change slow_query_log_file (line 50) to the same path as above PLUS '/mysql-slow.log'.
- below where it says "Uncomment the following if you are using InnoDB tables"
- change innodb_data_home_dir (line 137) to the same path as above.
- change innodb_log_group_home_dir (line 139) to the same path as above.

Move contents of xampp/mysql/data into the new mysql data directory in Dropbox.

Friday, June 26, 2009

Running SQL queries within query result loops in CodeIgniter

This took me a while to figure out but it's pretty obvious really. Initially I thought I'd have to run row-specific queries in the view itself (inside the results loop) but the solution is just to change where the result 'processing' happens from the view to the controller, allowing you greater control over what gets passed to the view in the first place.

Where you'd do something like this in plain old PHP:

$result = mysql_query("SELECT value FROM table");
while ($row = mysql_fetch_assoc($result)):
    mysql_query("SELECT id FROM table WHERE field='" . $row['value'] . "'");
endwhile;


in CodeIgniter you put the following code in your controller function:

$query = $this->Model->function($params);
$result = $query->result(); 
$foo = array();    
foreach ($result as $id => $object): 
    foreach ($object as $key => $value): 
        $foo[$id][$key] = $value;
    endforeach;
    $foo[$id]['bar'] = $this->function($params); 
endforeach; 
$this->data['foo'] = $foo;
$this->load->view('baz', $this->data);

then in the view:

foreach ($foo as $key => $row):
    print $row['item1'];
    print $row['item2'];
    print $row['bar'];
endforeach;

Basically, instead of passing the result of the main query direct to the view and looping through it there, you loop through the query results in the controller instead, and build up a two-dimensional associative array of results, to which you can add additional row-specific query results. Then in the view you just loop through your custom array.

Update:  You need to initialise the array ($foo = array()) before the foreach loop in the controller, otherwise if the query returns an empty result you'll get an error!

Thursday, February 5, 2009

Speed Dial + Foxmarks? Would be nice!

I use Foxmarks to synchronise my Firefox bookmarks across all the computers I use (it also works with IE and Safari now I believe) and it's great. You can create different profiles as well which you can switch between as required, so when I'm at work I use my 'work' profile with access to all my work-related bookmarks. At home I use my 'home' profile which has all my non-work bookmarks. But if I'm working from home as I was today I can easily switch profiles so I have all my work bookmarks at home! This includes all my bookmarklets which is great.

I also use Spped Dial which is a great and highly configurable way of having quick access to my most-visited sites whenever I launch a new window/tab. It's a bit like Chrome's dashboard but you can define which sites you want to show rather than it just displaying whatever you've been looking at a lot recently, which is better I think (the Speed Dial way I mean!).

But working from home today made me think how nice it would be if my Speed Dial 'home page' worked the same way as my bookmarks - so I could switch to my work Speed Dial page instead of my home one. At the moment there is no way to do this (unless there is some clever clogs way of doing it using Dropbox etc.).

Of course, with the steady march of Google towards world domination we'll probably have everything in the browser synced through Google in a couple of years - albeit using Google Chrome....

Tuesday, January 27, 2009

Run IE6, 7 and 8 on the same machine

Note to self:

http://blog.case.edu/jeremy.smith/2008/03/07/ie_6_7_and_8_running_on_same_machine

Presumably it will still work with the final version of IE8 when it gets released.

(As as aside, I've been using Tredosoft's MultipleIEs for a couple of years now and it works pretty much flawlessly. Extremely handy for testing purposes.)

Tuesday, January 20, 2009

Taming the information overflow

News feeds and activity streams are becoming ever more popular as the amount of online information we share and consume grows.

I am starting to wonder, however, where all this is going. The amount of information is only going to keep increasing, and at some stage it is going to become too much.

Do I really want - or need - to know exactly what every person I've ever met is doing or thinking right now? Sure, to a certain extent it can be useful and/or interesting, but there must come a point at which it is actually more of a distraction.

There is only so much information we can take in. Filtering of content is a partial solution, but only partial.

It will be interesting to see what happens!

Thursday, January 15, 2009

Google to drop Notebook

Along with several other less-well-known-about Google services, its been announced that development of Google Notebook is to stop.

This is a great shame as I really like this little tool, especially in conjunction with the Google Notebook extension for Firefox.

Although Google Notebook will remain active (at least for the time being), I think I'll have to start searching for an alternative.

Wednesday, January 14, 2009

The all-in-one social network?

http://www.readwriteweb.com/archives/diso_dashboard.php

This sounds like exactly the sort of thing I've been waiting for, although the details are obviously still pretty vague. One of the growing frustrations of internet use these days is the barriers that exist between different services and applications. I want to be able to link things, move things around, and generally customize my web experience (and web presence) the way I want it without having to be bound by the limitations imposed by each service.

There are a few inroads being made already - Facebook allows you to set up data imports from Twitter, Flickr, Blogger, Wordpress etc. (but the amount of customisation is limited); Twitterfeed lets you automatically post to Twitter every time you update your blog (or anything with an RSS feed); Digsby does a very good job of combining all your email and IM accounts as well as Twitter, Facebook etc. into a single desktop app; Flock (the web browser based on Firefox) does an admirable job of pulling together a lot of different web services into one place - although the level of customization is fairly limited and you're stuck with a few pre-defined apps.

Saturday, January 3, 2009

Make scaled images render nicely in IE

A colleague just noted this blog post in his RSS feed and I thought it was worth sharing on here (and for my own future reference).

If you force an image to a certain size via its width and height attributes in HTML or CSS, most browsers will handle this ok and display the scaled image reasonably nicely, but in IE the edges often look pixelated and jagged.

To fix this, just add the following to your CSS:

img { -ms-interpolation-mode:bicubic; }

I shall be adding this to my reset stylesheet ASAP.

Monday, December 29, 2008

It's magic! Experiencing the power of Foxmarks...

I came in to work this morning and fired up the old 'Fox as usual, with the thought at the back of my mind that I needed to add that Gmail bookmarklet I blogged about yesterday.

But I was genuinely surprised to see it was already there! Magic? No. Foxmarks of course!

Sunday, December 28, 2008

Learning to lose the mouse!

I always used to marvel at people who were able to use a computer almost solely from the keyboard. But it never seemed worth learning all the keyboard shortcuts to be able to become a keyboard wizard!

Over the years I have picked up the odd shortcut here and there - mainly for things like Photoshop where you tend to be constantly chopping and changing between tools. But one area where I've been quite slow to pick up keyboard habits is, oddly enough, web browsing, despite the amount of time I spend doing it!

Only with increasingly using a laptop (and finding that the right 'mouse' button is wearing out!) have I started to take browser keyboard shortcuts - and general keyboard navigation - more seriously.

Lifehacker have a useful article (rather old now actually but still just as useful) introducing the most useful Firefox keyboard shortcuts.

As something of a Firefox extension addict, the Keyconfig extension is certainly highly recommended by me - simply to resolve the inevitable conflicts over shortcuts that arise from installing multiple extensions.

Keyword bookmarking is another very handy feature. In relation to my last post, it's really handy to be able to simply press Ctrl+L and type 'gm' (as I have set it up) to get an instant Gmail Compose window pop up. About 10 times quicker than any other way of doing it!

I think it's one of those things where you have to make a bit of an initial effort (old habits die hard, of course) but in very little time that effort is repaid many times over in time saving. The same lesson has been recently learned in getting used to using Launchy - at first I was continually wanting to use the mouse and click on programs in the Quick Launch bar. Now 'Alt+Space' is second nature! Similarly, using 'Alt+Tab' to switch applications rather than constantly having to move down to the taskbar, etc. etc.

Add a 'Compose new Gmail' Bookmarklet to Firefox

This is a modified version of the 'GmailThis' bookmarklet which automatically adds the title and url of the current page into the email. I don't often need to send URLs to people, but being able to instantly open up a compose window in a popup is very useful.

Saturday, December 27, 2008

Goodbye Posterous - it was nice knowing you but I've just discovered Twitterfeed!

New technology is a fickle and ever changing thing...

Posterous seemed like a great idea until about half an hour ago. Blogging via email is nice (but Blogger does it already so no brownie points there). But having it auto-post to Twitter each time I posted a new blog entry was what won me over.

But then I came across a problem. I wanted to set up a new Twitter account, specifically related to my railway-related interests. And I wanted to set up a new blog on Posterous to mirror my existing 'Line to Nowhere' blog on Blogger. And I wanted to have Posterous autopost to my new Twitter account and my railway blog on Blogger each time I posted to the new Posterous blog. (In other words, two different online 'identities', each with seperate blogs, Twitter accounts etc., all managed through Posterous.)

Trouble is you can't do that with Posterous at the moment, unless you create two seperate Posterous accounts and then make sure that you always post to each one from a different email address. Which is a hassle and it kind of cancels out the simplicity of it all. (But then, maybe not everyone has such diverse interests as me?!)

Then I discovered Twitterfeed. You create an account (using OpenID) and then set up as many different RSS-to-Twitter feeds as you want. You just give it the URL of an RSS feed and the Twitter account you want it to auto-post to (you have to supply your Twitter username and password but a quick Google suggests that its a fairly reputable service), and how frequently you want it to update, and off it goes and does its stuff!

Since I have no need to post via email to Flickr or YouTube or Vimeo or any of the other blogging services supported by Posterous, and because Posterous doesn't allow me to easily differentiate my online identites, Blogger + Twitterfeed is actually the ideal solution for me right now.

So I now have the following setup:

mattots.blogspot.com + twitter.com/mattots
line2nowhere.blogspot.com + twitter.com/line2nowhere

I can post to either blog via email (I just post to a different address for each), and Twitterfeed automatically updates the relevant Twitter account every 30 minutes. Simple.

(Oh yes, and if I just want to post direct to either Twitter account, Twitterfox lets you log into and switch between multiple Twitter accounts, so that's no problem.)

Sorted.

For now at least!

Blogger-users, meet Posterous!


For those of you who follow this blog on Blogger, you may have noticed the "Posted via email from Matt's Random Stuff" link at the end of recent posts and wondered what it's all about. Well, clicking the link would have answered the question for you, but if you've not got that far yet then simply go and check out Posterous or see a carbon copy of this blog post at mattots.posterous.com and all will be revealed.

My current setup allows me to send an email to post@posterous.com from any of my email addresses and the contents of the email are instantly posted to my blog on Blogger and Posterous with the email subject as the post title. At the same time, the subject line and a link to the blog post on Posterous is posted to my Twitter account.

At the moment this is all I need to do, but Posterous lets you do much more than that - check it out.

It's still in the early stages of development really so I imagine there are going to be a lot of new features being rolled out as time goes on.

Posted via email from Matt's Random Stuff

Saturday, December 20, 2008

TinyTwitter would be great if it actually worked on my phone. But it doesn't!


Accepting the fact that I won't be getting an iPhone any time soon means having to scout around for decent apps that will work on my Sony Ericsson W950i. That's a bit of an contradiction in terms really, as there aren't really any truly decent apps for UIQ3 (unless someone can prove to me otherwise). Still, I was looking for a Twitter client that would work with my phone and after trying several, most of which either blatantly didn't work or were just plain rubbish, I found TinyTwitter, which seemed to be okay. And it works, except for one small thing - I can't send tweets! It just gives an error. Quite annoying really. I presume its some sort of big or incompatibility with my phone.

Posted via email from Matt's Random Stuff