Google Translate for Free

Google recently switched over to a paid model only. There is however a way to still get your translations for free.

The link below downloads a javascript file that includes a JSON string with your requested translation.

Simply format the link to your needed translation and you will be saying Hello there in every language. Congrats!

http://translate.google.com/translate_a/t?client=g&text=Hello+there&sl=en&tl=fr

Thursday, March 1st, 2012 API Services, Javascript No Comments

Restart Zend Server on Mac OSX

From the terminal:

sudo /usr/local/zend/bin/zendctl.sh restart

Monday, February 6th, 2012 Unix/Linux No Comments

Doctrine Generate Models from DB

Automatically generating the models for a project based off of existing database tables is extremely handy. I’ve had to do this several times and the available options are key, especially when generating these for a Zend Framework layout. The following stack overflow entry is very helpful:

http://stackoverflow.com/questions/2605291/what-are-the-options-available-for-doctrines-doctrine-coregeneratemodelsfromd/6541608#6541608

/**
* Doctrine CLI script
*/

define('APPLICATION_ENV', 'development');

define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
realpath(APPLICATION_PATH . '/../library/Doctrine'),
get_include_path(),
)));

require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/config/default.ini'
);

$application->getBootstrap()->bootstrap('doctrine');

Doctrine::generateModelsFromDb(
APPLICATION_PATH . '/modules/default/models/DbTable',
array('db1'),
array(
'pearStyle' => true,
'generateTableClasses' => true,
'baseClassesDirectory' => '',
'classPrefix'=> 'Model_DbTable_',
'classPrefixFiles' => false,
'baseClassPrefix' => 'Generated_'
)
);

Tuesday, November 15th, 2011 Doctrine, Zend Framework No Comments

How do I get the domain name from a full URL in MySQL?

I too had that same question friend. It is actually quite simple thankfully!

This little snippet should do the trick for you:

SELECT count(visit_id) as total_visits,
SUBSTRING_INDEX(TRIM(leading "http://" from TRIM(url_column_from_table)),'/',1) as url_visited
FROM url_visits
GROUP BY 1;

Tags:

Thursday, August 11th, 2011 MySQL No Comments

Setting up your MAMP Environment for Zend Tool

I wanted to get a bit more familiar with Zend Tool and so I set out setting it up on my machine.

I am currently using MAMP Pro, with PHP 5.3.5.

You will need to copy the Zend library folder into:

/Applications/MAMP/bin/php5.3/lib/php/

And your Zend ‘bin’ folder contents into:

/Applications/MAMP/bin/php5.3/bin/
–zf.bat
–zf.php
–zf.sh

Then setup an alias in your terminal to reference the the zf.sh file – to do so, run the following commands:
cd /etc
sudo vi profile

—- Then go down to the end of the file and paste:

alias zf=/Applications/MAMP/bin/php5.3/bin/zf.sh
export PATH=/Applications/MAMP/bin/php5.3/bin/:$PATH
export ZF_HOME=/Applications/MAMP/htdocs

This will set your default project path to be in the htdocs folder, and your php version to reference the 5.3 instance in MAMP.

Save the file by hitting the Escape key, then type:
wq!

This will save and exit the file. Go ahead and close your terminal, and re-open it.

Try typing:
zf show version

You should now be greeted with the current version of the Zend Framework that the script is connected with.

UPDATE:

After attempting to create a new zend framework project, I ran into a problem with the home path not being picked up correctly… So I had to set it at a deeper level within OSX – please see:

http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x

References:

http://wrightcreativelabs.com/blog/62-zend-framework-setup-mac-os-x-with-macports.html

http://www.digitalsurgeons.com/blog/the-lab/howto-install-zend-mamp-ma/

Thursday, June 30th, 2011 Uncategorized No Comments

SFTP OSX to Unix – Uploading/Downloading files remotely

I have needed this several times and always seem to forget the exact syntax and method to get the job done.

This website provides a great run-down!

http://it.unm.edu/howtos/715.html

Thursday, June 23rd, 2011 Unix/Linux 1 Comment

Multi Table Delete Syntax for MySQL

Today I needed to do a little clean-up in one of my applications that I re-vamped. There were several tables that had entries that were no longer relevant to the code base so I went about deleting them and any entries that were dependent upon them. It would have been a huge pain to have to go through each table and figure out which entries were associated, so luckily MySQL provides a simple solution. I did have to mess around with this a bit before it would work, mainly due to my prepending the database name in front of the table, ‘db_name.tb_name’, and for some reason that was not well liked… So I instead specified the database I wanted to execute this query on, and removed the database name and it worked like a charm. I needed to remove all references to a module that was no longer within the framework.

The actual query is the following:

DELETE aa, ac, am, aua, aga, ausp, agsp, asp, mi, a
FROM acl_action AS aa
INNER JOIN acl_controller AS ac ON (ac.acl_controller_id = aa.acl_controller_id)
INNER JOIN acl_module AS am ON (am.acl_module_id = ac.acl_module_id)
INNER JOIN acl AS a ON (a.acl_action_id = aa.acl_action_id)
LEFT JOIN acl_user_acl AS aua ON (aua.acl_id = a.acl_id)
LEFT JOIN acl_group_acl AS aga ON (aga.acl_id = a.acl_id)
LEFT JOIN acl_subprivilege As asp ON (asp.acl_id = a.acl_id)
LEFT JOIN acl_group_subprivilege AS agsp ON (agsp.acl_subprivilege_id = asp.acl_subprivilege_id)
LEFT JOIN acl_user_subprivilege AS ausp ON (ausp.acl_subprivilege_id = asp.acl_subprivilege_id)
LEFT JOIN menu_item AS mi ON (mi.acl_id = a.acl_id)
WHERE am.acl_module_id = 1;
Friday, June 10th, 2011 MySQL No Comments

HTML 5 Webkit Desktop Notification Code (Google Chrome Support Only… for Now.)

I was on gmail the other day and it prompted me to allow desktop notifications for my chat.. Hm, YES! It’s very helpful to have a popup come up as though it were built-in to the OS. Get’s your attention right away. So my next thought went to… How can I leverage this same benefit for my users? So I found a site that gave a great tutorial on how to do it, my example supplements it a bit, but the other is definitely worth a peek!

http://www.beakkon.com/tutorial/html5/desktop-notification

$('body').click(function(){
		displayNotification();
	});
    
    if (!window.webkitNotifications) {
        alert('Sorry , your browser does not support desktop notification. Try Google Chrome.');
    } 

    function sendPermissionRequest(callback)
    {
    	window.webkitNotifications.requestPermission(callback);
    }

	function displayNotification()
	{
		if(window.webkitNotifications.checkPermission() > 0){
			
			sendPermissionRequest(displayNotification);
			
		} else {

    	    var icon  = 'link_to_logo.png';
            var title = 'Routy Development';
            var body   = 'Kapow!';
     
            var popup = window.webkitNotifications.createNotification(icon, title, body);
            
            popup.show();
            
            setTimeout(function(){
            	popup.cancel();
            }, '15000');

		}
	
	}

	function displayHtmlNotification()
    {
        if (window.webkitNotifications.checkPermission() > 0) {
        	sendPermissionRequest(displayHtmlNotification);
        } else {
        
            var popup = window.webkitNotifications.createHTMLNotification('http://blog.routydevelopment.com');
            popup.show();
            
            setTimeout(function(){
            	popup.cancel();
            }, '15000');
        }
    } 

A few links that I had to also browse to when finding/installing this gem:

http://www.beakkon.com/tutorial/html5/desktop-notification
http://www.quora.com/Mozilla-Firefox/When-will-firefox-support-Desktop-Notifications-like-Chrome
http://stackoverflow.com/questions/4913866/webkitnotifications-security-err-dom-exception-18-script-ok-button

Friday, March 25th, 2011 Javascript, jQuery No Comments

Website Tour w/ jQuery Improved! Site Tour Plugin

Website Tour With jQuery

Recently I needed the ability to give an overview of some changes made on one of my web projects. I ran across the tutorial provided by CODROPS, and decided that it wasn’t quite as easy and modular as I would have liked…

So I re-did it!

Download the code from GitHub and enjoy!

https://github.com/nickrouty/jQuery-Tour

Original code:

http://tympanus.net/codrops/2010/12/21/website-tour/

View the source code to really get an idea of how it works.

I added a feature that will save a cookie when the user ends the tour, or if they click remind me later, it will popup the next visit. It is also only a line to instantiate. VERY easy to use on multiple pages now.

Enjoy!

Thursday, March 24th, 2011 jQuery No Comments

jQuery Image & Photo Galleries and Slideshow Plugins

Coin Slider

Slick Slider


Wednesday, February 9th, 2011 jQuery No Comments
[ad code=1 align=center]