Yearly Archives: 2012

How to change the background colour of a UIView

You can use the backgroundColor property for this:

Pre-defined values are

  • blackColor
  • darkGrayColor
  • lightGrayColor
  • whiteColor
  • grayColor
  • redColor
  • greenColor
  • blueColor
  • cyanColor
  • yellowColor
  • magentaColor
  • orangeColor
  • purpleColor
  • brownColor
  • clearColor

You can also define your own colours by creating a UIColor object (from RGB or HSL values). Here’s how you can create your own RGB colour and use it with the above example:

RGB and alpha must be defined as CGFloat numbers, i.e. between 0 and 1. The alpha value is the opacity, so 1 is fully visible and 0 is invisible.

Workaround: Parallels Desktop is not seeing my DVD Drive in Mountain Lion

Today I wanted to install Windows 7 using Parallels Desktop 7 on my Mac, but sadly I always got an error message every time I tried. It was saying it could not connect to my DVD drive – which clearly my Mac could.

Doing some research it turns out that several people had this problem, however I didn’t understand the instructions given by Parallels very well. Getting frustrated I decided to write my own, and give you some pointers where else to look for help.

For this scenario I’m using a DVD copy of Windows 7 Home Premium and the latest version of Parallels Desktop 7.0.15107. Parallels Desktop 8 is already out but I’ve decided not to upgrade at this point.

Continue reading Workaround: Parallels Desktop is not seeing my DVD Drive in Mountain Lion

How to create an NSString from an NSDate

First we’ll create a date object. Next we’ll create an NSDateFormatter and set how we’d like for display our date (and optionally our time). Then we’ll call the magical stringFromDate method which will create our string.

Where is the recurring payments dashboard in PayPal

I keep forgetting where to find what used to be known as the Recurring Payments Dashboard in PayPal. They’ve removed this when they restructured their menus a while back, and since then I’m lost when I need to find and change a subscription payment that’s coming in.

This option is now hidden in something rather cryptic and does not show up when you do a search on PayPal either. So without further ado, here’s how we can find our incoming subscription payments:

  1. Login to PayPal
  2. Head over to Profile – My Selling Preferences
  3. Find My Automatic Payments (that’s in the second block under “Getting Paid and managing risk”)
  4. Hit the Update link on the right
  5. Happiness!

Click on a payment to cancel or amend it. Hope this helps us all in the future.

How to retrieve the current User Locale

The following method will return a two letter code of which language is set on the iOS device in question:

There’s a list of language codes on Wikipedia: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

Note that to compare the current value against a list of languages you support we need use the isEqualToString method. Here’s an example:

The following articles have helped me figure this out:

How to bring back Scheduled Backups in Plesk 11

For those of you who hadn’t noticed, automatic scheduled backups are no longer working in Plesk 11 with some distributions. It’s not just you, and it’s not just your configuration. It’s a known issue according to this forum thread.

Lucky for us there’s a simple script which can bring this ever so important functionality back. Why Parallels is not addressing this with a Micro Update is beyond me (we’re already at 11.0.9 MU15 and it’s September 2012 at the time of writing).

In this article I’ll show you how to install the script step by step. I assume you’re logged onto your system as root and know your way around the command line.

Continue reading How to bring back Scheduled Backups in Plesk 11

How to move very large MySQL Databases

I’ve been shifting some things around and came across several very large WordPress databases for a few projects I was hosting. The largest was 1.3GB or 317MB compressed (!) which obviously poses a problem. Most sites – even those of frequent bloggers – amount to well under 2MB when compressed, but Multi Site or BuddyPress databases can get large quick.

To extract a database from a WordPress site, I’ve always relied on the superb WP DB Backup by Austin Matzko but even that timed out after 170MB.

In this article I’ll talk you through how we can handle this. I’m assuming here that a simple phpMyAdmin export/import isn’t working for you anymore. This is by all means not the only way to go about this task.

Continue reading How to move very large MySQL Databases

DNS Servers from OpenDNS

I was on the phone to Apple Support the other day. Among many other things they suggested that I use the OpenDNS servers for local DNS queries on my system rather than mu router’s.

An what do you know – they work faster indeed. Here they are – in case I forget:

  • 208.67.220.220
  • 208.67.222.222

To add those on your Mac follow these steps:

  • open System Preferences (click on the top-left Apple logo)
  • under Network, select your local WiFi network and click advanced
  • under DNS click the little plus sign at the bottom and add the above servers

Note that even though they resolve websites and domains faster, every now and again they do get it wrong. I guess they try for a certain amount of time, and if they don’t get a response from the server they just display an error message. In that case, delete them and go back to that of your router.