Aug 14 09

Macbook Insomnia – Keep your Macbook awake when the lid is closed

by Jordie
Stop your Macbook from sleeping when you close the lid

Stop your Macbook from sleeping when you close the lid

I recently ran into a problem with my Macbook Pro. I wanted to have the lid closed but have my mac still on and my programs running. Why would I want this? Well if I’m in the middle of a chat, or want to keep a download running while I sleep or move to another room, then I don’t want my computer to sleep when I close the lid, of course!

Cue the aptly named program, Insomnia. read more…

Aug 11 09

Drop multiple tables from a MySQL database

by Jordie

Problem:

I want to remove a set of tables from the database quickly. Larger applications have dozens of tables, this can be annoying if you want to drop them all, but don’t want to drop the database.

Solution:

Most PHP applications that deal with MySQL will use a table prefix when generating their tables. Using this prefix and calling MySQL from shell we can use this command to drop all the tables with a specific prefix. Just fill in the coloured bits:

mysql -u username database_name -e "show tables" | grep "tableprefix_" | gawk '{print "drop table " $1 ";"}' | mysql -u username database_name
Jul 21 09

Things that annoy me on my Mac…

by Jordie

Don’t get me wrong, I love my new MacBook Pro. It’s awesome. However, like changing from any system to another, things are done differently. Some things are better, others are worse or just plain different. There are a few things that I’m finding frustrating on my Mac. Somethings here are just a matter of changing my habits, e.g. hotkeys/shortcuts, others are just how stuff works on a Mac.

Mac OS X General

  • Pressing ‘tab’ on web-forms doesn’t tab to selectboxes or checkboxes or buttons. Very frustrating.

In Firefox

  • Pressing Command-Left makes the browser navigate ‘back’ when my intention was moving to the beginning of the line in a WYSIWYG editor or text box.

In TextMate

  • In the ‘Go to file…’ (i.e. Command+T) I can’t search folders too. E.g. I have a number of files in a project with the same name, over 50 to be exact. I want to be able to put their parent folder in too to narrow down the list. I can’t do this!
Jul 21 09

Welcome to Kohana!

by Jordie

One of my projects is a jokes website. It’s been up for a few years at the domain www.funny-jokes.net and it’s been my most profitable website to date. It’s paid for it’s hosting and more over the time I’ve had it. I’ve been able to develop it in bursts then let it run on auto-pilot thanks to Google Adsense. However, of late I have not done much with it. Therefore I believe it is time to give it the love and care that it needs, and hopefully to see it grow much larger.

While it’s a half decent website, the design could do with a well-deserved make over. In addition, I think the back-end code needs to go. Thinking about my past development on the website, I’ve come to a realisation that I’ve wasted a lot of time on it. Just like a lot of programmers out there, I have been stubborn in the past and jumped at the chance to build a website from scratch. I’ve re-coded and re-designed Funny Jokes too many times. New ideas on how to structure the website coming into my mind every other day. It’s fun to play with new code like that, but after you’d implemented the cool stuff, it gets a bit boring to finish it up. It’s also frustrating to get down to the nitty gritty stuff and find that I didn’t plan far enough ahead.

Well, with my recent attitude of trying new things (Wordpress, Macs) I’ve come to realise that maybe, just maybe, the people who always ramble on about frameworks might actually be right. Thinking about it, it actually makes sense. Using a framework allows you to use a tried and proven methodology for building a website, with core code in place that means you don’t have to reinvent the wheel for every website. I’m short on time at the moment, so this suits me perfectly.

Right, so, I’m going to use a framework. But which one? There are a few out there that many people suggest. CakePHP and Zend Framework come to mind as the most popular. CodeIgniter has also been mentioned to me as a “light-weight alternative”. However, they all have a serious weakness that has kept me away from frameworks. Bloat. Big fat Bloat. Where does this bloat come from? Backwards compatibility. These three popular PHP frameworks still have support for PHP 4. Yuk. PHP 5 has so many advantages over PHP 4 and it’s about time that PHP 4 go away anyway. If I’m developing a new website, I’m going to want to run it on the newest version of PHP (or most recent stable version).

Why not keep the framework up with the times? Backwards compatibility is only awesome when dealing with end-users, for example Windows or Web Browsers. You do it so you do not alienate large portions of your users. However, with frameworks, we’re talking developers here, and more often than not new websites will run on newer PHPs. People with older PHPs will have to use older versions of the framework until they can upgrade (which really shouldn’t be an issue, we’re talking about techie people here).

After a bit of searching around I’ve come across Kohana. It is a light-weight framework (originally based on CodeIgniter) but it’s main advantage is that they don’t care about old PHP versions, so there is minimal bloat and all the latest and greatest features available. At the time of writing, the minimum version if PHP 5.2 and PHP version 5.3 only just came out. It’s strongly built around PHP OOP and uses the MVC design pattern for code.

When you get Kohana working, you’re greated with a sample page with the title ‘Welcome to Kohana’, so I thought that would be fitting for the title of this blog post. Kohana is now my framework of choice as a redevelop funny-jokes.net. Wish me luck!

Jul 20 09

Funny Observation: Mac OS X uses BSOD for Windows shares

by Jordie

While attempting to hook up my Windows PC with my MacBook, I noticed the icon for the PC shares on my Mac seemed a bit funny. If you right-click/double-finger-tap on the share and go to ‘Get Info’, you can see the full size image… It’s the notorious Windows BSOD image, Apple seems to be representing ALL PC’s by using a BSOD image. Check it out:

Mac OS X using the BSOD to represent a PC share

Mac OS X using the BSOD to represent a PC share

Jul 20 09

Taking a screenshot on a Mac

by Jordie

As a Windows person, I’m used to taking a screenshot by pressing print-screen (or alt + print screen for the current window only). However I had no idea what to do on my Mac when I found I didn’t have a print screen button.

After a quick search, I found the key combination that I wanted was Command-Shift-3. This takes a whole-screen screenshot and saves it to your desktop.

Alternatively, if you want to only take a section of the screen, you can use Command-Shift-4 and then drag an area of the screen. If you press space after the command you can single-click a window to take a screen shot of the window (similar to alt+print screen in Windows). The results are saved to your desktop.

If you want the screenshot on your clipboard (like Windows) instead of a file on your desktop, use the same commands as above, but also hold down Control. E.g.  A whole-screen screenshot becomes Command-Shift-Control-3.

How to take a screenshot on a Mac

How to take a screenshot on a Mac

There are a few other methods available for doing this, including taking a picture using the terminal. You can see these methods over at MacRumors Guides.

I hope this helps any other Mac convertees out there!

Jul 16 09

Editing the hosts file in Mac OS X

by Jordie

One of the first things I needed to do when I got my Mac is to edit the hosts file on it. To do this you need to open a new Finder window, click Shift + Command + G and type in ‘/etc’ without the quotes.

There will be a file in the resulting finder window called ‘hosts‘, this is the file you want to modify. However, I found that I didn’t have sufficient privileges to edit the file. You need to right-click (on my laptop it’s tap with two fingers) and go to ‘Get Info’, then in there under ‘Sharing & Permissions’ you need to add your user using the plus + button and then give yourself Read & Write access. After that you can edit the file.

Jul 16 09

My new MacBook Pro

by Jordie
This is my new MacBook Pro

This is my new MacBook Pro

Today I got my new MacBook Pro. It’s a 13″ laptop, which I hope will allow me to work more efficiently… and from the comfort of my bed. Exhibit A is to the right. My specs are as follows:

  • 13″ Pro, with backlit keyboard
  • 2.53Ghz Intel Core Duo 2
  • 4 GB RAM
  • 500GB HDD

So far I’ve been adjusting… I just have to ask around or research how to do certain things. I few things I miss are the ‘End’ and ‘Home’ keys. I also find it difficult to press Fn+F5 to refresh a page rather than just F5, and getting used to the different anti-aliasing on the fonts is still hard. Though I have to say, websites look a hell of a lot better than they do on Windows.

I’ll post more as I find stuff out, hopefully it’ll be useful for others trying to migrate to a Mac.

Jul 16 09

My Project Plans

by Jordie

This is an outline of the projects that I hope to develop and work on over the coming year.

Annnnnnyway, my future/current/planned to update projects are:

  • versiontracker.info – Extremely simple version tracking service. It’ll keep track of the latest version updates to common programs and utilities. It’ll tweet about new updates, too!
  • funny-jokes.net – A website with a collection of funny jokes. It’s been around for a while, but I want to give it a decent design with new features and Facebook connect integration.
  • jordiebodlay.com (this site!)
  • phpdoctor.net – A PHP focused blog with tutorials and questions/answer solutions for users)
  • sitenest.com – Not sure what I will do this one exactly… I do have a page up but it was just an initial concept. It turns out it could be a conflict of interest with my current job, so I might put it on hold or use it for something else.

I have dozens of other domains to use, but I think I’ve narrowed it down to developing and maintaining these projects first. I may look into getting a designer to help me out with the designs for some of the sites.

Jul 7 09

My WordPress Experience

by Jordie

So I’m starting a new blog… I’ve been keeping myself away from WordPress for a while. I currently work on a commercial content management system so I have this elitist view of my own software. However, good developers need to know their competition well, especially if one is to overcome them. Therefore I am becoming rather good friends with WordPress.

I’m starting off with WordPress version 2.8, I’ve used other versions briefly before and I already I can see that 2.8 is a major improvement. The new control panel interface is very slick. The editor region looks far better than the plain TinyMCE skins.

I’ve noticed some usability things here and there, but that’s just getting to know the product.

- Something I’m amazed at is that you have to delve into the PHP code to add in your database details. It’s really not that hard to have an online interface that handles that as the first step when installing the product. It’d take the “famous 5-minute installation” (I’ve never heard about it before) down to 3 or 2 minutes. This is especially true when every other feature of the application makes it so easy to use without knowing PHP.

- When you first login, it prompts you to change your password. So I did and clicked save…. and …. well nothing. It saved, but the message telling me was at the top of the page and WordPress scrolled me back down to the bottom where I clicked the button. Hmmm… If you’re going to scroll me, perhaps implement fixed success messages like Twitter.

- Custom URLs, I like the layout of the interface you have. It would be great if you had the available tokens/placeholders I could use in the URL straight up. Also, I would say /%postname% is a very common URL pattern, it should be listed on the common layouts.

- Theme downloading – I’m grateful for this feature. We’ve had this in our product for some time now. I think we implement it in a cleaner way, something about the WordPress version just doesn’t seem as “nice” as it could be. Not sure what specifically it is…

So far I haven’t done much else. I shall dig around more and see what I can do with it. I’ll post about my experiences — perhaps they’ll bring me some page hits ;)

Update: Just used the download update to 2.8.1 and it worked like a charm. I love it, in fact. Go WordPress!