Preston Parris

Enabling short open tags in PHP with .htaccess

If you for some reason take on a project where short open tags in php are turned on and want to insure that when you put it up on your server or wherever it still works without doing a find and replace, simply put this in your .htaccess file

php_flag short_open_tag on

removing .svn files from a directory on mac osx

find . -name .svn -print0 | xargs -0 rm -rf

Listing the properties of an object in as3

import flash.utils.describeType;

var obj:Object = new Object();
obj.param1 = "param1";
obj.param2 = false;

for (var i:* in obj) trace(i+" :: "+obj[i]);
trace("---------");
var description:XML = describeType(obj);
trace(description);

Cloning loader object in as3

So I couldn’t find this anywhere yesterday, Chris @mode hooked it up and introduced this solution:

var bmpd:BitmapData = new BitmapData(mcwidth, mcheight, true, null);
bmpd.draw(loaderObject);
var _img = new Bitmap(bmpd);
addChild(_img)

Keeping Text Format of Dynamic Text Field in as3

So I just ran into this today and thought I would share. So here is the scenerio, you get an .fla with all of these text fields that have different letter-spacing and text formatting etc.. You are then responsible for making these text fields dynamic so you set movieclip.text = “your text”. Then you realize once you run this that it seems to overwrite your text formatting. In order to save the formatting without having to recreate it in actionscript, simply do this.

var format:TextFormat = movieclip.getTextFormat();
movieclip.text = "set your text now";
movieclip.setTextFormat(format);

MLOG Launched!

We just launched our MLOG at MODE. Check it out.

This is is my first entry into the MLOG:

Let me kick things off by introducing myself, the name is Preston Parris aka “Magik”. I began as an intern here at MODE. yet that quickly transformed into a full-time gig as an Interactive Developer. That’s the official title at least, but like everyone else here, I wear many hats. An average day might consist of doing some front-end development, Actionscript/Flash programming, working on an iPhone App, or PHP coding. It has been one long enthralling roller coaster ride ever since I began a little over a half year ago. The amount of information and experience I have gained has been incredible. Every day I am challenged to learn and progress. Although it has taken a ton of hard work, I wouldn’t be anywhere close to where I am today without the help and support of the team here at MODE.

The unspoken motto here I believe is “Work Hard, Play Hard”. Although everyone works incredibly hard, we also have a blast throughout the day. It’s actually fairly difficult to explain without experiencing. Whether we are having a “Gang War” in the office, or hosting a “MODE. Challenge”, you can expect the unexpected. For example, when the studio found out I was an ex sushi chef, they set up a “Sushi Roll-off” between me and Kelly the “Cow Boy” sushi chef (see photo). To put it mildly, we have a lot of fun. [See Event Poster]

I look forward to creating new content for this mlog. Hopefully, if not just a laugh, we hope to connect with the community around us. Look out for future video content, including iPhone app reviews by myself.

-Preston


Multidimensional US States and Countries Array for ActionScript

Hopefully this will help someone out, I couldn’t find this anywhere.

Countries:

var countries = new Array(
{data:null, label:”Select Country”},
{data:”US”, label:”United States”},
{data:”AF”, label:”Afghanistan”},
{data:”AL”, label:”Albania”},
{data:”DZ”, label:”Algeria”},
{data:”AS”, label:”American Samoa”},
{data:”AD”, label:”Andorra”},
{data:”AO”, label:”Angola”},
{data:”AI”, label:”Anguilla”},
{data:”AQ”, label:”Antarctica”},
{data:”AG”, label:”Antigua and Barbuda”},
{data:”AR”, label:”Argentina”},
{data:”AM”, label:”Armenia”},
{data:”AW”, label:”Aruba”},
{data:”AU”, label:”Australia”},
{data:”AT”, label:”Austria”},
{data:”AZ”, label:”Azerbaijan”},
{data:”BS”, label:”Bahamas”},
{data:”BH”, label:”Bahrain”},
{data:”BD”, label:”Bangladesh”},
{data:”BB”, label:”Barbados”},
{data:”BY”, label:”Belarus”},
{data:”BE”, label:”Belgium”},
{data:”BZ”, label:”Belize”},
{data:”BJ”, label:”Benin”},
{data:”BM”, label:”Bermuda”},
{data:”BT”, label:”Bhutan”},
{data:”BO”, label:”Bolivia”},
{data:”BA”, label:”Bosnia and Herzegovina”},
{data:”BW”, label:”Botswana”},
{data:”BV”, label:”Bouve”},
{data:”BR”, label:”Brazil”},
{data:”IO”, label:”British Indian Ocean Territory”},
{data:”BN”, label:”Brunei Darussalam”},
{data:”BG”, label:”Bulgaria”},
{data:”BF”, label:”Burkina Faso”},
{data:”BI”, label:”Burundi”},
{data:”KH”, label:”Cambodia”},
{data:”CM”, label:”Cameroon”},
{data:”CA”, label:”Canada”},
{data:”CV”, label:”Cape Verde”},
{data:”KY”, label:”Cayman Islands”},
{data:”CF”, label:”Central African Republic”},
{data:”TD”, label:”Chad”},
{data:”CL”, label:”Chile”},
{data:”CN”, label:”China”},
{data:”CX”, label:”Christmas Island”},
{data:”CC”, label:”Cocos (Keeling) Islands”},
{data:”CO”, label:”Colombia”},
{data:”KM”, label:”Comoros”},
{data:”CG”, label:”Congo”},
{data:”CD”, label:”Congo, Democratic Republic”},
{data:”CK”, label:”Cook Islands”},
{data:”CR”, label:”Costa Rica”},
{data:”CI”, label:”Cote D’Ivoire”},
{data:”HR”, label:”Croatia”},
{data:”CU”, label:”Cuba”},
{data:”CY”, label:”Cyprus”},
{data:”CZ”, label:”Czech Republic”},
{data:”DK”, label:”Denmark”},
{data:”DJ”, label:”Djibouti”},
{data:”DM”, label:”Dominica”},
{data:”DO”, label:”Dominican Republic”},
{data:”EC”, label:”Ecuador”},
{data:”EG”, label:”Egypt”},
{data:”SV”, label:”El Salvador”},
{data:”GQ”, label:”Equatorial Guinea”},
{data:”ER”, label:”Eritrea”},
{data:”EE”, label:”Estonia”},
{data:”ET”, label:”Ethiopia”},
{data:”FK”, label:”Falkland Islands (Malvinas)”},
{data:”FO”, label:”Faroe Islands”},
{data:”FJ”, label:”Fiji”},
{data:”FI”, label:”Finland”},
{data:”FR”, label:”France”},
{data:”GF”, label:”French Guiana”},
{data:”PF”, label:”French Polynesia”},
{data:”TF”, label:”French Southern Territories”},
{data:”GA”, label:”Gabon”},
{data:”GM”, label:”Gambia”},
{data:”GE”, label:”Georgia”},
{data:”DE”, label:”Germany”},
{data:”GH”, label:”Ghana”},
{data:”GI”, label:”Gibraltar”},
{data:”GR”, label:”Greece”},
{data:”GL”, label:”Greenland”},
{data:”GD”, label:”Grenada”},
{data:”GP”, label:”Guadeloupe”},
{data:”GU”, label:”Guam”},
{data:”GT”, label:”Guatemala”},
{data:”GN”, label:”Guinea”},
{data:”GW”, label:”Guinea-Bissau”},
{data:”GY”, label:”Guyana”},
{data:”HT”, label:”Haiti”},
{data:”HM”, label:”Heard Island and Mcdonald Islands”},
{data:”VA”, label:”Holy See (Vatican City State)”},
{data:”HN”, label:”Honduras”},
{data:”HK”, label:”Hong Kong”},
{data:”HU”, label:”Hungary”},
{data:”IS”, label:”Iceland”},
{data:”IN”, label:”India”},
{data:”ID”, label:”Indonesia”},
{data:”IR”, label:”Iran, Islamic Republic of”},
{data:”IQ”, label:”Iraq”},
{data:”IE”, label:”Ireland”},
{data:”IL”, label:”Israel”},
{data:”IT”, label:”Italy”},
{data:”JM”, label:”Jamaica”},
{data:”JP”, label:”Japan”},
{data:”JO”, label:”Jordan”},
{data:”KZ”, label:”Kazakhstan”},
{data:”KE”, label:”Kenya”},
{data:”KI”, label:”Kiribati”},
{data:”KP”, label:”Korea, Democratic People’s Republic”},
{data:”KR”, label:”Korea, Republic of”},
{data:”KW”, label:”Kuwait”},
{data:”KG”, label:”Kyrgyzstan”},
{data:”LA”, label:”Lao People’s Democratic Republic”},
{data:”LV”, label:”Latvia”},
{data:”LB”, label:”Lebanon”},
{data:”LS”, label:”Lesotho”},
{data:”LR”, label:”Liberia”},
{data:”LY”, label:”Libyan Arab Jamahiriya”},
{data:”LI”, label:”Liechtenstein”},
{data:”LT”, label:”Lithuania”},
{data:”LU”, label:”Luxembourg”},
{data:”MO”, label:”Macao”},
{data:”MK”, label:”Macedonia, Former Yugoslav Republic”},
{data:”MG”, label:”Madagascar”},
{data:”MW”, label:”Malawi”},
{data:”MY”, label:”Malaysia”},
{data:”MV”, label:”Maldives”},
{data:”ML”, label:”Mali”},
{data:”MT”, label:”Malta”},
{data:”MH”, label:”Marshall Islands”},
{data:”MQ”, label:”Martinique”},
{data:”MR”, label:”Mauritania”},
{data:”MU”, label:”Mauritius”},
{data:”YT”, label:”Mayotte”},
{data:”MX”, label:”Mexico”},
{data:”FM”, label:”Micronesia, Federated States of”},
{data:”MD”, label:”Moldova, Republic of”},
{data:”MC”, label:”Monaco”},
{data:”MN”, label:”Mongolia”},
{data:”MS”, label:”Montserrat”},
{data:”MA”, label:”Morocco”},
{data:”MZ”, label:”Mozambique”},
{data:”MM”, label:”Myanmar”},
{data:”NA”, label:”Namibia”},
{data:”NR”, label:”Nauru”},
{data:”NP”, label:”Nepal”},
{data:”NL”, label:”Netherlands”},
{data:”AN”, label:”Netherlands Antilles”},
{data:”NC”, label:”New Caledonia”},
{data:”NZ”, label:”New Zealand”},
{data:”NI”, label:”Nicaragua”},
{data:”NE”, label:”Niger”},
{data:”NG”, label:”Nigeria”},
{data:”NU”, label:”Niue”},
{data:”NF”, label:”Norfolk Island”},
{data:”MP”, label:”Northern Mariana Islands”},
{data:”NO”, label:”Norway”},
{data:”OM”, label:”Oman”},
{data:”PK”, label:”Pakistan”},
{data:”PW”, label:”Palau”},
{data:”PS”, label:”Palestinian Territory, Occupied”},
{data:”PA”, label:”Panama”},
{data:”PG”, label:”Papua New Guinea”},
{data:”PY”, label:”Paraguay”},
{data:”PE”, label:”Peru”},
{data:”PH”, label:”Philippines”},
{data:”PN”, label:”Pitcairn”},
{data:”PL”, label:”Poland”},
{data:”PT”, label:”Portugal”},
{data:”PR”, label:”Puerto Rico”},
{data:”QA”, label:”Qatar”},
{data:”RE”, label:”Reunion”},
{data:”RO”, label:”Romania”},
{data:”RU”, label:”Russian Federation”},
{data:”RW”, label:”Rwanda”},
{data:”SH”, label:”Saint Helena”},
{data:”KN”, label:”Saint Kitts and Nevis”},
{data:”LC”, label:”Saint Lucia”},
{data:”PM”, label:”Saint Pierre and Miquelon”},
{data:”VC”, label:”Saint Vincent and the Grenadines”},
{data:”WS”, label:”Samoa”},
{data:”SM”, label:”San Marino”},
{data:”ST”, label:”Sao Tome and Principe”},
{data:”SA”, label:”Saudi Arabia”},
{data:”SN”, label:”Senegal”},
{data:”CS”, label:”Serbia and Montenegro”},
{data:”SC”, label:”Seychelles”},
{data:”SL”, label:”Sierra Leone”},
{data:”SG”, label:”Singapore”},
{data:”SK”, label:”Slovakia”},
{data:”SI”, label:”Slovenia”},
{data:”SB”, label:”Solomon Islands”},
{data:”SO”, label:”Somalia”},
{data:”ZA”, label:”South Africa”},
{data:”GS”, label:”S. Georgia, S. Sandwich Islands”},
{data:”ES”, label:”Spain”},
{data:”LK”, label:”Sri Lanka”},
{data:”SD”, label:”Sudan”},
{data:”SR”, label:”Suriname”},
{data:”SJ”, label:”Svalbard and Jan Mayen”},
{data:”SZ”, label:”Swaziland”},
{data:”SE”, label:”Sweden”},
{data:”CH”, label:”Switzerland”},
{data:”SY”, label:”Syrian Arab Republic”},
{data:”TW”, label:”Taiwan, Province of China”},
{data:”TJ”, label:”Tajikistan”},
{data:”TZ”, label:”Tanzania, United Republic of”},
{data:”TH”, label:”Thailand”},
{data:”TL”, label:”Timor-Leste”},
{data:”TG”, label:”Togo”},
{data:”TK”, label:”Tokelau”},
{data:”TO”, label:”Tonga”},
{data:”TT”, label:”Trinidad and Tobago”},
{data:”TN”, label:”Tunisia”},
{data:”TR”, label:”Turkey”},
{data:”TM”, label:”Turkmenistan”},
{data:”TC”, label:”Turks and Caicos Islands”},
{data:”TV”, label:”Tuvalu”},
{data:”UG”, label:”Uganda”},
{data:”UA”, label:”Ukraine”},
{data:”AE”, label:”United Arab Emirates”},
{data:”GB”, label:”United Kingdom”},
{data:”UM”, label:”United States Minor Outlying Islands”},
{data:”UY”, label:”Uruguay”},
{data:”UZ”, label:”Uzbekistan”},
{data:”VU”, label:”Vanuatu”},
{data:”VE”, label:”Venezuela”},
{data:”VN”, label:”Viet Nam”},
{data:”VG”, label:”Virgin Islands, British”},
{data:”VI”, label:”Virgin Islands, U.s.”},
{data:”WF”, label:”Wallis and Futuna”},
{data:”EH”, label:”Western Sahara”},
{data:”YE”, label:”Yemen”},
{data:”ZM”, label:”Zambia”},
{data:”ZW”, label:”Zimbabwe”}
);

States:

var stateData = new Array ({data:”None”, label:”please select…”}, {data:”AK”, label:”Alaska”}, {data:”AL”, label:”Alabama”}, {data:”AR”, label:”Arkansas”}, {data:”AZ”, label:”Arizona”}, {data:”CA”, label:”California”}, {data:”CO”, label:”Colorado”}, {data:”CT”, label:”Connecticut”}, {data:”DE”, label:”Delaware”}, {data:”DC”, label:”District of Columbia”}, {data:”FL”, label:”Florida”}, {data:”GA”, label:”Georgia”}, {data:”HI”, label:”Hawaii”}, {data:”IA”, label:”Iowa”}, {data:”ID”, label:”Idaho”}, {data:”IL”, label:”Illinois”}, {data:”IN”, label:”Indiana”}, {data:”KS”, label:”Kansas”}, {data:”KY”, label:”Kentucky”}, {data:”LA”, label:”Louisiana”}, {data:”MA”, label:”Massachusetts”}, {data:”MD”, label:”Maryland”}, {data:”ME”, label:”Maine”}, {data:”MI”, label:”Michigan”}, {data:”MN”, label:”Minnesota”}, {data:”MS”, label:”Mississippi”}, {data:”MO”, label:”Missouri”}, {data:”MT”, label:”Montana”}, {data:”NC”, label:”North Carolina”}, {data:”ND”, label:”North Dakota”}, {data:”NE”, label:”Nebraska”}, {data:”NH”, label:”New Hampshire”}, {data:”NJ”, label:”New Jersey”}, {data:”NM”, label:”New Mexico”}, {data:”NV”, label:”Nevada”}, {data:”NY”, label:”New York”}, {data:”OH”, label:”Ohio”}, {data:”OK”, label:”Oklahoma”}, {data:”OR”, label:”Oregon”}, {data:”PA”, label:”Pennsylvania”}, {data:”RI”, label:”Rhode Island”}, {data:”SC”, label:”South Carolina”}, {data:”SD”, label:”South Dakota”}, {data:”TN”, label:”Tennessee”}, {data:”TX”, label:”Texas”}, {data:”UT”, label:”Utah”}, {data:”VA”, label:”Virginia”}, {data:”VT”, label:”Vermont”}, {data:”WA”, label:”Washington”}, {data:”WI”, label:”Wisconsin”}, {data:”WV”, label:”West Virginia”}, {data:”WY”, label:”Wyoming”}, {data:”other”, label:”other”});


Wordpress root Install with .htaccess Password Protected directories

I have been incredibly busy lately, I have many iphone dev tutorials and Flash tutorials I need to write, this one is a quickie though so I thought I would share.

If you have wordpress installed in your root directory of your domain, and you would like to password protect a directory lets say at root/directory, wordpress prevents this because wordpress is trying to turn what needs to be a 401 header into a 404 header, therefore messing up your password protection. In order to fix this , simply add one of the following to your .htaccess file in either the root, or the directory you are password protecting.

Apaches default file:

ErrorDocument 401 default

Your own custom hard coded error:

ErrorDocument 401 "Unauthorized access"

Or you can create your own  401 document :

ErrorDocument 401 /401.html

If you decide to create your own 401, make sure it is where you specify, otherwise you will continue to have the same issue.


Installing Iphone SDK on PowerPC MAC

So at work my computer is a G4 PowerPC Mac Pro 1.8GHz with 3 GB of RAM.  It’s a great comp, but it’s lacking one thing,  an intel processor! you guessed it. So this one thing appeared to be a problem when I was trying to install the iphone SDK. If you have found this post then you obviously are having the same problem, so let’s get to the solution!

First off if you don’t already have the iphone SDK , your going to need an apple ID ( it’s free) and you need to head on over to developer.apple.com. You will see a link to the SDK at the top left, it is 1.41 GB so depending on how fast your internet connection is it might take a bit of time.

After you have completed the download, click on the installer and let the installation process do it’s thing. Click close when it has finished.

Now if you open up xcode you will notice that there is nothing for the iphone, what happened you ask? Well since it is not made to install on this processor it didn’t install all of the packages needed.

Now the fun begins…First open back up the mounted iphone SDK. This time click on the packages folder. 

Go ahead and install the top 5 packages individually. All of the packages beginning with Aspen at the top.

*note*

you may have a version of the SDK that doesn’t use Aspen as the Name of the packages so the packages you need to install are the following

iPhoneDocumentation
iPhoneHostSideTools
iPhoneSDKHeadersAndLibs
iPhoneSimulatorPlatform
iPhoneSystemComponents

you will now replace the word Aspen in your head with iphone whenever I refer to it anymore, haha.

* end note* 

Alright now go to your default install directory ( more than likely your main HD ) and you should now see a folder Called Platforms.

You want to copy those two folders AspenSimulator.platform and Aspen.platform to your Developer/Platforms folder on your main HD. 

Ok so now your almost there, if you start xcode you will now see the iphone related stuff and be able to run the simulator, yet if you try to compile any code you will get an error talking about ‘no architectures to compile for (ARCHS=ppc,VALID_ARCHS=i386). Yeah you don’t want that so don’t bother running xcode yet.

So lets push on by going to :

 /Developer/Platforms/AspenSimulator.platform/Developer/Library/Xcode/Specifications/

You will find a file called “Aspen Simulator Architectures.xcspec”, copy this file to your desktop or somewhere as a backup.

Now open this file with your preferred text editor ( I would suggest TextMate, it’s awesome), Replace the contents of it with this. Save that now.

Now if you boot up Xcode you should be good to go. No warnings, No errors. You will see the iphone development stuff. 

I’m not completely confident that your apps will run on the actual iphone, I have heard some mixed responses about this. I will be beginning to develop some apps so whenever I run into problems I will update this post. 

Nevertheless you have now bypassed the system and this can at least get you started coding. 


Running Ruby on Rails in Ubuntu in 30 mins

So you want to install ruby on rails in Ubuntu linux huh? Well it’s really not as difficult as it seems. Follow this guide and you will be up and running in about 30 minutes, maybe less.

The lovely people at fiveruns have released an all in one package that includes the following:

  • Ruby 1.8.6
  • Rails 1.2.3
  • MySQL 5.0
  • SQLite 3.3
  • Subversion 1.4
  • Apache HTTP Server 2.2 (Production mode)
  • OpenSSL
  • ImageMagick 6.3
  • Mongrel/Mongrel Cluster
  • Capistrano
  • Gruff
  • Rake
  • RMagic

Now wasn’t that nice of them?

Open your terminal and type the following:

wget http://www.fiveruns.com/downloads/rminstall-1.0.1-linux.bin

(if this doesn’t work check for the newer version here making sure to get the linux version)

Now type this in:

chmod 755 rminstall-1.0.1-linux.bin

Next type in this:

sudo ./rminstall-1.0.1-linux.bin

Now the installer should pop up and just keep hitting yes until it asks for a developer or server install and you want to check server install. Continue hitting continue until it asks for the directory to install too and choose the /opt directory so that it installs to /opt/rminstall/ . Keep hitting continue until it begins to actually install. The installation should take roughly 10 minutes, go grab a bite to eat or maybe check out www.mindsetgear.com and buy a shirt, then click finish to complete the installation.

Wow, that wasn’t so bad now was it? Ok now we must open terminal again and type in the following:

sudo vi /etc/profile

Now at the top add the following three lines:

if [ -f /opt/rminstall/scripts/setenv.sh ]; then
. /opt/rminstall/scripts/setenv.sh
fi

Now you may be wondering if that fi is correct and yes it is. You may also be wondering how to save and you do this by going to the bottom of the document and typing:

:wq

Now just simply log out and log back in. You can now use the rails, ruby, mysql, rake etc. commands. Now give yourself a pat on the back, you did it! It’s time to start programming.




?>?>