Thursday, November 17, 2011

Safari Debug Menu: Changing User Agent, Debugging JavaScript

I usually don't use Safari, but here's a great item to note if you need to use it. You can enable development tools through a preference setting. Simply open up a terminal window and execute the following:
defaults write com.apple.safari IncludeDebugMenu 1
This will enable a new menu in Safari containing controls to change the user agent, disable various functions like javascript or caching, and/or start javascript debugging.

Tuesday, October 04, 2011

XAMPP Apache Could Not Bind to Port 80

Recently, I had an issue starting up Apache. My Apache instance runs on a Windows 7 development box and also shares the box with IIS 7. Immediately I thought that it was IIS and of course that's a valid assumptions but binding IIS to port 81 did not solve the issue.

I received the following error while trying to start Apache:
D:\xampp>apache_start.bat
Diese Eingabeforderung nicht waehrend des Running beenden
Bitte erst bei einem gewollten Shutdown schliessen
Please close this command only for Shutdown
Apache 2 is starting ...
(OS 10013)An attempt was made to access a socket in a way forbidden by its access permissions. : make_sock: could not bind to address [::]:80
(OS 10013)An attempt was made to access a socket in a way forbidden by its access permissions. : make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

Apache konnte nicht gestartet werden
Apache could not be started
Press any key to continue . . .
D:\xampp>

Running a netstat I could see that something called SYSTEM was listening on port 80.
D:\canvas\xampp>netstat -aon | findstr :80
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4

It turns out that another service called SQL Server Reporting Services (SQLEXPRESS) was causing the conflict. Stopping the service through Component Services > Services allows you to start Apache on port 80.

*EDIT
On another machine at work a service called "Web Deployment Agent Service", part of Microsoft's WebMatrix, was also preventing Apache from binding to port 80.

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.