How to use a custom font in my iPhone app

I received some custom fonts from the designer to use in an iPhone app I’m developing.
Stackoverflow gave some ideas, and the best method I found is this:

1. Convert font file to TTF using this online tool: http://www.freefontconverter.com/
2. Add the TTF files to your project
3. Make some configurations to your info.plist file:
3.1 Edit info.plist as source code (right click on file -> open as -> source code)
3.2 Add this:


UIAppFonts

font1.ttf
font2.ttf
...etc...



3.3 Your info.plist should have this now:

4. Use the new fonts just like the system fonts:

[UIFont fontWithName:@"font1" size:16.0];

(Notice no “.ttf” in the font name)

Good luck using your own fonts in your iphone app!

PHP: How to get aerial distance between two GPS coordinates

I wanted to calculate the distance between two GPS coordinates in Kilometres
There’s an algorithm called “Haversine Great Circle Distance” that does just that.
Here’s a PHP implementation of the Great Circle Distance algorithm:

function haversineGreatCircleDistance($latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo) {
// convert from degrees to radians
$latFrom = deg2rad($latitudeFrom);
$lonFrom = deg2rad($longitudeFrom);
$latTo = deg2rad($latitudeTo);
$lonTo = deg2rad($longitudeTo);

// calculate delta
$latDelta = $latTo - $latFrom;
$lonDelta = $lonTo - $lonFrom;

$angle = 2 * asin(sqrt(pow(sin($latDelta / 2), 2) + cos($latFrom) * cos($latTo) * pow(sin($lonDelta / 2), 2)));

return $angle * 6371; // earth radius in km
}

Mac: How to flatten a directory structure

I wanted to upload a lot of videos to my picasa cloud
The problem: videos are in sub-sub-folders by date, and I don’t want to open each sub-sub-folder and drag the video from there…
The solution: a command that flattens the directory structure:

find ‘/path/to/source/folder’ -iname ‘*.*’ -exec cp \{\} ‘/path/to/destination/folder’ \;