Facebook user id & Mysql Field
tip: remember that, for any reason, you want to store the facebook user id into a mysql field you should use BIGINT unsigned type.
Add Open Graph support in headMeta() View Helper
I’m currently working on a web app with ZF and I want integrate the just released Open Graph protocol.
The headMeta() view helper shipped with ZF have a check to permit only a few attribute (‘name’, ‘http-equiv’, ‘charset’) but the the OG protocol expect to use the ‘property’ attribute and if you try to use ‘property’ as key a PHP error is raised.
A ticket is just opened in ZF Issue Tracker (http://framework.zend.com/issues/browse/ZF-9743) but until the development team does not implement this improvement I made a little hack. It’s just a view helper that subclass Zend_View_Helper_HeadMeta and adds to the array of accepted values the ‘property’ value.
Buddypress Avatar Moderation Plugin
The current version of Buddypress (1.2) doesn’t support the avatar moderation. But unfortunately we don’t always have trusted user, and we want to have a minimum of control, for example we don’t want explicit image or for some “political” reason we want only real photo with the person’s face.
For this reason i’ve created a very simple plugin that let you delete unwanted avatar.
The behaviour is very simple: when a user upload a new avatar, save the userid into db. The admin can accept the avatar or physically remove the avatar file.
You can find the plugin source code at my GitHub:
As you can see the plugin is far from be complete, but the collaboration is highly encouraged so feel free to edit my gist.
For any question or suggestion use the comment.
Use iPhone’s proximity sensor
iPhone has a proximity sensor that can tell whether the device is close to some surface. The best-known use of this sensor when iPhone is brought near the face during a call (at about 2 cm) , the system deactivates the display and touchsreen immediately saving some precious battery power and preventing inadvertent inputs from the user’s face and ears.

Fortunately, with version 3.0 of the SDK APIs to access the proximity sensor were made public and all the mehod are in the UIDevice class(Before SDK 3.0 were located in UIApplication).
According to Apple’s documentations
The UIDevice class provides a singleton instance representing the current device
So we must first obtain the singleton istance:
UIDevice *device = [UIDevice currentDevice];
Proximity sensor is not active by default so is necessary enable it, to do this set the proximityMonitoringEnabled property to the Boolean value YES.
device.proximityMonitoringEnabled = YES;
Still according to Apple’s documentation :
Not all iPhone OS devices have proximity sensors. To determine if proximity monitoring is available, attempt to enable it. If the value of the proximityState proximityMonitoringEnabled (there’s an error in documentation) property remains NO, proximity monitoring is not available. So:
if(device.proximityMonitoringEnabled == YES) {
/*do something */
}
else{
NSLog(@"No proximity sensors on your device");
}
Now we finally want to know the status of proximity sensor, there are basically two ways to do this:
- you can instantly check the sensor value with the property proximityStatus that returns a Boolean value.
- or you can set up your Object to became an observer of the UIDeviceProximityStateDidChangeNotification notification and register a callback that read the sensor value, to do this use the following code:
UIDevice *device = [UIDevice currentDevice];
device.proximityMonitoringEnabled = YES;
if(device.proximityMonitoringEnabled == YES) {
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(proximityStatusChange:) name:@"UIDeviceProximityStateDidChangeNotification" object:device];
}
else{
NSLog(@"No proximity sensors on your device");
}
As you can see we add the current object (addObeserver:self) as an observer of the UIDeviceProximityStateDidChangeNotification and we specify that the notification center have to call the method proximityStatusChange.
Now the call back’s implementation:
- (void)proximityStatusChange:(NSNotification *) notification {
UIDevice *device = [notification object];
NSLog(@"Proximity: %i", device.proximityState);
}
This approach is very useful when multiple objects want to be informed about the change.
Change the terminal’s default text editor
In OsX a lot of terminal command using the default text editor.
Examples of these commands are git commit or svn propset svn:ignore, when you type this command Emacs is opened to let you type some text.
But since I’m not a big fan of Emacs and let me say we are in year 2009 I’d like to open an editor such as TextMate.
The solution is very simple: open the /etc/profile file ad add the following line
export EDITOR=’mate -w’
save (attention to make this operation you need administrator privileges) and close.
By doing this you tell bash that the default text editor is the command mate. Pay attention to -w flag that tell to wait the closure of TextMate before continuing.
If you’re TextWrangler’s fan you can get the same result with
export EDITOR=’edit -w’
