Saturday, September 03, 2011

Scaling Bitmaps In Flash ActionScript 3 (AS3)

I was working on composing large Bitmaps and scaling them and noticed an optimization that might have included a bug. The images I was scaling were pixel snapping and were not smoothed. This resulted in a choppy tween.

In the past avoiding choppy image animations required setting the quality to "best". Now ActionScript allows granular control of images. In my project they were embeded as external assets and pulled from a SWF file.

[Embed(source="assets/about/gfx.jpg")]

As of Flash Player version 10.3.183.5, when scaling Bitmaps in Flash smoothing and PixelSnapping are ignored when the scale is equal to 1. In order to force smooth set the Bitmap to a scale not equal to 1.0.

For example:
var bitmap:Bitmap = new Bitmap(_bitmapData, 'never', true);
bitmap.scaleX = bitmap.scaleY = .99;

Tuesday, January 18, 2011

CakePHP Bake mysql.connect Error Running XAMPP

I ran into the following error baking with CakePHP. I was trying to create the cake schema for ACL tables.


:$ ./cake schema create DbAcl

Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EST/-5.0/no DST' instead in /htdocs/cake/libs/cache.php on line 570

Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EST/-5.0/no DST' instead in /htdocs/cake/libs/cache.php on line 570


Welcome to CakePHP v1.3.6 Console
---------------------------------------------------------------
App : app
Path: /htdocs/app
---------------------------------------------------------------
Cake Schema Shell
---------------------------------------------------------------

Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 552

Warning: mysql_connect(): No such file or directory in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 552

Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 558

Warning: mysql_get_server_info() expects parameter 1 to be resource, boolean given in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 566

Warning: mysql_real_escape_string() expects parameter 2 to be resource, boolean given in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 671

Warning: mysql_real_escape_string() expects parameter 2 to be resource, boolean given in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 671

Warning: mysql_real_escape_string() expects parameter 2 to be resource, boolean given in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 671

Warning: mysql_real_escape_string() expects parameter 2 to be resource, boolean given in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 671


The issue that I didn't realize quick enough was that the CakePHP script wasn't using my XAMPP's PHP executable. Another instance of PHP was being run since it was located in my $PATH.

This can be easily corrected by correcting your $PATH with a quick visit to vi.

Tuesday, November 16, 2010

Taking screen captures of websites

Here's a great way to programmatically create screen captures of sites. It uses a python script to access WebKit and generate a PNG. It would be fairly easy to add some logic to make it crawl a site to show clients. We had to use this to grab some shots of a site for a routing phase of a pharmaceutical project.


There is also another program called Paparazzi! It provides a GUI and allows a little bit of interactivity for clicking through.

Saturday, September 25, 2010

Reformatting XML with TextWrangler Script

Here's a great tip for reformatting XML. I'm reposting this. I use TextWrangler and use the UNIX Script.

Use Unix Filters and create the following script to use, Reformat XML.sh:

#!/bin/sh
xmllint --c14n "$*" | XMLLINT_INDENT=$'\t' xmllint --format -

Thanks Magpie.


Thursday, September 02, 2010

Fixing Font Rendering Issues in Google Chrome for Mac OSX

While I'm writing this the Google Chrome browser is still a beta. But I still want to use it.

So the problem is that I open up Chrome and it runs into a font issue when I'm using fonts installed with my font management software (i.e. - Linotype FontExplorer X, FontAgent Pro, etc...).

I see the following characters:


The problem is that Chrome for Mac OSX is looking for font files at the following location:

/Library/Fonts/

Where these font management software programs install fonts to a different location. To remedy the problem simply change your font folder and Chrome should read the fonts fine.


On FontExplorer X 1.2.3, you can simply open up Preferences and go to the Advanced tab. Here you can change the location of font files. Yeah I run it because it's free.

Font Book which is provided by Apple on Leopard and up, seems to install for use with Chrome with out any issues. But then again, Font Book isn't exactly the best solution for font management when you have six thousand fonts.