Wednesday, July 17, 2013

OSX Shuttle app running Apple Script

Here is a quick script to re-index the mail.app using the shuttle.app

- http://fitztrev.github.io/shuttle/

Save this as speedmail.command.line.scpt

    (*
    Speed up Mail.app by vacuuming the Envelope Index
    Code from: http://www.hawkwings.net/2007/03/03/scripts-to-automate-the-mailapp-envelope-speed-trick/
    Originally by "pmbuko" with modifications by Romulo
    Updated by Brett Terpstra 2012 
    *)

    tell application "Mail" to quit
    set sizeBefore to do shell script "ls -lah ~/Library/Mail/V2/MailData | grep -E 'Envelope Index$' | awk {'print $5'}"
    do shell script "/usr/bin/sqlite3 ~/Library/Mail/V2/MailData/Envelope\\ Index vacuum"
    set sizeAfter to do shell script "ls -lah ~/Library/Mail/V2/MailData | grep -E 'Envelope Index$' | awk {'print $5'}"
    tell application "Terminal" to display dialog "Mail index before: " & sizeBefore & return & "Mail index after: " & sizeAfter & return & return & "Enjoy the new speed!"
    tell application "Mail" to activate

open up the shuttle.app and add this to the config ( note: you will need the path to where you save the speedmail.command.line.scpt file )

    {
    "Apple Scripts": [
            {
                "name": "Speed Mail.app by Indexing",
                "cmd": "osascript ~/speedmail.command.line.scpt"
            }
        ]
    }

Happy Hacking

Tuesday, September 11, 2012

Eclipse IDE for Symfony2 developers

After looking for a good Symfony 2 IDE I found Eclipse to offer a good solution for what I needed. I did see this post on how to setup Eclipse for Symfony 2 but it's a little out dated. Post #1 First download the Zend Eclipse IDE for your OS Flavor, Me I'm running Ubuntu 12.04 LTS 64BIT. Zend Eclipse IDE - Community Edition ( Yeah it's FREE ) Now the Paid version of Zend IDE you can download all the plugins from this list Zend Eclipse IDE Plugins List But I found you can also install then yourself in the Community Edition. Now I haven't been able to find them all but if you see one on the list that I don't provide a update site link to, Please comment and I will add it. Here are the plugins I use: Here are some others I have found but have not installed it's still a work in progress, let me know what works for you

Saturday, November 05, 2011

Name Virtual Host

Edit httpd.conf

sudo vi /etc/apache2/httpd.conf
Add this line

NameVirtualHost *:80
NOTE: You can replace *:80 with your_ip_address:80

Now create the domain name config file. I use the domain_name.com

sudo vi /etc/apache2/sites-available/domain.com
Add this to the file


ServerAdmin admin@domain.com
ServerName www.domain.com
ServerAlias domain.com
DocumentRoot /var/www/domain.com/public_html/
ErrorLog /var/www/domain.com/logs/error.log
CustomLog /var/www/domain.com/logs/access.log combined

Make sure the directories in the domain.com config exists

/var/www/domain.com/public_html/
/var/www/domain.com/logs
NOTE: use the mkdir command like this if needed

sudo mkdir /var/www/domain.com/public_html/
sudo mkdir /var/www/domain.com/logs
Now we need to enable the new config file like this

sudo a2ensite domain.com
You should see a notice to restart apache, use this command

/etc/init.d/apache2 restart
Now we need a test file to view

sudo vi /var/www/domain.com/public_html/index.html
Add some text

Hello domain.com
Open your web browser and go to your new domain

http://domain.com

Wednesday, July 27, 2011

Prado and installing PHPExcel - Auto Loading bug

Well this was a headache and then some.

The problem is Prado has a Auto Loading process that can cause 3rd party or additional libraries to break and act strange if they also have a Auto Loading process.

The Solution is to turn off Prado's Auto Loading process, Load the 3rd party/Additional library and then turn Prado's Auto Loading process back on.

Here is what it looks like: (In this example I'm using the namespace instead of the path alias)


$phpExcelPath = Prado::getPathOfNamespace('Application.Core.php_excel.Classes');

// Disable Prado Auto Loading process
spl_autoload_unregister(array('Prado','autoload'));

// Add PHP Excel
require_once($phpExcelPath.'/PHPExcel.php');
require_once($phpExcelPath.'/PHPExcel/Writer/Excel2007.php');

// Do PHP Excel stuff here

// Reload Prado Auto Loading process
spl_autoload_register(array('Prado','autoload'));



Reference: http://www.ramirezcobos.com/2010/11/05/how-to-use-phpexcel-with-yii/
They are using YII but the process is very similar

There is a discussion here for possibly more information regarding this issue.

Monday, October 11, 2010

Ubuntu upgrading to 10.10 Apache hosts get overwritten

If anyone else goes through this just re-add your hosts to /etc/hosts and restart Apache, kept getting this error "(EAI 5)No address associated with hostname: Could not resolve host name".

Tuesday, October 05, 2010

Why are my PHP sessions timing out around 30 minutes?

Have been pulling out my hair trying to find out why my sessions are being terminated/killed/destroyed at 30 minutes. Well it looks like Debian based systems have a special cron running that ignores all php.ini and apache configurations and kills any idle session at 30 minutes.

The cron path: /etc/cron.d/php5

Inside the cron:


# /etc/cron.d/php5: crontab fragment for php5
# This purges session files older than X, where X is defined in seconds
# as the largest value of session.gc_maxlifetime from all your php.ini
# files, or 24 minutes if not defined. See /usr/lib/php5/maxlifetime

# Look for and purge old sessions every 30 minutes
09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -print0 | xargs -n 200 -r -0 rm


/usr/lib/php5/maxlifetime code

#!/bin/sh -e

max=1440

for ini in /etc/php5/*/php.ini; do
cur=$(sed -n -e 's/^[[:space:]]*session.gc_maxlifetime[[:space:]]*=[[:space:]]*\([0-9]\+\).*$/\1/p' $ini 2>/dev/null || true);
[ -z "$cur" ] && cur=0
[ "$cur" -gt "$max" ] && max=$cur
done

echo $(($max/60))

exit 0


so it looks to be searching all the php.ini files, finds the greatest value, compares it to 1440 (which is 24 minutes).

Here are the php.ini files

/etc/php5/apache2/php.ini
session.gc_maxlifetime = 1440

/etc/php5/cgi/php.ini
session.gc_maxlifetime = 1440

/etc/php5/cli/php.ini
session.gc_maxlifetime = 1440


CRON running every 30 minutes is why the session looks to be killed at 30 minute intervals. But it could also be 24 to 54 minutes, FYI

Also looking over the code in: `/usr/lib/php5/maxlifetime` it's taking the highest value and during my testing I was trying to lower the threshold to speed up the condition (this is why we were getting mixed results).

So to configure a higher number is easy, just configure one of the php.ini files, set session.gc_maxlifetime to a higher value than 1440 and you might want to also change the cron execution times.

If you wanted a lower number you would have to edit ALL the php.ini files on your system as welll as the /usr/lib/php5/maxlifetime max= variable to the smaller number

Thursday, June 17, 2010

My wifes iPhone 4 Pre-Order Story

So after the headache of ordering two iPhone 4's on June 15th Pre-Order day we finally got our email confirmations for a June 24the delivery (Yeah), but somehow in the process we ended up purchasing three iPhone's. (Wonder how this could have happen? http://www.tuaw.com/2010/06/15/apple-and-atandt-servers-up-and-down-and-up-and-down/). Well the next day my wife calls to cancel one of the iPhone orders, the call took over two hours of being on hold (here is the funny part). During the on hold process my wife had to leave the house, not wanting to hang up (as she leaves the phone somewhere on speaker and listens for someone to pickup) she places the handset down and leaves the house for about forty minutes. Returning home she realizes she is still on hold with Apple and takes another ten minutes before she is able to speak to someone and resolve the issue, Great timing LOL!!! So to recap, two hours to speak to someone, forty minutes she leaves the house and just leaves the phone on speaker, an additional ten minutes on hold when she returns before speaking with someone. Priceless :)