How to setup MySQL Master/Slave Replication with existing data
This is a step-by-step guide on how to replicate an existing MySQL server. The server is live and contains data and needs a constant backup companion. Many tutorials focus on how to setup replication when no data is present on the system. That’s an ideal solution if you’re building a new setup, but in case you’ve got a server that already has data present then here’s how to accomplish the this: setup your existing MySQL server (with data) as a Master export all your databases and user accounts create a slave and import...
read moreHow to install CentOS 6 on a Samsung NC10
Today was a rather exciting day for me: I’ve successfully turned my aging Samsung NC10 Netbook into an internal server in our office. I bought the little guy in 2009 and he’s been my trusty companion on many jobs before I got an iPad. He still works fine, even though Windows XP was getting weird of late – and admittedly I hadn’t even turned him on in over 8 months. Now my trusty pal is running CentOS 6.4 while sitting quietly in a corner next to the modem, serving as an internal Linux server. This is great for testing...
read moreHow to switch SketchBook Pro 6 into Full Screen Mode
The Mac version of Autodesk’s SketchBook Pro 6 works well on small screen – but since real estate is limited, there is a way to switch the app to Full Screen Mode. Rather than the double-arrow in the top right corner though, you’ll have to use the shortcut OPTION+CTRL+J Don’t ask me why, it’s not very well documented for such an intuitive app. And since I keep forgetting how to do this, here it is in writing. Thanks to Eric from Autodesk for this tip (discussion)
read moreHow to create an NSDate object
The easiest way to create an NSDate object is to create “right now” with our convenience method date: NSDate *myDate = [NSDate date]; But if you want to create a date object with a date such as your birthday it gets a little bit trickier, and – more importantly – much less obvious. To do this, we need to create an NSDateFormatter, tell the formatter how to expect the date, and then use its convenience method dateFromString to create the date: NSDateFormatter *formatter = [[NSDateFormatter alloc]init];...
read moreHow to display the full month from an NSDate (such as “February”)
There was me thinking I’d have to whip out NSDateComponents and NSCalendar – but my mind works too complicated at times. All we need to do this is our good friend the NSDateFormatter and the Unicode Date Format MMMM – let’s check it out: // create today's date NSDate *myDate = [NSDate date]; // create a date formatter and set its format NSDateFormatter *formatter = [[NSDateFormatter alloc]init]; formatter.dateFormat = @"MMMM"; NSLog(@"The current month is %@", [formatter...
read moreHow to create Linkshare Affiliate Links to iTunes Products
One of the worst ever interfaces i have ever come across is that of Rakuten LinkShare. Even before they’ve been bought by Japanese giant Rakuten it was bad, and it hasn’t been improved since I’ve signed up with them in 2008. Lucky for us we don’t have to use their interface to get links to iTunes Products – we can use the standard good looking and well working iTunes Link Maker. All we need is go there via LinkShare, which will embed our affiliate code. Here’s how to do this step by step: 1.) Login to...
read moreHow to create a UIBarButtonItem in code and make it call a method
Some things are really easy to do via a Storyboard – but when you want to create the same thing in code I frequently forget how to do it. Turns out it’s equally simple: this example assumes you have a View Controller which is embedded in a Navigation Controller (so it already has a UINavigationBar at the top). Here’s how you add a button to it, set the title and target, and tell it what to do when it’s pressed: – (void) viewDidLoad { [super viewDidLoad]; // first we create a button and set it's properties...
read moreHow to remove a Core Data Model Version
Core Data can handle several versions of your Model. It’s easy to add a version (via Editor – Add Model Version) and set it active, but it’s not so easy to remove a version you no longer need. Thankfully there is a way to delete version files which goes a long way to declutter your brain. The secret lies in the fact that the .xcdatamodeld file is actually a Package and can contain more than one file. It’s like the .app extension which isn’t just one file. I never knew this! To explore, select your versioned...
read moreHow to create a View Controller defined in you your Storyboard programmatically
Your View Controllers are created by the Storyboard automatically depending their defined relationships in Interface Builder. Sometimes however we need to create and transition to View Controllers we’ve defined in code. For example, if you want to transition to a view as part of displaying a search result. We can do this by creating a new UIStoryboard object and then asking it to create a View Controller defined in it. For this to work you need to give your View Controller a unique identifier using the Identity Inspector (under...
read moreHow to add a Search Display Controller to a UITableView (in code)
We’ve recently discussed how to deal with a Search Bar and Search Display Controller using Interface Builder. You can however do this in code too. This can be useful if you don’t want to make all the relevant connections in every Storyboard. This example assumes you have a Table View (self.tableView) to which you’d like to add a Search Bar and Search Display Controller at the top. We do this by utilising the Table View’s tableHeaderView property: // create a new Search Bar and add it to the table view UISearchBar...
read more