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'];

Saturday, October 3, 2009

osx leopard install apache mysql memcache php memcache

1] install ports (similar to fedora's yum)
http://www.macports.org/

Memcached


2] #sudo port install memcached libmemcached

PHP


3] #sudo port install php5-memcache
4] #sudo port install php5-mysql
5] #vi /opt/local/etc/php5/php.ini
make sure socket location is /tmp/mysql.sock

Apache


6] #cd /opt/local/apache2/modules
#sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
[activating module 'php5' in /opt/local/apache2/conf/httpd.conf]
7] #vi /opt/local/apache2/conf/httpd.conf
add these lines:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

find line: DirectoryIndex and append index.php to line

8] #vi ~/.profile
Add this line:
alias httpdstart='sudo /opt/local/apache2/bin/apachectl start'
alias httpdstop='sudo /opt/local/apache2/bin/apachectl stop'

8b] autostart
#sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist

9] #source ~/.profile
10] apachectl start

11] check your http://localhost

MYSQL


12] #sudo port install mysql5-server

follow directions to setup new database
if server is not starting move /etc/my.cnf to /etc/my.cnf.old
13] autostart mysql
#sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
14] edit /etc/my.cnf change socket location to /tmp/mysql.sock

PHPMyadmin


15] #sudo port install phpmyadmin
Update Apache’s httpd.conf file to find phpmyadmin. First add the following lines to the end of the file:

# Local access to phpmyadmin installation
Include conf/extra/httpd-phpmyadmin.conf

and then create a file /opt/local/apache2/conf/extra/httpd-phpmyadmin.conf containing this text:

AliasMatch ^/phpmyadmin(?:/)?(/.*)?$ "/opt/local/www/phpmyadmin$1"


Options -Indexes
AllowOverride None
Order allow,deny
Allow from all

LanguagePriority en de es fr ja ko pt-br ru
ForceLanguagePriority Prefer Fallback






other:
http://trac.macports.org/wiki/howto/MAMP
http://2tbsp.com/content/install_apache_2_and_php_5_macports

Friday, October 2, 2009

OSX make iso shell script

Makes a ISO file while removing .DS_Store files

#!/bin/sh
#echo $1 $2
find "$2" -name .DS_Store -exec rm -rf {} \;
hdiutil makehybrid -o "$1" "$2"

Monday, September 28, 2009

FIOS reboot ONT

I was having trouble with my FIOS ON DEMAND being choppy pixelated and my FIOS internet dropping the connection frequently. Several calls to Verizon support yielded absolutely nothing (TERRIBLE).

I hard reloaded the router, changed the cables, and splitters. NOTHING.

After looking around on the internet to see what else could cause this, I found out it could be the ONT which tech support never even mentions, not to mention the fact that they wouldn't even send a technician out to come check it. Turns out a cold reboot (removing power to the ONT while temporarily disabling battery power) was the cure to both problems.

Follow this guide if you want to give it a try:
•Disconnect the AC from the Power Supply Unit (PSU).
•Remove one lead from the battery in the Battery Backup Unit (BBU).
•Wait one minute.
•Reconnect the battery lead.
•Reconnect AC to the PSU.
taken from: http://www.dslreports.com/faq/16357

The top cover can be opened on the left side. The battery lead looks similar to a PSU's 4 pin connectors, it's on the left of the battery connected to the red wire.

Hope this information helps you, but do anything at your own risk, I take no responsibility for this information.