Tech Thought

Tech tips, hints, and general musings. PHP, Perl, Mysql, Javascript, AJAX, JSON, Linux, Mac OSX

Entries for the ‘Development’ Category

Countries of the world in PHP array

A handy snippet to share with anyone who needs access to the countries of the world (Australia/New Zealand at the top in my example) as a PHP list:

Leave a Comment

Facebook Connect Mobile: XML Schema Error on Mobile Devices

If you’re getting an XML error when you’re using Facebook Connect to post to a users stream using the function: $facebook->render_prompt_feed_url() Then ensure the following: You don’t have any double quotes in your attachment You don’t have any ampersands in your return URL For some reason the content is being placed in a hidden field [...]

Leave a Comment

Online Tool to Convert .ICS file to Excel/CSV

I couldn’t find a decent way online to convert ICS files into an Excel type format for easy manipulation, or adding to documents etc.  So I’ve built a simple one that is now available online: http://csv2sql.evandavey.com/ical2csv.php This takes an iCal URL and provides you with a CSV file as a download.  Makes it much easier [...]

Comments (5)

How To: PHP OAuth Twitter

So, you’re building a web based twitter client in PHP.  Easy, just use a simple Twitter API client and call the Twitter API directly.  But what if you don’t want to store the user’s Twitter authentication information anywhere?  It’s a security risk anyway and some people don’t want to give up their account details to a [...]

Comments (3)

How-To: Create my.cnf file in MAMP

This is a simple process, however not something I could find documented anywhere easy to find. MAMP supplies you with a range of sample configuration files: /Applications/MAMP/Library/share/mysql/my-huge.cnf /Applications/MAMP/Library/share/mysql/my-innodb-heavy-4G.cnf /Applications/MAMP/Library/share/mysql/my-large.cnf /Applications/MAMP/Library/share/mysql/my-medium.cnf /Applications/MAMP/Library/share/mysql/my-small.cnf To setup one of these for MAMP, simply issue the following command: sudo cp /Applications/MAMP/Library/share/mysql/my-choicehere.cnf /Applications/MAMP/Library/my.cnf

Comments (2)

What does iPhone OS 3.0 Mean for your Apps?

Recently I was involved in a podcast regarding the iPhone OS 3.0 upgrade. We looked at all the new features (and some upcoming ones in v3.1) and discussed how they relate to new features clients can develop in their apps. You can hear more here: What does iPhone OS 3.0 Mean for Your Apps (WSP [...]

Leave a Comment

Google Maps: Zoom Level, Center from points on map

So you’ve created a pretty Google Map on your website.  You place a whole heap of markers on your map, driven from data you’ve got stored in your database. A nice thing to do when we first show the map, would be to ensure that all the markers are visible on the map. To do [...]

Comments (1)

yum fails: Fixing Fedora Core 5 yum repositories

Fedora Core 5 is currently EOL – it’s not supported any more.  As a result, you might find you can’t use yum to install packages any more – you get an error message about this file not existing: http://download.fedora.redhat.com/pub/fedora/linux/core/5/i386/os/repodata/repomd.xml This is because the repositories that yum uses aren’t there anymore.  However you can modify the [...]

Comments (6)

How-To Fix: MAMP won’t start

Okay, so sometimes our shiny friend and development support buddy MAMP won’t start properly.  I’ve found this often happens when you’ve first booted up your Mac and you try to start getting stuck into your code. Symptoms are pretty simple to diagnose – you start MAMP, and it’s control panel pops up and shows that everything [...]

Comments (2)

How-To: Move change the address of a SVN repository

So you’ve changed where you host your subversion repository for a particular project and you want to update your local copy so that it points at the correct address?   How do you do this?  Simple: svn switch –relocate http://oldserver.com/PROJECT  http://newserver.com/PROJECT This will recursively modify all the .svn folders contents so they point to the correct [...]

Leave a Comment

How-To: Solve ‘modifying layer that is being finalized’ iPhone SDK

Okay, so I’ve been getting the ‘modifying layer that is being finalized’ error message when i’m trying to release a subview from a superview: [self.popupPreviewView release]; self.popupPreviewView = nil; The best way to solve this (that I’ve found – please post a comment if you can provide a better one) is to remove the view [...]

Comments (2)

iPhone App Icon Doesn’t appear on iPhone, works in Simulator

If your iPhone App icon isn’t appearing on your phone, but works fine on the simulator, it may be a problem with the way you’ve saved your Icon.png file: I had this problem, until I chose to “show” the extension of the Icon.png file when I saved it from within Preview.  Once I’d done this, [...]

Comments (2)

How-To: Make UIWebView transparent

Common problem, need to apply nice HTML formatting for a section of your page, but want the UIWebView not to appear as a big white box – only the content of the UIWebView to appear. How to do it? myWebView.opaque = NO; myWebView.backgroundColor = [UIColor clearColor]; [myWebView loadHTMLString: @"<html><body style='background-color: transparent'> Content Here</body></html>" baseURL:nil]; The above [...]

Comments (2)

Objective-C: Calculating Days, Minutes, Hours from seconds

If you need to convert a total number of seconds into specific components (days, hours, minutes and seconds) in Objective-C, you can use this code snippet.  You can probably do this a million other ways, but this works beautifully for me:     NSNumber *valueForDisplay = [NSNumber numberWithDouble: [self valueForDisplay:clockName]];     NSNumber *totalDays = [NSNumber numberWithDouble: [...]

Comments (5)

How-To: Show/sync volume control in iPhone SDK

Developing for the iPhone, we wanted to show a volume control that sync’ed with the user’s volume control buttons on the side of the phone.  It turns out, the best way to do this is to show the volume control using the MPVolumeView class (part of the MediaPlayer framework). Here is some example code from [...]

Comments (2)

How-To: Fix ‘Verification Failed’ error (0xe8000001) iPhone Adhoc Distribution

I have had huge problems trying to provide my iPhone Applications to friends using the Adhoc Distribution method.  I thought I was following Apple’s instructions down to the letter: Obtain an Adhoc Distribution Provisioning Profile Install provisioning profile in XCode For my project, create a new build profile called “Adhoc Distribution” copied from the “Release” build [...]

Comments (7)

How-To: Convert a string to NSDate

In Objective-C, you commonly nead to convert a string to an NSDate object.  A simple way to do this is using the NSDateFormatter object.  It provides the dateFromString method which converts a string into an NSDate object.  You do, however, need to tell NSDateFormatter the format the date will be in.  See below example: NSDateFormatter [...]

Comments (4)

UIScrollView not working – scrolling doesn’t work

Okay, so I’ve just spent the last few hours trying to work out why my UIScrollView won’t scroll! The secret, I’ve found, is the following: – (void)viewDidLoad {     [super viewDidLoad];     // Setup scroll view     [scrollView setContentSize:CGSizeMake(backgroundImage.frame.size.width, backgroundImage.frame.size.height+200)]; } You must call setContentSize and pass it an object which has a greater size [...]

Comments (13)

iPhone Development: How to Stream Audio (mp3)

Okay, so we’ve fully taken the plunge and are now developing for the iPhone platform.  Its got a fantastic SDK, with lots of really nice features and tools to help you with your developing fun.  However some tasks are a little more difficult than you’d image. For instance, we wanted to stream an MP3 file [...]

Leave a Comment

How-To: Redirect to different URL using Javascript or META tags

If you need to redirect from one page to another, you can achieve this with either a META tag redirection or Javascript.  See below for an example.  You should provide a manual link as not all browsers support META tags – and javascript won’t work if its been disabled: <html> <head> <title>Move my domain!</title> <meta [...]

Comments (1)