Monday, October 12, 2009

Mac OS X 10.6 Snow Leopard, iPhone USB Tethering and Bad Carriers

Since iPhone OS 3.0 it is possible to [officially] use your 3G internet connection right into your laptop. That works very well for the all new Snow Leopard, with one single drawback: it is not possible to set name resolution servers when tethering via USB.

You might think it is a small issue but I would say you can be wrong, sorry. Relying on carrier's default DNS can be very annoying when they are faulty. And thats exactly what happens with me all the time. My carrier DNS frequently stops resolving top hit domains such as google.com and many more.

Of course I can switch to bluetooth, in which case Snow Leopard "weirdly" allows you to set your own DNS. But keep in mind that sometimes the phone might have no battery for that. Again, I could just let the phone plugged in a power outlet and bring bluetooth up, but that would have any fun ! I like to have choices, and not being able to tether via USB is something that annoys me and challenged me for quite some time.

No more bla bla bla, I could fix my problem when I found about something called configd and scutil. You can find a bit of information about them here and here. Going straight to the point, I could manage to overwrite my default DNS (with the address for opendns) using scutil and a little of bash scripting. That is what I came up with:


#!/bin/sh
#
# Replaces current DNS with the one you want in Mac OS X
#
# Author: Igor Feghali 
# 

#DNS="208.67.222.222 208.67.220.220"
DNS="8.8.8.8 8.8.4.4"
STATE=`echo "list State:/Network/Service/[^/]+/DNS" | scutil | awk '{print $4}'`

(echo "d.init"; echo "d.add ServerAddresses * $DNS"; echo "set $STATE";) | sudo scutil


You can set the contents of the variable DNS in the above script to whichever you want. But don't get too excited. This solution will work only for a few moments. I guess that's because configd rebuilds the network configuration periodically.

A short visit to configd man page led me to the right place: /Library/Preferences/SystemConfiguration/preferences.plist stores the preferences for all the network interfaces. The first thing to do is to find out the HEX code of which one we want to modify.

That would be BB6EBCF-861B-4A73-94FE-E08F7EEEE5EE for me. Now open preferences.plist (in the above path) and look for the key string somewhere in the file between a <key> and a </key>. Now replace:


<key>EBB6EBCF-861B-4A73-94FE-E08F7EEEE5EE</key>
<dict>
<key>AppleTalk</key>
<dict/>
<key>DNS</key>
<dict/>

with:

<key>EBB6EBCF-861B-4A73-94FE-E08F7EEEE5EE</key>
<dict>
<key>AppleTalk</key>
<dict/>
<key>DNS</key>
<dict>
<key>ServerAddresses</key>
<array>
<string>208.67.222.222</string>
<string>208.67.220.220</string>
</array>
</dict>


Just be sure to edit the file as root ($sudo vim for instance), save and reboot. That should do the trick.

I couldn't manage to reload the system configuration without a reboot, just let me know if you do.

Monday, June 22, 2009

PHP'n Rio 09

The PHP Local User Group of Rio de Janeiro - PHP Rio are pleased to announce their 1st PHP'n Rio conference. It will be held July 03rd at the
Infnet Institute, Rio de Janeiro. It is a one day mini conference, aimed on providing experienced developers and beginners a chance to learn more about PHP frameworks, web
applications built in PHP and testing code.

The keynote speaker is Jan Schneider that will talk about the Horde project. We will also have sessions about other frameworks and a PHP TestFest.

PHP'n Rio sessions goes from 6pm to 9pm. Then PHP TestFest follows up
to 10pm. No fees or subscription required. Participation is entirely
free !

Whether you live here or are around just enjoying the marvelous city,
come and join us :)

For more information please visit the official site (portuguese only).

We are looking for sponsors so we can bring even more speakers from
around the country while keeping a great conference for free. If you
see your company fits as our partner, please email Igor Feghali <ifeghali at phprio.org>

Saturday, March 7, 2009

PHP Test Fest 2009

What is it ?

The TestFest is an event that aims at improving the code coverage of the test suite for the PHP language itself. As part of this event, local User Groups (UG) are invited to join the TestFest. These UGs can meet physically or come together virtually.

When is it going to happen?

UGs are free to pick any timeframe in April - June 2009. Each local TestFest can last a day, a week or any other timeframe.

Where do I get more info?

At the official site of the event.

Scalable logo for advertising

I used Inkscape to vectorize the official logo designed by Vincent Pontier, so you can make smaller/bigger bitmaps while keeping the good quality.