error: Unsupported Feature: to-many relationship … option requires Mac OS X 10.7 or later

While tinkering with the relationship properties in my Core Data model, my app suddenly failed to compile with this error:

error: Unsupported Feature: to-many relationship [Entity].[attribute]
option requires Mac OS X 10.7 or later

While it says to-many relationship is not supported, I know that’s not the real problem as I have been compiling fine with the ‘to-many‘ option turned on for a few weeks. What it’s really trying to tell you is an ‘ordered‘ AND ‘to-many‘ relationship is not supported. Once I unchecked the ‘ordered‘ option the app build fine again.

Recovering lost animation on referenced characterSets in Maya 2011

A friend recently lost all of his animation on a referenced character rig. The file still opens without Maya complaining, but the keys just went missing. A quick check of the .ma in a text editor confirmed that the animCurve nodes were still present.

Feeling adventurous, I fired up notepad++ and did a text comparison of a working file containing the same referenced rig and the problematic file. Sure enough, the animCurve nodes seem to be connected to the wrong .phl (placeHolderList) of the reference file, or were not Continue reading ‘Recovering lost animation on referenced characterSets in Maya 2011′

Free Transform Manager As3 v1.3

This is an update to my earlier post announcing the launch of FTM. Source provided after the jump.

Continue reading ‘Free Transform Manager As3 v1.3′

Drupal 7 – Handling file uploads

When trying to deal with custom forms with file upload fields, you may sometimes get a error regarding extensions:

The specified file “your file name here” could not be uploaded. Only files with the following extensions are allowed: “jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp”

To allow all extensions, you have to manually set the ‘file_validate_extensions’ validator to an empty array.

e.g.
$validators = array('file_validate_extensions' => array());
$file = file_save_upload('upload', $validators);

For more information, check out Drupal API’s documentation at http://api.drupal.org/api/drupal/includes–file.inc/function/file_save_upload/7

The bare requirements for a file upload form is the “multipart/form-data” enctype, a “file” field, and the standard “submit” button. An example of a basic structure:


$form ['upload'] = array (
'#type' => 'file',
'#title' => 'Choose file',
'#description' => 'Upload a file.' );
$form ['submit'] = array ('#type' => 'submit', '#value' => t ( 'Submit' ) );
$form ['#attributes'] = array ('enctype' => "multipart/form-data" );

Raise the Red Lantern

Inspired by some minimalist posters, I attempted to create one for one of my favorite movies:

Unfortunately, its not as minimal as I would like it to be. I got distracted and started watching “To Live”, another masterpiece from the same director, Zhang Yimou.

Free Photo Stitching Software from Microsoft?

It surprises me to find out that Microsoft has been offering a free photo stitching utility for quite some time. And though its quality cannot be matched by photoshop or auto stitch, it is free, and surprisingly fast. While it takes up to 30mins to merge 8 hi res photos from my 550D (5184×3456) in photoshop, it took less than a minute in Microsoft’s Image Composite Editor. Oh, and did I mention that its free? ;)



Download the 64bit version at http://research.microsoft.com/en-us/downloads/69699e5a-5c91-4b01-898c-ef012cbb07f7/default.aspx

Checking PHP syntax

A quick way to check a .php file for syntax errors is to use the -l option of php.exe.

php -l /path/to/php/file.php

Creating nodes programmatically in Drupal (including cck and location fields)

Creating a new node in drupal is trivial, but when the node includes custom cck fields, then a few things can trip you up. To save time and energy, here’s a quick guide and some tips to make your drupal life easier.

Creating a basic node:

global $user; //get current logged in user
$new_node = new stdClass();
$new_node->type = 'YOUR_NODE_TYPE_HERE';
$new_node->uid = $user->uid; //you can specify some other userID here if you want
$new_node->name = $user->name;
$new_node->title = $YOUR_NODE_TITLE;
$new_node->body = $YOUR_NODE_BODY;
$new_node->status = 1; // published
node_save($new_node);

The function node_save() does a few things behind the scene. It checks if the nid property is empty to determine if this is a new insert or an update, then calls the appropriate functions so that you would not have duplicates. Put simply, if you want to do an update, populate the nid, and leave it out otherwise.

Creatnig a node with CCK fields involves this additional line (for each field):

$new_node->field_your_field[0]['value'] = $YOUR_FIELD_DATA;

Point to note is the [0]['value'], because CCK treats each field as multiple-value fields even if you specified otherwise in the field settings. If you see the error Fatal error: Cannot unset string offsets in …/modules/cck/content.module on line 1248, you’re probably missing the [0]['value'] and setting the value directly into $new_node->field_your_field.

To create a node with location, we need to save the location first to get a location ID before saving it along with our node:

$location = array(
'street' => $address,
'postal_code' => $postal,
);
$locationID = location_save($location);
$new_node = new stdClass();
// ... the usual stuff ...
$new_node->locations[0]['lid'] = $newLocationId;
node_save($new_node);

There you go. Another method is to manually craft an array to simulate a $_POST from a drupal form. To do that you basically have to know the form structure, populate the require fields and pass the array on to the drupal_execute() call. Refer to the example here for more details.

Drupal references:
Node_save: drupal documentation

Size mismatch when getting BitmapData from Camera

Recently while trying to capture a frame from my webcam in Adobe Air, I realize the captured image is always smaller than the height or videoHeight from the Video object. The BitmapData documentation revealed that the BitmapData.draw() operation does not respect any matrix transformation applied on the Camera or Video object, so we need to do the scaling ourselves. A quick and dirty way would be:

 

//var video:Video; and a Camera object is already attached
var matrix:Matrix = new Matrix();
matrix.scale(video.width / 320, video.height / 240);
bitmapData.draw(video,matrix,null,null,null,true);

 

 

Wireframing Kits

Just like you shouldn’t start building a project from scratch, you shouldn’t start crafting a wireframe out of a blank canvas as well. The place where you should start is here:

http://www.smashingmagazine.com/2010/02/05/50-free-ui-and-web-design-wireframing-kits-resources-and-source-files/

Great looking stencil kits for building everything from iPhone, browser, facebook, MacOS apps – even Blackberry. Preview the iPhone kit below