Showing posts with label LAMP. Show all posts
Showing posts with label LAMP. Show all posts

Wednesday, May 14, 2008

Automating Processes by observing the Pattern

It's been said time and again that The REAL Programmer automates his job that they are Long Term Life Planners and have Attention to Detail

Here is just an example of ways in which one can automate processes.

I use Seagull Framework for developing faster, secure and feature rich Web based Applications Today, I had to update the Database to fill some blank columns in a table named sgl_permision

I first tried to edit them through the Seagull's Web based Admin Front end It was taking too long.
Then I tried to edit the same using phpMyAdmin setting the result to go to edit the next page instead of going back to the listing Page still it was very time consuming..

Then I decided to write SQL Queries by Observing the Pattern and using that to my rescue.

Here is the SQL Queries that I wrote to solve the Problem and am documenting so that it can be used in future.

/* To use a Manager */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to use ', TRIM(TRAILING 'mgr' FROM `name`), ' Manager')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr'

/* To add a new entity */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to add a new ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_add' FROM `name`)), ' through ', TRIM(TRAILING 'mgr_cmd_add' FROM `name`), ' Manager')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_add'

/* To view the listing of entities */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to view the listing of ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_list' FROM `name`)), '(s) through ', TRIM(TRAILING 'mgr_cmd_list' FROM `name`), ' Manager')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_list'

/* To insert a new entity */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to insert new ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_insert' FROM `name`)), ' through ', TRIM(TRAILING 'mgr_cmd_insert' FROM `name`), ' Manager in the Database')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_insert'

/* To edit an existing entity */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to edit an existing ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_edit' FROM `name`)), ' through ', TRIM(TRAILING 'mgr_cmd_edit' FROM `name`), ' Manager')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_edit'

/* To update an existing entity in the database */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to update an existing ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_update' FROM `name`)), ' through ', TRIM(TRAILING 'mgr_cmd_update' FROM `name`), ' Manager in the Database')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_update'

/* To delete an entity */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to delete ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_delete' FROM `name`)), '(s) through ', TRIM(TRAILING 'mgr_cmd_delete' FROM `name`), ' Manager from the Database')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_delete'

/* To archive an entity */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to archive ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_archive' FROM `name`)), '(s) through ', TRIM(TRAILING 'mgr_cmd_archive' FROM `name`), ' Manager in the Database')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_archive'

/* To View an entity in detail */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to view ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_view' FROM `name`)), ' through ', TRIM(TRAILING 'mgr_cmd_view' FROM `name`), ' Manager')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_view'

/* To create a duplicate of an entity */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to create a duplicate of ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_duplicate' FROM `name`)), ' through ', TRIM(TRAILING 'mgr_cmd_duplicate' FROM `name`), ' Manager')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_duplicate'

/* To reorder entities */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to reorder ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_reorder' FROM `name`)), '(s) through ', TRIM(TRAILING 'mgr_cmd_reorder' FROM `name`), ' Manager')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_reorder'

/* To view an overview of an entities */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to view an overview of ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_overview' FROM `name`)), '(s) through ', TRIM(TRAILING 'mgr_cmd_overview' FROM `name`), ' Manager')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_overview'

/* To view a summary of an entity */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to view an summary of ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_summary' FROM `name`)), '(s) through ', TRIM(TRAILING 'mgr_cmd_summary' FROM `name`), ' Manager')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_summary'

/* To edit all entities */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to edit all ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_editAll' FROM `name`)), '(s) through ', TRIM(TRAILING 'mgr_cmd_editAll' FROM `name`), ' Manager')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_editAll'

/* To Update all entities */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to update all ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_updateAll' FROM `name`)), '(s) through ', TRIM(TRAILING 'mgr_cmd_updateAll' FROM `name`), ' Manager')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_updateAll'

/* Scan all Orphaned entities */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to scan all Orphaned ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_scanOrphaned' FROM `name`)), '(s) through ', TRIM(TRAILING 'mgr_cmd_scanOrphaned' FROM `name`), ' Manager')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_scanOrphaned'

/* Delete all Orphaned entities */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to delete all Orphaned ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_deleteOrphaned' FROM `name`)), '(s) through ', TRIM(TRAILING 'mgr_cmd_deleteOrphaned' FROM `name`), ' Manager')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_deleteOrphaned'

/* Scan to detect new Entities */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to scan and detect for new ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_scanNew' FROM `name`)), '(s) through ', TRIM(TRAILING 'mgr_cmd_scanNew' FROM `name`), ' Manager')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_scanNew'

/* To insert newly detected Entities */
UPDATE `sgl_permission`
SET `description` = CONCAT('Permission to insert new ', TRIM(LEADING 'admin' FROM TRIM(TRAILING 'mgr_cmd_insertNew' FROM `name`)), '(s) through ', TRIM(TRAILING 'mgr_cmd_insertNew' FROM `name`), ' Manager')
WHERE (`description` = '' OR `description` IS NULL)
AND `name` LIKE '%mgr\_cmd\_insertNew'

Wednesday, April 16, 2008

Google Toolbar Button for PHP Reference

Here is a Google Toolbar Custom Button to Search php.net for all LAMP Developers

Requirements:

1) Google Toolbar must be installed in your Browser . Google has Toolbar for Internet Explorer and Mozilla Firefox. There could be Toolbars for other Browsers also.
You can check and install Google Toolbar from http://toolbar.google.com

Click here to add the Button to your Google Toolbar
Its a single XML file and you can download the XML file and view its source.


Install
Download

Related Posts:
Google Toolbar Custom Button to Search your Web History through Google
Google Customized Search Engine
All Google Toolbar Buttons Created by me

Install or Download Google toolbar button to Search through a Google customized Search Engine by me specifically for the domain Web Development on LAMP Platform

Install or Download Google Toolbar Custom Button to search your Google Web History.

Monday, November 5, 2007

Getting Eclipse to Work on Ubuntu

Getting Eclipse to wiork on Ubuntu for all my Development Work proved to be very tricky.
There are issues related to permission compatibility and what not.

Here is what worked for me.
After installing and uninstalling Eclipse and deleting the Workspace for quite a few times, I first removed all the Packages with the search term eclipse from the Synaptic Package Manager (Top Bar -> System Menu -> Administration -> Synaptic Package Manager)

Then I used the steps as explained in the iteratively documented tutorial at Ubuntuforum in the following url

http://ubuntuforums.org/showthread.php?t=201378

After doing this, the first time I run the Editor from the terminal with the following command
rungss@rungss-ubuntu: eclipse -clean

then I included the following Update sites
name="Subclipse Subversion Plugin" url="http://subclipse.tigris.org/update_1.2.x"
name="The Eclipse 3.3 Project Updates" url="http://update.eclipse.org/updates/3.3"
name="Europa Discovery Site" url="http://download.eclipse.org/releases/europa"
name="PDT Updates" url="http://download.eclipse.org/tools/pdt/updates/"
name="Web Tools Platform (WTP) Updates" url="http://download.eclipse.org/webtools/updates"

By default there were two sites

name="The Eclipse Project Updates" url="http://update.eclipse.org/updates/3.2"
name="Callisto Discovery Site" url="http://download.eclipse.org/callisto/releases"

Here is the link of Update Site Bookmarks which you can import through the Eclipse Update manager.
http://bijay.rungta.googlepages.com/ubuntu-lamp-eclipse-update-sites-boo.xml

Note: be careful with the ending /(slash) for the site urls enter them as is in the above list. Its strange that for some sites the end "/" is valid while not for others.

Then I searched for Updates..

Upon the listing of all available features I selected a few based on my preferences. The following is the list of them
  • Subclipse Plugin from Subclipse Update site
  • PDT features and PDT SDK features from the PDT Update Site
  • Eclipse 3.3 from the Eclipse 3.3 Project Update Site.(I like the view in 3.3 where you can minimize all panels and view any one of them as you wish irrespective of the Perspective you are viewing the Editor)
  • WTP from Europa Site and some other CVS related features.
While selecting these features I clicked on the Select Required button when I saw any error for incompatibility in selected features.

Next I signed the Agreements and when Saving them I selected the folder "/usr/local/lib/eclipse" to install features where it was in any other Directory than the base installation location (Basically wherever it permitted to do so.)
This is done so that other users can also use them. Advise taken from the article at https://help.ubuntu.com/community/EclipseWebTools

That is all This seems to work for me.
Here are the various webpages that I reviewed many a times during the whole process

http://ubuntuforums.org/showthread.php?t=201378
https://help.ubuntu.com/community/EclipseWebTools
https://help.ubuntu.com/community/EclipseIDE

https://bugs.launchpad.net/ubuntu/+source/eclipse/+bug/68053
https://bugs.launchpad.net/ubuntu/+source/eclipse/+bug/68053
http://flurdy.com/docs/eclipse/install.html
http://ubuntuforums.org/showthread.php?p=3177266
http://www.eclipseplugincentral.com/PNphpBB2-printview-t-2556-start-0.html
http://www.eclipse.org/eclipse/development/readme_eclipse_3.3.1.1.html
http://ubuntuforums.org/archive/index.php/t-436316.html

PS: The strategy to install plugins in the directory /usr/local/lib/eclipse again had some problems. Was getting an error message saying conflict entries..
I guess what happened is some of the files(a part of some plugin was exisitng in both the directory usr/lib/eclipse and usr/local/lib/eclipse) or may be because i installed Eclipse 3.3 on Eclipse 3.2 I have started the Eclipse 3.3 updation right now and wil realize if thats what the problem was in some time. Will update the post.

So I had to uninstall the Eclipse again and then I reinstalled. But to my Surprise I got the same error again(Conflict..)
I later realized that this was because when I installed it after uninstalling it... It was basically installed from the cache on the Local Computer..

So I run the following command to first clear the cache

apt-get clean

Thanks to teh article at https://help.ubuntu.com/community/AptGetHowto

And then I reinstalled eclipse with the following the steps at the Page
http://ubuntuforums.org/showthread.php?t=201378

Lets see how it goes now...

Saturday, October 27, 2007

Setting up XAMPP for LAMP Development on Windows

Out of several LAMP/WAMP stack packages available in the market I prefer XAMPP from http://apachefriends.org when Working on a Windows machine for my Development Environment.

The XAMPP for Windows can be downloaded from the following link
http://www.apachefriends.org/en/xampp-windows.html

I download/keep the zip archive of the Basic package XAMPP Windows 1.6.4 which has the following components

Apache HTTPD 2.2.6, MySQL 5.0.45, PHP 5.2.4 + 4.4.7 + PEAR + Switch, MiniPerl 5.8.7, Openssl 0.9.8e, PHPMyAdmin 2.11.1, XAMPP Control Panel 2.5, Webalizer 2.01-10, Mercury Mail Transport System v4.01a, FileZilla FTP Server 0.9.23, SQLite 2.8.15, ADODB 4.94, Zend Optimizer 3.3.0, XAMPP Security, Ming. For Windows 98, 2000, XP.

After downloading it if you unzip the archive you will get a folder structure something like the following
---------------------------------
./xampp
./xampp/apache
./xampp/php
./xampp/mysql
./xampp/perl
---------------------------------
Copy the XAMPP folder to the root of any Drive (Its not really required but to avaoid any hassle I recommend that you copy it to the Local Drive root and avoid spaces in any of the paths to all executables)

You can run the Server in many ways. I am going to describe some of them here.


Note: Before proceeding you need to make sure that the default Ports for the Servers that you wish to run or install are free. You can check this by running the Executable file ./xampp/xampp-portcheck.exe This will tell you whether the ports are free or not. if any of the port numbers 80(for HTTP Server) and 443(for HTTPS Server) is not free you will either need to stop/disable the Application that is running on this port or you will need to configure the Apache Server to run on some other port.

To change the default HTTP Port 80 for Apache open the config file ./xampp/apache/conf/httpd.conf in a text editor and replace all occurances of 80 to the new Port (Which should again obviously be free).
If you need to change the port 443 then open the file ./xampp/apache/conf/extra/httpd-ssl.conf and replace the occurances of 443 with the new port.

Similarly to run MySQL on a different port you will need to make changes in the file ./xampp/my.ini by replacing the default Port number 3306 with some other free valid port number.

If you are not a hard core LAMP Developer and going to have to run the server only occasionally You can start the Apache Server by executing the Batch file ./xampp/apache_start.bat in the root XAMPP folder. and to run the MySQL server run the Batch file ./xampp/mysql_start.bat

You should be all set to run your applications. Copy Your Applications directory to ./xampp/htdocs/MyAPP/* and you can access the Application with a url http://localhost/MyApp and http://localhost/MyApp/*

But this scheme has a drawback that you cat close the dos window unless you want to stop the Servers. To do so you have to run the Batch files ./xampp/apache_stop.bat
and ./xampp/mysql_stop.bat to stop them.

XAMPP Provides a Control Panel which is a file named ./xampp/xampp-control.exe if you run it you will get a User interface as in the following screenshot


You can simply Start and Stop by clicking the button with appropriate label beside each service. Bothe Servers are in running mode in the above Screen shot. so you don't see the Button labeled Start here.

This scheme is very cool but if you are a hard code developer and will need the Server running all the time then probably you wouldn't want to have to start the Servers manually each time you boot your System.

You can install the Servers as a Windows Server by clicking on the checkbox beside the respective Server. Make sure to stop the Server you are installing as a Service before checking the checkbox to install it.You will be prompted to confirm if you really want to install it as a service. It will be installed if you confirm by clicking the button labeled "OK" Once the Service is installed you can start the Servers manually by clicking on the Start button here for the first and last time.


Note: If you have the XAMPP folder in D and select the Service option then you will have to run the Script .xampp/setup_xampp.bat before proceeding because of some bug in this version (not sure about other versions.).

You should be all set now. next time you boot the System both the Servers will be started automatically.

Checklists:
Ports
XAMPP Path

Happy Developing on LAMP/WAMP ...