[PHP] Faster array lookup than using in_array()

If you use arrays in PHP, one of the most common tasks you’ll find yourself doing is determining if Item A is in Array X. The function you would probably use in this case is PHP’s in_array.

[php]bool in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] )[/php]

This function works great and I recommend sticking to it when it makes sense. However, when you’re dealing with a very large haystack and need to run in_array() on thousands of values, you’ll discover that in_array isn’t particularly fast when cumulated over thousands of calls. Having recently run into this situation, I set up a little experiment to try two different approaches to in_array().

Continue reading [PHP] Faster array lookup than using in_array()

Angry Birds Space Box

A few days ago, I was lucky enough to be selected as the winner of a Twitter contest organized by @angrybirds:

Today, the package has arrived and I must say, it rocks! A big thank you to Rovio, the Angry Birds team, and a special shout-out to the person or people managing the incredibly active and responsive @angrybirds Twitter account.

Angry Birds Space Box
Angry Birds Space Box

Simulate different network connectivity conditions with OSX.

Update 23/04/2014: The installation procedure described below no longer works on Mavericks. Instead you must download the Hardware IO Tools from the Apple Developer portal (search for Hardware IO Tools and download the latest .dmg available). From that .dmg, you’ll be able to install the preference pane.

Update 25/09/2012: Network Link Conditioner also available in iOS6 on devices.

Since the release of OSX Lion, the Apple Developer Tools have included a nifty tool to help developers simulate different network conditions. This is particularly useful for iOS developers who want to test and debug apps via the simulator and pretend they have an Edge/ or 3G-like network connection. To install the Network Link Conditioner, go to the Network Link Conditioner folder located under “/Developer/Applications/Utilities/” and install the preference pane (reminder: You must have OS Lion or above installed). Once installed, you’ll see this :

Continue reading Simulate different network connectivity conditions with OSX.

Why Over-the-Air updates is a game changer for iOS

iOS 5 is just around the corner and developers have been using the beta version for a few weeks now. It’s coming with oodles of new features ranging from a shortcut to your camera when your screen is locked to a completely revamped Notification center. You can read more on that here. What I find most interesting is that Apple has finally decided to cut the cord and is implementing or upgrading many features to be completely wireless. Though most of these features have been extensively covered and were, for the most part, predicted by the user community, some features are real game changers for iOS where as they might not have been for other platforms.
Continue reading Why Over-the-Air updates is a game changer for iOS

Fixing iOS 4.3.3 WiFi bug

iOS 4.3.3 seems to affect the WiFi connection of some iphones. In any case, if your WiFi on your iPhone has suddenly seems to be very slow or disconnects very often, assuming you haven’t changed any settings on your router(s), and if you recently updated to iOS 4.3.3, there might be a simple trick you can use while we wait for Apple to update.
Continue reading Fixing iOS 4.3.3 WiFi bug

Streaming video from your Mac to your Apple TV2

Air Video
Air Video Player/Server
iOS4.3 introduces a buffed-up Air Play and Home Sharing which is really great but if, like me, you don’t have tons of .mp4 files lying around, you might be looking for a solution to play DivX, AVI, or .mkv videos wirelessly from your Mac to your Apple TV. This solution allows you to do just that except that you’ll have to go through an iPhone or an iPad too.

With the arrival of iOS 4.3, developers are finally able to harness the power of AirPlay which means bye-bye HDMI cable from my Mac to my TV to watch videos. Here’s what you need :

  • Apple TV 2 fully updated to iOS 4.3 or later
  • An iPhone or iPad running iOS 4.3 or later with Air Video installed
  • Air Video Server from http://airvideoapp.com

At the time of writing, Air Video costs €2,39 but frankly, it’s worth it. The app is awesome. If you really want to catch a deal, you can always head on over to Appsfire.com and track the app. Update: There’s a free version here but I don’t know if it’ll serve this purpose.

To stream a movie from your mac, follow these steps :

  1. Install Air Video Server
  2. Set up your preferences and set which folders you want the app to play videos from
  3. Make sure the server is On. (Start Server)
  4. Launch the app that you bought from your iPhone or iPad, connect to a server (in this case, your Mac
  5. Browse to the video you want to play and hit Live Conversion
  6. Once the video starts playing on your device, hit the AirPlay icon and send it to your Apple TV – you’re done! Enjoy the show 🙂

Editing hosts file in Windows 7

NOTE: This example uses the file “hosts” as an example but other files can also be modified using this technique.

If at some point you need to modify your hosts file in Windows 7, you’ll most likely have to change your access rights to that specific file.

Please note that you have to have administrator privileges to make the following changes.

  1. In Explorer, go to the file you wish to Edit. In this case “c:\windows\system32\drivers\etc\hosts”
  2. Right-click on that file and select “Properties”
  3. Select the “Security” tab
  4. Select your User.
  5. Click on “Edit”
  6. Click on your username again and modify the permissions as you wish. In most cases, you can give yourself “Full Control”
Changing file permissions for a file in Windows 7