I originally blogged about this on my other site lazygnome.net but that was simply a quick place to record it.
I present to you a very quick and handy way of replicating PHP’s trim() function in JS:
return value.replace(/(^s+|s+$)/g, '');
There it is, simple and usable.
I don’t claim to be original with this code. I’m sure that others have done exactly the same themselves. But it surprises me that JS doesn’t come with such a text manipulation method by default.
Installed Ubuntu 10.04 from ISO onto a blank virtual box machine.
All worked well for a while, until I recently did an aptitude safe-upgrade.
The next time I booted the system, mysql failed to start and refused to do so when I issued: sudo service mysql start
It would just hang there.
Tracked the issue down to this bug. How I maged to get get it to work:
In a terminal: sudo /usr/sbin/mysqld
In another terminial:
sudo service mysql start
sudo service mysql stop
sudo killall mysqld
Now mysql will start and stop on the system as it should.
[nb: this is a rough artical, I will flesh it out when I have more time]
[edit 27-05-2010: this is not a permanent fix and requires to be executed after every system start. Looking forward to a fix on this…]
[edit 22-06-2010: see Ryan’s comment to fix this issue. I hope this helps others :)]
Just a quicky…
Using the guide from here, I’ve managed to use the ‘net connection of my Nexus One with my Eee PC running Ubuntu Netbook Remix.
Nexus One using Wi-Fi and home cable:
Nexus One using 3G in the Telford & Wrekin region:
The documentation on http://prototypejs.org/api/element/writeAttribute is a wee bit scarce. So here’s a quick one on usage.
To add an attribute:
To remove an attribute:
To enable all disabled form elements (in a form with the id ‘container’):
The MySQL PASSWORD() function has started giving a different value on a client’s live server compared to local development servers.
This has resulted in end users not being able to log in when PASSWORD() is used to compare the stored and entered passwords.
Why this has happened I have no idea. Any thoughts?
mysql> SELECT PASSWORD('foobar');
| PASSWORD('foobar') |
| *9B500343BC52E2911172EB52AE5CF4847604C6E5 |
1 row in set (0.00 sec)
mysql> select password('foobar');
| password('foobar') |
| *9061D7B8DA0D4523AD448B53D80C2B551EDF8CD1 |
1 row in set (0.00 sec)
When something really note worthy happens, I usually don’t go longer than a few days without knowing.
But, for some reason, I just learnt about something that happened 19 March 2008.
Only by reading this comic in this book did I learn of Arthur C. Clarke‘s passing. This is particularly shocking as Arthur C. Clarke was the main author of the books I read in my childhood.
You’d have thought that it would have been bigger news. Maybe I just live under a rock.
Buy the book, read the comics, follow the might of Hijinks Ensue.
This is on myrant.net rather than my other blog on lazygnome.net as it wasn’t as quick and easy as I’d have liked to set up. So, in a way, a very tiny rant with a lot of helpful content (I hope).
Inspiration for this article came from following Popey’s setup instructions with Ubuntu 9.10 alpha.
- Download Ubuntu 9.10 32bit desktop ISO: http://www.ubuntu.com/getubuntu/download
- a) if you have an external CD drive, burn the ISO to a CD.
b) if you have a USB flash drive: download and install UNetbootin from http://unetbootin.sourceforge.net/. This is available for Windows and Linux. Use this util. to ‘burn’ the ISO to your USB flash drive.
- a) if you have an external CD drive, put the ubuntu CD into the drive.
b) if you have a USB flash drive, plug it into the Revo (Any USB port seems to work).
- Power on the Revo and hit f12 to enter the boot menu.
- Select CD or USB depending on your install medium.
- Select Default, or wait and it’ll select it for you.
- The Ubuntu desktop will eventually load.
- Have a play, or click ‘Install Ubuntu 9.10’.
- On step 4, partitioning, I chose to use the entire disk. If you don’t want to ditch the shipped OS, choose another option.
- Set up a username/password then choose if you want to log in automatically. Normally, I wouldn’t set this, but as it’s going to be a media centre, you might as well have it log in automatically.
- Step 6 will allow you to check you have set the options you want. Once you are happy, continue the install and go make a cuppa tea, do the washing, feed the cat, read a book; as this will take some time.
- Reboot the machine once installation has finished.
- When the desktop is usable, run the Update Manager – at the time of writing, there were 86 packages to be updated.
- Click on Restricted drivers available and activate the NVidia accelerated graphics driver.
- From this point, follow Popey’s install instructions.
- Whilst following Alan’s instructions, I had to grab 3 debs from Jaunty (rather than his stated 1). These are:
By this point, Boxee is accessible via the Sound & Video menu.
Next task, for me, is to get an external enclosure for my internal blu-ray drive (still waiting for decent blu-ray support in linux).
[this is a bit of a random rant, excuse me whilst I ramble]
Every year, the sale of fireworks seems to come earlier and earlier.
In the UK, we used to use them on the 5th November (or the closest weekend). Now they seem to be in use from the 30th October to mid November. And then over the whole Christmas period.
When in the right hands, they can be great fun. But as people have more and more access to them, the fun becomes less.
- The sale of fireworks should be licensed in the same manner as the sale of alcohol.
- The purchase of fireworks should be more tightly controlled. Get them out of the supermarkets and corner-shops for a start.
- The use of fireworks should also be licensed. This would restrict displays to organised events and not 14 year old kids throwing fireworks down the street, or scaring fish.
I don’t want to be kill joy, but explosives need to be treated with respect.
Maybe I’m getting old and jumpy. I love the look of a good display. I don’t like having to fish the cat out from underneath the bed.
Finding a needle in a haystack is a wonderful bit of symbolism and I welcome its use in many situations.
It’s just the implementation of that symbolism that needs to be standardised. For forgetting the order in which a function expects variables to be passed in is tedious.
In PHP, for example, there are some very useful functions: in_array() and strpos() to name but two.
Usage is in_array($needle, $haystack) and makes sense as you want to check that the needle is in the haystack.
But, it’s strpos($haystack, $needle) that messes things up. You can’t look for a haystack within a needle!
So, because of strpos() confusing things, it’s quite often that I (and other’s I’m sure) mix the order, no matter which function is in use. Unless I’ve been using the function within the last few hours, I’ll most likely get it wrong.
These are long standing functions in a well established language, so there’s no hope of these ever being corrected.
For new functions, a possible answer would be to pass variables by associative array when the function has more than 1 variable input.
An example of calling such a function would be: myFunction(array(‘needle’ => ‘malteser’, ‘haystack’ => ‘bag_of_revels’));
This way, it wouldn’t matter which order you remembered to pass in the variables. As it happens, this is how I write my own functions.
Apparently, something similar is done in Python. Might get around to learning it sometime…
Strictly Come Dancing has never been the sort of programme to hold my attention.
But whilst I’m keeping my darling girlfriend company, I seem to be distracted from my laptop by the show.
The audience annoys me with their reaction to the judges. Bruce annoys me for having lost it years ago. But everybody else annoys me for humouring the old fool.
Yes, I’m getting old.