Friday, October 29, 2010

Remote virtual host testing without a DNS server

Assume 184.1.1.1 is the IP of your server.
Assume mywebsite.com is one of the domains your hosting on your server.

----------------------
- On Local Machine
----------------------
#sudo vi /etc/hosts
Add this to the bottom

184.1.1.1 mywebsite.testing


----------------------
- On Server
----------------------
#vi /etc/hosts
Add this to the bottom

184.1.1.1 mywebsite.com mywebsite.testing


#vi /etc/httpd/conf.d/vhosts.conf
Add this virtual host entry

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/vhosts/mywebsite.com/httpdocs
ServerName mywebsite.com
ServerAlias www.mywebsite.com mywebsite.testing

<Directory "/var/www/vhosts/mywebsite.com/httpdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


#service httpd restart



You should now be able to put mywebsite.testing in your browser and be
directed to the appropriate vhost.

Friday, August 13, 2010

How to migrate your AIR certificate (Air 2.0)

1] Determine your application's current publisher ID. In an installed application, this is found in the package's META-INF/AIR/publisherid file.

2] Open your application's descriptor file, e.g. My-App.xml and add in:
<publisherID>mypublisheridstringfoundinabovefile</publisherID>

3] Export a release build with your new certificate

4] Run this command to tell adt you are migrating from a old certificate:
#/Applications/Adobe\ Flash\ Builder\ 4/sdks/4.1.0/bin/adt -migrate -storetype pkcs12 -keystore ./src/MYOLDCERT.p12 -storepass MYCERTPASS -keypass MYCERTPASS my-app-v2.air my-app-v2-migrated.air

Point your application's updater to my-app-v2-migrated.air and it should update fine

Tuesday, August 3, 2010

TLF Bugs

I recently ran into a couple hard to diagnose TLF bugs, this might help save someone else a couple days of debugging time..

1] Redraw bug when using Linked Containers
http://forums.adobe.com/message/2782649#2782649

2] Embedded fonts break if your program uses spark text containers
http://marcel-panse.blogspot.com/2010/03/embedded-fonts-in-tlf-and-swfcontexts.html

Thursday, July 29, 2010

Speed up Flash Builder 4 compile times

1] If your project has multiple application targets, everytime the project rebuilds it rebuilds every application in your project. So if you have 4 targets, things can get slow fast. To remedy this, right click your project, click Properties, goto Flex Applications, and remove the applications your not currently running. Set the remaining application as default.

2] If your project has many files, when the project rebuilds it will copy them into the bin-debug folder which could take a long time, Right click your project, click Properties, click Flex Compiler, uncheck Copy non-embedded files to output folder. You will have to copy files to the bin-debug folder manually if any assets are required.

Saturday, October 24, 2009

Pagination pagelinks PHP algorithm

If you are making a pagination with adjacent links and are trying to figure out how to find out which number the links should start at, the algorithm below should help.

Case 1
Not enough pages, just show them all..
if (totalPages < adjacent*2)
[1]-2-3-4

Case 2
Almost at start, just start showing from beginning
true when currentPage - adjacent < 1
1-[2]-3-4-5-6 ..
starti = 1

Case 3
Almost reached the end, start showing till reached end
true when currentPage + adjacent > totalPages-1
.. 6-7-8-9-[10]-11
starti = currentPage-adjacent*2+(totalPages-currentPage)

Case 4
Not close to end or start, show even number of adjacent links on each side
true when none of above cases match
.. 2-3-[4]-5-6 ..
starti = currentPage-adjacent;


if ($this->totalPages <= $this->adjacent*2) {
$starti = 1;
$endi = $this->totalPages;
}
else if ($this->currentPage - $this->adjacent < 1) {
$starti = 1;
$endi = $this->adjacent*2;
}
else if ($this->currentPage + $this->adjacent > $this->totalPages-1) {
$starti = $this->currentPage - $this->adjacent*2 + ($this->totalPages-$this->currentPage);
$endi = $this->totalPages;
}
else {
$starti = $this->currentPage - $this->adjacent;
$endi = $this->currentPage + $this->adjacent;
}

Wednesday, October 21, 2009

Flash Builder Beta 2

Adobe... who's stupid idea was it to force users to "upgrade" to Beta 2?

If you've been getting this error trying to load a style SWF:
VerifyError: Error #1014: Class mx.modules::ModuleBase could not be found.

at flash.display::MovieClip/nextFrame()
at mx.core::FlexModuleFactory/deferredNextFrame()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\core\FlexModuleFactory.as:574]
at mx.core::FlexModuleFactory/update()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\core\FlexModuleFactory.as:402]
at mx.core::FlexModuleFactory/moduleCompleteHandler()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\core\FlexModuleFactory.as:652]

1] right click the project that contains the CSS file your compiling
2] goto Flex Build Path
3] Change framework linkage to merged
4] Click on the Flex 4.0.0 build path and Remove it
5] Click Add Flex SDK to readd it
6] Click ok to exit and re-clean your project

Hopefully this will fix your compiler bug.

Wednesday, October 14, 2009

Making a whos online script with Zend_Session_SaveHandler_DbTable

1] fetch rows from zend_session table where modifiedtime > time()-900
2] unserialize the data column using this function

function DecodeSession($sess_string)
{
// save current session data
// and flush $_SESSION array
$old = $_SESSION;
$_SESSION = array();

// try to decode passed string
$ret = session_decode($sess_string);
if (!$ret) {
// if passed string is not session data,
// retrieve saved (old) session data
// and return false
$_SESSION = array();
$_SESSION = $old;

return false;
}

// save decoded session data to sess_array
// and flush $_SESSION array
$sess_array = $_SESSION;
$_SESSION = array();

// restore old session data
$_SESSION = $old;

// return decoded session data
return $sess_array;
}

3] print out the username which should be stored in the session data, it'll look
something like
echo $session['data']['Namespace']['user']['username'];