PHP syntax trick, using query ? true : false.

March 15th, 2010

This seems to be a trick that not everyone knows, if you have read some source code from various locations you’ll probably have seen something like this occasionally.

if (isset($_GET['o'])){
     $sql = "SELECT COUNT(id) FROM my_quotes".' WHERE origin = '.$_GET['o']);
} else {
     $sql = "SELECT COUNT(id) FROM my_quotes");
}

Instead you could use something like this:

$sql = "SELECT COUNT(id) FROM my_quotes".(isset($_GET['o']) ? ' WHERE origin = '.$_GET['o'] : '');

The syntax is simple. Firstly you put an expression that will evaluate as True or False, then you separate this with a ‘?’ and provide expressions which return the values you’d like to see for first True and then False. Separate the True and False expressions with a ‘:’ and you’re good to go.

Of course you must always sanitise your parameters and check them for sensibility. Parameters must be sensible, as sensible as your grandparents driving advice. Remember that you can also tier these clauses just like:

(isset($_GET['o']) ? ' WHERE origin = '.$_GET['o'] : (isset($_POST['o']) ? ' WHERE origin = '.$_POST['o'] : ''))

There! Your five or seven lines are now one. It would be interesting to see the processing speed difference but I’d imagine its minimal. I hope you’ve found this little tip of use, maybe we’ll see some leaner meaner code coming up soon. The examples were modified from the new V8d QDB, the source code for which will be available soon.

Kind regards, Robert.

  • Share/Bookmark

V8d QDB (Laughter, sunshine, and inappropriate remarks)

February 17th, 2010

Recently I’ve been doing some work to resurrect the V8d QDB. About a year ago it was shut down because of excessive spam and excessive bugs in the script running it, at that time it had a little under 1,000 quotes and many people submitting them. Fortunately I saved the database (spam and all) and over the last couple of weeks or so I exported it to CSV and then imported it to a new quote script. This quote script was based off of QdbS and I’ve made several additions, including:

  • CAPTCHA system based on reCAPTCHA
  • Quote origins to allow users provide a source for their quotes and quote sources to have their own QDB
  • An option to allow users to fix quote origins
  • Deletion requests
  • IP tracking for posts
  • Language filtering for quotes
  • Nicknames associated with quotes and passworded access to the nicknames
  • Syntax highlighting so it looks just like your client
  • A mobile site for portable laughter
  • Line by line quote editing (currently only submitting lines to be deleted)

Creating origins for quotes means that now we have separate QDB’s for different channels/networks, so there’s http://qdb.v8d.org/afternet and there’s http://qdb.v8d.org/crystalirc.

There’s a long list of things to do still, some of it is pretty easy and other bits are going to take a lot longer. If you have any features you’d like to suggest or request then please either drop a comment here or get in touch another way. Of course if you want your network/channel listed as an origin then just say so. Well, I know the question you want answered, what might be coming?

  • An Android client
  • Registration so you don’t have to keep filling out CAPTCHA’s
  • Support for SMS quotes, MSN quotes and IRL quotes (and etc.)
  • Support for texting your quotes in
  • Support for mobile submission

I’ve been using the QDB to [re]learn PHP so there have been some bugs and I’ve learnt a lot. As I work with it I’m sure I’ll provide an ever growing number of features as I become more skilled and spend more time on it. At some point I will add better templates as the existing ones use tables and could use some AJAX to make things a little more streamlined. I am working on this project and there will be more done to it within the near future, however, right now I’m working on another project so development of new features is paused for maybe a week.

Please click here to go to the QDB

Kind regards, Robert Small.

  • Share/Bookmark

Fix for: Linux 2.6.32.8 and FGLRX (8.690 or 10.1)

February 17th, 2010

So, you have your fancy graphics card and you’ve updated to the latest kernel, however you seem to have been bitten on the buttocks. Your old FGLRX drivers do not work and you can’t get them to compile for the newer kernel, you swear at dkms as much as you want but it doesn’t help. You download the latest version and you’re faced with an error message something like:

dpkg-shlibdeps: error: couldn't find library libatiuki.so.1 needed by debian/xorg-driver-fglrx/usr/lib/xorg/modules/linux/libfglrxdrm.so.
Note: libraries are not searched in other binary packages that do not have any shlibs or symbols file.
To help dpkg-shlibdeps find private libraries, you might need to set LD_LIBRARY_PATH.
dh_shlibdeps: dpkg-shlibdeps returned exit code 2
make: *** [binary-predeb-IMPL/xorg-driver-fglrx] Error 1
dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit status 2

There is a solution, it’s a relatively easy solution too and I’m surprised at the point of writing this blog it hasn’t been patched by ATI.

./ati-driver-installer-10-1-x86.x86_64.run --extract
cd fglrx-install.*/arch/x86/usr/lib/
ln -s libatiuki.so.1.0 libatiuki.so.1
cd ../../../../
sudo ./ati-installer.sh 10.1 --buildandinstallpkg Ubuntu/karmic

In the case of 64bit compiling remember to change x86 to x86_64 and lib to lib64. Now you should have ATI just where you need it.

Kind regards, Robert.

  • Share/Bookmark

What to do with Ubuntu 9.10 (Karmic Koala) after installing.

February 8th, 2010

So, you paid your money, bought a CD, and installed a cuddly Koala onto your computer. However, you feel it’s not doing everything you wanted a ball of furry FOSS to do.

Sleepy Koala

You feel a need to make Ubuntu 9.10 do more for you. To make your Karmic Koala climb it’s tree. So, here I am, your Ubuntu zoo keeper to give you some tips.

The first thing to realise is that there are some changes, one which makes me particularly happy is that you can add sources by ‘ppa lines’. Simply put you can change where Ubuntu gets it’s software with shorter lines. Call me a lazy belly dancer and beat me with a mop but this makes me happy.

Screenshot-Software Sources

Screenshot-Untitled Window

See? Easy as that.

Another big thing for me was the new ATI graphics driver for my HP Pavillion DV7 2050ea and it’s ATI M92 (Mobility Radeon 4500 series, 4530). They seem to work very well which makes me extremely happy. I’ve simply used jockey (the ‘Hardware Drivers’ item in ‘System > Administration’) to adjust it. One note must be made. The kernel you use can cause issues with the kernel module being compiled. I advise keeping your old kernels that work whenever you change/recompile.Screenshot-Hardware DriversScreenshot-glxgears

Without optimisation this already has given me a massive performance boost. I can now run XBMC (which I will discuss later).

Moving on from the new drivers there are a few other updates. There’s a new Firefox which should make everyone happy, and Empathy has taken over from Pidgin. I’m not quite sure how I feel about this to be honest, over the last few years I’ve switched almost completely to IRC (using XChat). I do however use Bonjour to talk to people on the same network occasionally and Empathy seems to handle this reasonably well.

So, once you’ve run Jockey to get all your hardware working well there are some programs I would recommend and a few things to do to get yourself up and running.

A music player

One of the most important things in modern computer usage is playing music. Recently I’d been enjoying Songbird, unfortunately when I’d first installed Ubuntu 9.10 it caused an error. While looking at alternatives I found Banshee which offers me something else.

Songbird

When first trying Songbird I was presented with two problems:

  1. GetDeb didn’t have a copy.
  2. When I downloaded the source it failed to start with the following error:
    ././songbird-bin: symbol lookup error: /usr/lib/python2.6/dist-packages/gst-0.10/gst/_gst.so: undefined symbol: gst_task_pool_get_type
    Could not initialize GStreamer: Error re-scanning registry , child terminated by signal

However, there is a usable solution. Firstly download from http://www.getsongbird.com/download/, then go into the ‘lib’ folder and delete everything starting with libgst. Once you’ve done this it should start perfectly. There are some great plug-ins and cool themes.

Now GetDeb has a copy, but if it doesn’t work for you that might be a helpful solution.

Screenshot-Songbird

Rhythmbox

Install: sudo apt-get install rhythmbox

This is a feature full alternative to the original media players. Until I discovered the fix for Songbird I used Rhythmbox and I found it very usable. I personally don’t like it as much as Songbird. It should be installed by default, if not see above.

Screenshot-Rhythmbox

Banshee

APT line: ppa:banshee-team/ppa
Install: sudo apt-get install banshee

This media player is much more like what I like. It provides a fair few features and if you haven’t used it you should give it a shot. Banshee gives excellent iPod/Android/RockBox synchronisation and I’m sure it provides more syncing but I don’t have any more devices to try. I have noticed a few small gaps between playback but I know that the Banshee team are working on gap-less playback support and I’m excited to see it.

Screenshot-Banshee

A media centre

There are several options for this. I personally love XBMC, others swear by Moovidia and some by MythTV.

XBMC

I love XBMC, I run it on my dad’s media centre and it’s always done me really well.

Screenshot-XBMC

Moovidia

I’ve recently tried Moovidia, it’s nice but it doesn’t seem to offer anything to draw me away from XBMC, however I’d recommend it to anyone who wants to have a good interface to their music, films and TV shows.

Screenshot-Moovida Media Center

Development Environment

There are two development environments that I really like, both of them are built with Java and have support for multiple languages out of the box.

Eclipse

Install: apt-get install eclipse

I’ve always used Eclipse and PyDev for Python development, I’m not sure if I could change if I had to. One of my first things to do was to install eclipse. I also use it for Java/Android development, all in all it’s a great IDE.

NetBeans

Install: apt-get install netbeans

NetBeans seems to be primarily for web development, I use it for PHP (http://www.v8d.org/qdb) and I know other people who use it for HTML, Java, JavaScript and etcetera. One feature I especially like is that it can upload my edits immediately after I finish them.

Video Playback

Presumably you’re going to install all the mediabuntu goodies so you can play lots of different formats.

SMPlayer

Install: apt-get install smplayer

This is now the only video player I use for desktop applications. It provides massive format support from MPlayer, bookmarking, and unbelievable reconfigurability.

Audio Tagging

Music Brains Picard

Install: apt-get install picard

Picard is to us music lovers as air is to you other people. It tags music from a massive database and if you have something it doesn’t then you can submit it for others to be able to tag.

TV Shows

If you don’t have your own PVR to provide XBMC with content then you should certainly consider getting something like Hulu desktop. It’s in their labs section and available for Linux

Hulu Desktop

Install: Follow the instructions here

In closing

There are so many more applications out there, you’ll never find them all or use them all. If you want something first search the repo’s (Synaptic or whatever you use), then progress to GetDeb and Google. However, I will give you some suggestions for other applications you may be interested in.

  • VLC – This used to be my favourite video player, it uses a brilliant play engine and manages to cope with almost any form of network stream.
  • digiKam – Best. Photo. Management. Ever. (IMNSHO)
  • K3b – Excellent, fast and easy CD/DVD burning/cloning/creation/decryption/etcetera.
  • Audacity – Very good linear audio editor with great plug-ins.
  • Handbrake – Video en/de/transcoder.
  • soundKonverter – Conversion from and to various audio formats.
  • Kate – Excellent text editor.

I’m sorry this wasn’t posted sooner, I started it and then things happened like marriage and Christmas. Talking of which, Happy New Year to all!

Kind regards, Robert.

  • Share/Bookmark

Top ten Android Apps I miss from my T-Mobile G1 (HTC Dream)

September 11th, 2009

So here’s the story. My G1 has stopped working and being in the USA at the moment I have to return it to the UK to be replaced, in the mean time I’ve found myself missing both it and the applications on it. I’ve really grown to love Android and the apps on it. In fact it has become something of a mobile computer to me. With the easy WiFi connectivity and built in GPS (and the help of Locale) I’ve found using WiFi hotspots almost as easy as having a (cheap) 3G connection. Of course being on a UK contract I’d rather not incur the massive roaming charges for data in the USA.

In the last few days as I’ve started to miss it I decided to write a ‘Top Ten Roundup’ with a difference, the top ten that I miss. I’ve reverted to my Windows Mobile smart-phone so I still have a few luxuries. I expect that I’ll mention several things which made me prefer my G1 to the HTC Hermes I was on. Firstly though I’ll compare a few core components that I miss.

  • The email program. When I first used Android I wasn’t that excited about the email app; sure, it had starring which Windows Mobile didn’t, but that was about it for me. However I’ve come to really appreciate the way it synchronises and the way that I can apply labels and generally use it as I do the computer front end. Windows Mobile makes me synchronise manually or set a time, this is nice and I used to find it very useful but I really appreciate being able to use Locale with the Gmail application to trigger synchronising only in a WiFi hotspot.
  • The contacts application. There are some trade-offs here. Windows Mobile supports a birthday for a contact, unless I’m severely blind my G1 does not. Windows mobile however attacks my contacts list on Gmail adding Mr’s and Mrs’s which in turn adds extra contacts. This is fixable, the G1 lack of birthdays will surely be fixed in a future release. Incidentally the birthdays can be shown on the calendar with a small work around. Simply go to the calendars listing under settings, click browse interesting calenders and find your birthdays under ‘More’.
  • The browser. I really miss the Android browser and its speed and zoom features.
  • Marketplace. Do I even need to say anything here? The ease and simplicity is so nice.

Now for my top ten list of Android applications that I miss.

  1. Locale. I had rules set up to do everything I needed all based on where I was. It came into extra brilliance while abroad where I couldn’t use my normal data connection.
  2. ConnectBot. Having a well rounded SSH application is essential.
  3. Android IRC. Who can exist without IRC? I mean, what true techie can exist without IRC? Android IRC supports SSL, multiple servers and message notification, what’s more it doesn’t die if you leave it and open other applications.
  4. AndNav. This is my most memory heavy application, it uses tiles instead of vectors so pre-download is essential for any sensible routing. Also routes are calculated away from the client which causes network use. However, all this is well known to the developers and is being worked on. I would personally love to see (for example) POI search for off-line (maybe import gpx POI’s). I would be even more excited to see off-line routing, maybe data sets could be split further just to contain roads with no additional data? However all the Windows Mobile alternatives that I’ve found have not done what I needed or had some major problems.
  5. Quickipedia. Wikipedia has become the defatico source of information these days. Want cable layouts? Check Wikipedia. Want information about a penguin that flies? Check Wikipeida. Having a mobile client is like carrying it around as a book… just without ink or weight or that book smell or worrying about pages falling out.
  6. Movie Finder. It’s great to be able to quickly find out the times of a movie or check which ones are on locally. This isn’t a new concept I know but I found this the easiest to use, far easier than my previous experiences on Windows Mobile.
  7. Telegraph.co.uk news. Although this requires a connection and can’t horde its data off-line it’s still a great application. I’ve used other news applications and I’m open to suggestions but I found this to be the best. I do miss Viigo.
  8. Listen. I’d only just started using this but I’d become adicted pretty quickly. It’s a nice product from google themselves and it provides me with a stream of podcasts straight to my device. What’s more it can be run offline.
  9. FML. This would be one of two things that I use to entertain myself.
  10. Lolcats. This would be the other.

There are more I miss, there are more I used regularly and there are more I’d probably like to put on this list in the future. A couple in the running were:

  • My Tracks. A GPS tracking application that I’ve found to be absolutely excellent.
  • Beeb Player. BBC iPlayer application, not much use here as I have a US IP but it was great when I was in the UK.
  • Meridian Player (and now Meridian Evolve). A great player. Unfortunately I don’t watch much on my phone as my laptop has a better resolution for that.
  • Dizzler. A music on demand player, very useful for those moments where someone doesn’t know a song and you want to *show* them.
  • Barcode Scanner. Most sites about Android offer 2d encoded barcodes for content, I think this is a great way to move stuff from one device to another.
  • Better Keyboard. A great on screen keyboard. I certainly miss it.

That just about makes up my little Android tear story. Hopefully I should see a new G1 working perfectly within the next few weeks and I’ll be able to tell you which applications I’m adicted to right from the word go.

Kind regards, Robert.

  • Share/Bookmark

HP Pavillion DV7 2050ea and Linux.

September 4th, 2009

I am now a fortunate owner of an HP Pavillion DV7 2050ea. The first thing I’d like to say is that this is a very nice laptop and I’m very happy with almost every aspect. It’s comprised of the following hardware:

  • AMD Turion X2 Dual-Core Mobile ZM84, 2.3GHz
  • 4GB of RAM, I haven’t checked the brand but it seems fast
  • 320GB of hard drive space on a Western Digital drive
  • ATI M92 (Mobility Radeon 4500 series, 4530), seems to have 512MB of RAM
  • eSATA, USB and FireWire
  • ExpressCard
  • XD/MMC/SD slot
  • HDMI and VGA
  • QuickDock (v3 I think)

HP Blurb

The biggest problem so far has been the graphics card, so far I’ve been unable to get it working with fglrx. I have the standard X drivers working and they give me full screen output but that too was a bit of a fight. However under Vista the card seems incredibly powerful for a laptop and it has no problems playing DVDs using the standard X drivers under Linux. However the iPlayer will not play without major chopping. Hulu plays but only at standard resolution and without full screen.

The sound works perfectly using the snd_hda_intel module and one small adjustment to its config. In fact I’m quite impressed with the volume and power the speakers can create. The file /etc/modprobe.d/alsa-base.conf now contains:

options snd-hda-intel model=hp-hdx

eSATA, USB and FireWire all appear to work correctly. All I’ve noticed is that the eSATA port’s USB functionality seems to be a little low power, I can use everything except for hard drives which act as if I’d plugged them into a USB 1.1 port.

Strangely I can’t get the XD/SD etc slot to work, this is pretty normal though so I’m not too bothered. It does seem to help if I disable the power saving for them and FireWire in the BIOS. No idea why, maybe someone else will have more information on this.

The laptop can take two hard drives and I’ve found a second miniPCIe slot. Unfortunately the second hard drive needs a ‘kit’ to be installed, I’ll blog more about this when I get a chance to install one. However, with hard drives the size they are these days this makes for at least 1TB of space without too much heat overload.

I haven’t yet worked out the obligiroy IrDA, it seems it’s somehow hooked through the BIOS to allow the included remote to function (including the luxury of a power button). I haven’t had any other problems with it yet, the ExpressCard slot seems to work perfectly as do the other various ports.

Over all this is an excellent laptop with a lot of power, although it’s large enough to watch DVDs on it is also small enough and light enough to be portable.

Kind regards, Robert.

  • Share/Bookmark

Review of the iPlayer – Round two (does it still judder?)

January 18th, 2009

This seems like a good time to write another iPlayer review, after all, they’ve had some time and I have a new computer. What’s changed?

So, let’s look at what we said last time.

Good

  • No advertisements (other than a brief channel trailer which doesn’t really count).
  • Good quality, especially for so called ‘standard definition’.
  • Generally fast play.
  • Done with flash, pretty much universal.

Bad

  • Bandwidth heavy.
  • No live viewing.
  • Some issues with the video.
  • Only seven days of watching time.
  • Awful problems with full screen play.

The thing is that I now have a computer which is almost as good as my Dad’s media machine. This means that I can experiment more, but it doesn’t mean that I have something more powerful than the box I tested it on before (although the screen is a tad smaller).

However, Auntie has had a chance to get her act together and upgrade/advance the iPlayer. This seems to have resulted in some serious interface changes and the new high definition version.

I don’t have time to write a full review at the moment but here’s my summary:

Bad to good

  • With the introduction of the HD version bandwidth seems to have dropped for the non-HD media, unfortunately so has quality (see below).
  • Since my last exploration I’ve found some programs and libraries which allow iPlayer downloading.
  • It would seem that more and more applications are supporting the iPlayer (Boxee and XBMC).

Good to bad

  • The quality before HD was very good on normal recordings. It would seem that with HD’s introduction the SD (standard definition) media is lower quality and in general more flaky.

New bad

  • Over the last few weeks I’ve encountered a few video bugs, mostly involving jerks or artifacts.
  • Occasionally the video decides to scramble audio and play at ten times speed, similar things happened before but this is worse.
  • I’ve started to notice that very little of the audio is normalised, I have to adjust my amp a lot.
  • Contrast and brightness differences, hitting ‘auto calibrate’ a lot on my screen isn’t much fun.

New good

  • The HD version is very nice and the content very crisp.
  • There is a growing number of devices which support the iPlayer.
  • The ability to pause, then resume the next time you open your browser (it remembers where you were), a small but important improvement.
  • Wider range of Programme avaliability.
  • I can generally get jerk-less full screen playback on my box. I have yet to purchase a non-integrated graphics card so this is impressive (I have a NVIDIA internal at the moment).

Still good

  • No advertisements. Even with things like Heroes there are no advertisements, the most you get is a channel/producer trailer.
  • Audio on both SD and HD is crisp and clear.
  • Generally very good avaliability.
  • Generally fast play.
  • Good support for most normal computers.

Still bad

  • No live viewing that I can find.
  • Limited time to watch.
  • Strange problems with full screen, sometimes on some computers with some definitions. They’ve certainly fixed it for some situations.

I think that  covers just about everything, feel free to comment with your own opinions.

Kind regards, Robert.

  • Share/Bookmark

Merry Christmas! Oh, and a funny picture.

December 25th, 2008

Merry Christmas all, season’s greetings if you don’t go in for Christmas. I’d like to wish you all a very happy and enjoyable period of celebration and family time. I intend to start some new projects and do some new and exciting things during the next year, but I’ll leave that for a New Year post.

I’m enjoying the new WordPress; including the Gears side of it, and the new look.

I will be uploading some photo’s on Facebook for those of you who follow that. I’ll probably be more active soon, at the moment I’m fervently searching for a new job, preferably a well paid one. Some of you may also know that my Girlfriend/Fiancee  is staying with me at the moment and we’re spending quite a bit of time out and about. So, sorry for the lack of blogs, I’ll be good in the new year, I promise! Now send me presents!

Now, for your amusement I bring you this photo.

Police hunt gang of Santa's after city fight.

Enjoy!

Have a great Christmas all of you, I’ll write more in the new year.

Kind regards, Robert.

  • Share/Bookmark

The life of a fig

November 4th, 2008

I know, I haven’t posted. I’ve been really busy with all sorts of stuff. I thought I’d bring this little gem to you.

Correct me if I’m wrong, but isn’t this a grammar fail?

Kind regards, Robert.

  • Share/Bookmark