yes i love technology

MySQL tips: Grants and Changing Passwords

February 23rd, 2007 by Pete

I was doing some work administering MySQL databases earlier in the week. I haven’t done much with MySQL in over half a year since we use Postgres as the backend for phuser.com, needless to say I’d forgotten a lot of the commands! Here are a few MySQL tips which I’m putting up here for my own reference but if anyone else finds them useful then that’s great!

First thing I had to do was create a database, for this example we’ll call the DB stats.

CREATE DATABASE STATS

Normally you will want to create a new user to access your DB, here’s how to do this:

GRANT All PRIVILEGES ON stats.* TO ’statsBoy’@'localhost’ IDENTIFIED BY ‘rubbishPassword’;

Here I have created a new user called “statsBoy” with password “rubbishPassword”. I’m giving statsBoy all privileges to the DB and I’m only letting statsBoy connect from localhost so he can only to connect from the server the DB is on. Don’t forget to put the .* on the end of your DB otherwise you won’t be able to access your DB tables (this has screwed me over before!).

After doing any granting you’ve got to flush your privileges for them to take effect:

FLUSH PRIVILEGES;

Doing this will tell you “Query OK, 0 rows affected” it lies! Rows have been affected and your privileges should work now. I normally log on using the mySQL commandline interface and check.

Now my earlier password wasn’t very good, to change it do this:

SET PASSWORD FOR ’statsBoy’@'localhost’ = PASSWORD(’Rd1×3$k8′);

No flushing of privileges is required here. Well that’s all for today MySQL maniacs, I’m sure they’ll be more commandline Database Administration fun soon!

// Pete Graham

Posted in Uncategorized, MySQL, database, grants, changing passwords | No Comments »

Argh! Why MySpace does my nut in!

February 22nd, 2007 by Pete

Yesterday I was ranting about MySpace, in particular how their music downloads don’t actually let you download the song. While I’m at it I’ve got another mySpace gripe I’d like to get of my chest…

MySpace lets people include lots of things on their profiles such as songs, video’s, flash animations, etc. Due to this lots of profiles are slow to load. Often I’ll want to add comments to lots of people’s profiles, I’ve found the fastest way to do this is load each of their profiles up in a tab on my browser. I can see when a profile has finished loading, go to it, click the “add comments” link and then write my comment.

The problem with this is most profiles have a song which starts playing, if you load lots of profiles in tabs then all the songs start trying to stream at the same time and play over the top of each other, highly irritating! All these songs are being played with the mySpace media player, I’d like to see the developers change it so the player only plays one song at a time. I’m not sure if this is possible as I’m not a Flash programmer but you’d think mySpace would have enough money to figure out how to do this if it is.

One thing that definitely could be developed is an option to switch off the mySpace media player in your account preferences, not only would this make profiles faster loading but if you wanted to listen to your own music it would make using mySpace much less annoying.

Some people might say that mySpace isn’t designed to be opened in multiple tabs and I’m just causing these annoyances for myself. I think mySpace is designed for tabs but very badly. Consider the situation: you’re going to comment on someone’s profile, you notice they have got a good song on their profile and want to listen to it. The only way you can do this is either wait till the song has finished, or open the “add comment” link in a new tab.

Well that’s my mySpace rant over for the today, I hate you Tom!

tom from myspace is a wally
# Pete Graham

Posted in Tech, social networking, mySpace | 4 Comments »

Why mySpace Music Downloads are Rubbish

February 21st, 2007 by Pete

Today like most days I got added as a “friend” by a band on mySpace. Surprisingly the band was quite good and some of their tracks were available to download from their mySpace page, great!

myspaceplayer.png

When I clicked on the download track link the mp3 actually gets streamed in your browser using quicktime. It is not possible to right click the download link and “Save File As” because the mySpace media-player is flash based. What is the point of offering a download
link if your not going to provide a proper download?

irritating.PNG
The amount of bands using mySpace is quite staggering now days, it seems that every new band that comes out has a mySpace page, some don’t even bother with separate website. mySpace has multi-millions of dollars behind it and must have hundred of developers, the mind boggles why they can’t sort this, especially when one of the sites main appeal is supposed to be the music.

Now I sure the mySpace download feature used to work, interestingly I received a newsletter from mySpace the other day promoting their new Music Store. Conspiracy theorists will probably claim they’ve sabotaged the free downloads on purpose so people pay for music in the store. Well it certainly doesn’t entice me to buy anything from them, if they can’t offer downloads correctly imagine what they might do with your credit card information!

# Pete Graham

Posted in social networking, mp3, downloads, mySpace | 13 Comments »

Wii Mac Advert Parody

February 21st, 2007 by Pete

So there’s been some banter on this blog about the “Mac vs PC” advert spoofs over on YouTube. I’ve watched a few of them and this Wii VS PS3 spoof is current favorite. Enjoy!

wii_vs_ps3.png

/* Pete Graham */

Posted in Tech, Apple, Mac, Wii, PS3 | 3 Comments »

(Smug) Peep Show UK Mac Adverts

February 20th, 2007 by Pete

Apple has released some UK only adverts which feature the comedy duo Michelle and Web from the peek show. These adverts are a reworking of their Americans ones which feature one character as a PC; who is slightly uptight, uncool has bad hair and a bad suit. The Mac character on the other hand is laidback, friendly and hip. The adverts show the two characters interacting in various scenarios which help to point out how the Mac is great for “fun stuff” and the PC is best suited for business use.

macad.png

Personally I found the adverts quite amusing the first time I saw them (I’m now sick of them because they’re on the UK version of mySpace all the bloody time), did the adverts make me want to buy a Mac? No they didn’t. The reason for this the same reason other Mac adverts have irritated me in the past, they’re quite smug! The casting of Michelle and Web probably doesn’t help as we know their characters from the peep show. So before the advert begins I was imagining the “PC” character as being a quite likable but bumbling oaf, and the “Mac” character as being a slightly irritating pretentious twat.

I wondered if it was just me that saw the add like this because I’d watched a lot of the peep show but there is an article on the BBC site which voices very similar opinions. Maybe Apple underestimated how well known the comedy duo were in England.

Now I’m not anti-Apple, I used to own a iPod until it broke. One of the thing that I have found about some Mac owners is they will quite happily bore you about how much better Macs are than PCs with a slightly smug look on their face. Becoming one of these is the reason more than anything that’s prevented me from buying/using Macs. Is this attitude reflected by the adverts or caused by them? Your guess is as good as mine.

# Pete Graham

Posted in Tech, Apple, Mac, Adverts, Peep Show | 3 Comments »

Tech Superstars: Bruce Schneier

February 9th, 2007 by Pete

Tech Superstars is a new segment that I’ll be running. In it I will be profiling individuals that have made an important contribution to the fields of Computer Science or technology. Readers of my Peteamania blog will know I love facts, I’m sure you’ll be delighted to hear my Tech Superstar Profiles will contain facts galore!

Bruce Schneir Looking Buff

Tech Superstar #1 is security guru Bruce Schneider. Regular blog commenter fat-faced Phil Evans sent me a link to this brilliant Brucey facts website a few months ago. This is my favourite fact from it:

  • FACT: Bruce Schneier can losslessly compress random data by 50%, with his fists

The people that have made the Bruce facts site seem to like Knuth a lot as well. Personally I was never too keen on Knuth, he just seemed too wrapped up in Theory not the application. I mean the man is supposed to be a Computer Science legend but he doesn’t even read his email!

Anway I got a bit sidelined with my Knuth ranting, lets all agree that he’s “no Bruce” and I’ll be happy. Back to Bruce: The Bruce Schneier book Secrets & Lies is an excellent read on computer security. Unusually for a technical book it’s very readable [1] and entertaining, while containing some great explanations of how digital security works. I’d give you a quote from the book but Phil Evans has stolen it from me. Bruce’s Applied Cryptography book is supposed to be extremely good but I haven’t read it yet, don’t worry it’s on my ever growing list of things to do!

Anyway hope you enjoyed this first Tech Superstar Profile, if you would like to see someone in particular covered then add your suggestions in the comments section.

/* Pete Graham */

[1] Technically nearly all books are readable; I mean in this case it reads like an actual book rather than a technical manual

Posted in Tech, Bruce Schneier, Tech Superstars, Knuth | 2 Comments »

Email Interaction with Web Applications (using PHP, Postfix and Regular Expressions)

February 9th, 2007 by Pete

One of the popular facilities on phuser.com is the ability to create polls. Once a poll has been created it can be sent to people by SMS or Email. The recipients can reply with their choice of answer and a optional comment using SMS, Email or phuser web interface, lovely!

Handling of emails replies has easy been the trickiest part of this process. Here is a very basic overview of the steps we have taken:

  1. Have postfix forward the email to a PHP command line script that saves the email to file. Details of how to do this can be found here.
  2. Cron runs a PHP script that processes the email files. It makes sure the emails are valid, strips the users reply from the body of the email, and then adds the email to a database table.
  3. Crons runs another script which queries the database table and processes the emails replies, this is where the actually interaction with the phuser system (the magic) happens!

Today I shall be describing the regular expression that we used for Step 3 as it took a bit of effort to get right. Step 2 will be covered at a later date.Warning: when I cover Step 2 I will be having a rant about my new found hatred of HTML emails!

Note: Steps 1 and 2 are separate because security precautions on our servers prevent the Postfix user from interacting with the Databases.

When someone gets a poll email from phuser the content looks like this:

pete (pete graham) wants your opinion:

Which is your favourite drink?

Vote for one of the options below:

1) Tea
2) Coffee
3) I love them both like they were my children
4) Urgh! I can’t stand either!

——————— YOUR REPLY BELOW THIS LINE ———————

——————— YOUR REPLY ABOVE THIS LINE ———————

Reply using one of the following methods:

o Reply to this email. Include the number of your vote at the start of your message. Any extra text will be added as a comment. (Please do not edit the Subject line).

Now due to the difference in the way email clients work and the ways people think here is a small selection of the possible replies we needed to be able to handle:

  • > 1 I like to drink tea since I am a English Gentleman!
  • 4 I’ll have whats going
  • 3 – I hate them all
  • > 2)
  • 1) tea because I love tea!!!
  • 1 I’m not a big drinker of either since I’m the no-caffs, but like a cup of decaff tea
  • > 1
  • 2

So what we required is a Regular Expression which would correctly grab the number if one was included at the beginning so we could log the voting option. We also needed to grab the text afterwards if any was included so it could be used as a comment. Here’s what we eventually came up with:

CODE:

  1. /^[^\w]*([0-9]+)[^\w]*(\w.*)/ms

And it works, yay! The ‘m’ flag is set so the Regex is multiline , the ’s’ flag makes the dot character match every character including newlines. Here is the page that describes all the PHP regular expression modifiers.

If you want to learn more about regular expressions (and who doesn’t) then loads of information can be found on this site. Another great site is the one that we used to testing our regular expressions, it lets you supply up to 10 different test strings at once.

If you’d like to see this system in action then go to phuser.com and request an invite we are still looking for Beta testers currently, if you sign-up now you can have a real input into the site as it develops and grows.

Ps. The regular expression is in an if statement. If it fails the entire message is put in the comments section on the poll.

# Pete Graham

Posted in Uncategorized, phuser, postfix, php, regex, regular expressions | 8 Comments »

iPod is the new CD, and 3 different iPhones?

February 8th, 2007 by Pete

Apple Overlord Steve Jobs has also been getting his bearded face in the papers because he’s finally managed to settle the legal dispute between Apple Computers (now just Apple) and the Beatles owned Apple records. Interestedly Apple is now able to sell iPods preloaded with music. iPod will be the New CD is an interesting article which explores the idea that if iPod Shuffle can be sold cheaply enough preloaded with music they could completely replace CD’s. I though this theory was bizarre at first but iPod Shuffle’s are essentially flash memory drives with a few microchips for the firmware. Flash memory sticks are so cheap these days that many companies give them away like pens or key-rings. The articles author Leander Kahney speculates that the Shuffle’s could be skinned to make them more collectable, it’s certainly a good concept.

Theoretical iPhone range
There is an interesting article on Information Architects about a theoretical iPhone range. The article is quite detailed and explains the features each model would offer and the type of consumer they would appeal to. I can’t see anything like these actual models produced as they suggest dropping music playback from the iPhone, but I wouldn’t be surprised if Apple do attempt to create a range of iPhones.

One topic the article touches upon is the huge scope for simplification and reduction of facilities in modern mobile phones. You might want the latest phone with mp3 player, camera, and video games but your Gran probably doesn’t.

To read my previous iPhone pondering click here.

/* Pete Graham */

Posted in Tech, iPhone, Steve Jobs, Apple, iPod | No Comments »

Beginning of the End for DRM?

February 8th, 2007 by Pete

There has been much discussion in the media this week about DRM (Digital Rights Management) and downloadable music. Apple Overlord Steve Jobs has done a U-turn and now decided that he doesn’t like DRM, Jobs has told the press that the only reason songs downloaded from his iTunes store are locked with DRM is because “the big record companies made me do it”. Sceptics are saying this sudden change of heart is mainly due to new European DRM legislation which means come Summer Apple may not be able to sell downloadable music with their currently DRM setup in some countries.

Personally I’d love to have the convenience of downloading music from the iTunes store, the reason I don’t is I refuse to pay money for music locked into being stored on one computer and one device. If I go to the shops to buy a CD (or order CDs from Amazon) its less convenient but once I’ve got that CD I can rip, and then move or copy the files to which ever computer or mp3 player I want to use. Majority of digital Music is ripped from CDs, so why would people be anymore likely to copy just because it was downloaded?

The other reason I don’t use the iTunes store is I don’t think its great value for money. If I buy a CD it’s around the same price as downloading the Album but I get a nice case and a booklet, I can put that on a shelf with other CDs and impress chicks. I’d like to see Apple offer a subscription based service where the user pays a set free for as many downloads as they like. If people had no download cap on the iTunes store why would they bother “illegally” swapping mp3s with each other anyway?

Interesting Bill Gates stated in December 2006 that he feels that digital copy protection for music and video is too complex. Hopefully with big names in Technology realising that DRM is a problem this could be the begging of the end for DRM, but I wouldn’t hold my breath.

# Pete Graham

Posted in Tech, Steve Jobs, Apple, DRM, Bill Gates | 1 Comment »

BlogDesk Test Post

February 8th, 2007 by Pete

This is a test post written using BlogDesk application. Has it worked? I hope so. Expect a write up of the BlogDesk software later today. You can find out more in the meantime at http://www.blogdesk.org.

/* Pete Graham */

Posted in Tech, wordpress | 1 Comment »

« Previous Entries