Official Website
http://rubyonrails.org/
Great Start
http://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial
Examples
http://www.tutorialspoint.com/ruby-on-rails/rails-examples.htm
Sample applications with basic features like authentication and admin features
http://www.railsinside.com/elsewhere/100-7-barebones-rails-apps-to-kick-start-your-development-process.html
Many to Many Relationship with Multi select control in rails
http://blog.coryfoy.com/2008/02/multiselect-control-in-rails-with-a-many-to-many-relationship/
Develop Facebook application
http://www.liverail.net/articles/2007/6/29/tutorial-on-developing-a-facebook-platform-application-with-ruby-on-rails
Monday, July 26, 2010
Use mysql_real_escape_string() function to avoid mysql injections
// Query database to check if there are any matching users
$query = "SELECT * FROM users WHERE user='{$_POST['username']}' AND password='{$_POST['password']}'";
mysql_query($query);
// We didn't check $_POST['password'], it could be anything the user wanted! For example:
$_POST['username'] = 'admin';
$_POST['password'] = "' OR ''='";
// This means the query sent to MySQL would be:
echo $query;
?>
The query sent to MySQL as:
SELECT * FROM users WHERE user='admin' AND password='' OR ''=''
This would allow anyone to log in without a valid password.
Solution:
// Query
$query = sprintf("SELECT * FROM users WHERE user='%s' AND password='%s'",
mysql_real_escape_string($_POST['user']),
mysql_real_escape_string($_POST['password']));
?>
Here mysql_real_escape_string function prepends backslashes to the following characters: \x00, \n, \r, \, ', " and \x1a to make data safe before sending a query to MySQL. So user can't hack your database.
$query = "SELECT * FROM users WHERE user='{$_POST['username']}' AND password='{$_POST['password']}'";
mysql_query($query);
// We didn't check $_POST['password'], it could be anything the user wanted! For example:
$_POST['username'] = 'admin';
$_POST['password'] = "' OR ''='";
// This means the query sent to MySQL would be:
echo $query;
?>
The query sent to MySQL as:
SELECT * FROM users WHERE user='admin' AND password='' OR ''=''
This would allow anyone to log in without a valid password.
Solution:
// Query
$query = sprintf("SELECT * FROM users WHERE user='%s' AND password='%s'",
mysql_real_escape_string($_POST['user']),
mysql_real_escape_string($_POST['password']));
?>
Here mysql_real_escape_string function prepends backslashes to the following characters: \x00, \n, \r, \, ', " and \x1a to make data safe before sending a query to MySQL. So user can't hack your database.
Saturday, July 24, 2010
Wordpress Vs Drupal
Hi, here is my view about where to use wordpress and where to use drupal.
Wordpress
# If your application doesn't contain so many dynamic content forms and have to manage some static pages of information and need a bloging system.
It should suitable company portfolio sites and simple to medium level websites.
Drupal
# If you have multiple dynamic content types (press releases, news articles, blog posts, etc.). Drupal is great at allowing you to create this stuff on the fly, with Wordpress you are hacking things together.
# If your site has more than a two template design structure (homepage and second levels).
# If you have numerous content blocks on the homepage or in sidebars that you will be editing frequently. Drupal’s block system is great at this kind of stuff.
# If you are trying to start small and expect your site to add tons of features/content moving forward.
It should suitable for complex websites which involves so many modules.
Wordpress
# If your application doesn't contain so many dynamic content forms and have to manage some static pages of information and need a bloging system.
It should suitable company portfolio sites and simple to medium level websites.
Drupal
# If you have multiple dynamic content types (press releases, news articles, blog posts, etc.). Drupal is great at allowing you to create this stuff on the fly, with Wordpress you are hacking things together.
# If your site has more than a two template design structure (homepage and second levels).
# If you have numerous content blocks on the homepage or in sidebars that you will be editing frequently. Drupal’s block system is great at this kind of stuff.
# If you are trying to start small and expect your site to add tons of features/content moving forward.
It should suitable for complex websites which involves so many modules.
How to get driving licence in Andhra Pradesh
The procedure to obtain a Driving License is simple. Follow the below mentioned steps.
Normally this is the process in any State across India. Well, Few Road Transport Authorities (RTA's) could be working as per the local governments periodic regulations.
1. Buy the Learning Licence Forms. These are Form 2, Form 1 & Form 1A(Form 1A is for people aged above
40 years and also depends if your RTA needs it). These forms are available in single click at www.drivingtest.in. Copy or Click the following link and try.
http://drivingtest.in/rta-forms.php
2. Once you are done with filling up of forms, find out with the Road Transport Authoritie’s office, if you have to book a slot for your learners license test. In Andhra Pradesh, one has to book the slot and then practice the questions to clear the test. In Andhra Pradesh the slot can be booked at the link below.
Visit :-
http://www.delhi.gov.in/wps/wcm/connect/doit_transport/Transport/Home/Driving+Licence/Learner+Licence(For Delhi)
http://rto.kar.nic.in/ (click on 'online appointment for LL' for Karnataka)
http://cfst.co.in/cfstonline/LL/TestCenter.aspx (for Andhra Pradesh only)
3. Once the slot is booked, you need to prepare for the online learners licence test which comprises of 20 questions (For Andhra Pradesh). In other cases, walk in to RTA office and pay fee and wait for your turn. The passing mark is 16 where each question carries 1 mark for AP. The number of questions may vary from State to State, however, the questions in this website are the ones normally in the syllabus. In order to practice online you may visit the following link. There are about 250 questions in this website and 10 are free sample learners licence questions. Register to access all the Driving Licence questions.
http://www.drivingtest.in/online-driving-license-sample-test.php
4. To get a hint on the road signs and the traffic signs go to
For knowing all the Traffic Signs http://www.drivingtest.in/road-signs.php
To know about driving tips etc http://www.drivingtest.in/resources.php
5. Once you clear your learners license, you may book a slot for the permanent licence (This is in case of Andhra Pradesh) on the same website as stated above. For other states call the RTA office to find out the availability
of track to be tested for the permanent License. While learning to drive a two wheeler or a four wheeler, kindly keep the road safety and its structure in mind. Read the signs in practical driving test carefully. For further driving tips click on the following links.
http://www.drivingtest.in/driving-tips.php
http://www.drivingtest.in/road-marking.php
http://www.drivingtest.in/offences-penalties.php
Normally this is the process in any State across India. Well, Few Road Transport Authorities (RTA's) could be working as per the local governments periodic regulations.
1. Buy the Learning Licence Forms. These are Form 2, Form 1 & Form 1A(Form 1A is for people aged above
40 years and also depends if your RTA needs it). These forms are available in single click at www.drivingtest.in. Copy or Click the following link and try.
http://drivingtest.in/rta-forms.php
2. Once you are done with filling up of forms, find out with the Road Transport Authoritie’s office, if you have to book a slot for your learners license test. In Andhra Pradesh, one has to book the slot and then practice the questions to clear the test. In Andhra Pradesh the slot can be booked at the link below.
Visit :-
http://www.delhi.gov.in/wps/wcm/connect/doit_transport/Transport/Home/Driving+Licence/Learner+Licence(For Delhi)
http://rto.kar.nic.in/ (click on 'online appointment for LL' for Karnataka)
http://cfst.co.in/cfstonline/LL/TestCenter.aspx (for Andhra Pradesh only)
3. Once the slot is booked, you need to prepare for the online learners licence test which comprises of 20 questions (For Andhra Pradesh). In other cases, walk in to RTA office and pay fee and wait for your turn. The passing mark is 16 where each question carries 1 mark for AP. The number of questions may vary from State to State, however, the questions in this website are the ones normally in the syllabus. In order to practice online you may visit the following link. There are about 250 questions in this website and 10 are free sample learners licence questions. Register to access all the Driving Licence questions.
http://www.drivingtest.in/online-driving-license-sample-test.php
4. To get a hint on the road signs and the traffic signs go to
For knowing all the Traffic Signs http://www.drivingtest.in/road-signs.php
To know about driving tips etc http://www.drivingtest.in/resources.php
5. Once you clear your learners license, you may book a slot for the permanent licence (This is in case of Andhra Pradesh) on the same website as stated above. For other states call the RTA office to find out the availability
of track to be tested for the permanent License. While learning to drive a two wheeler or a four wheeler, kindly keep the road safety and its structure in mind. Read the signs in practical driving test carefully. For further driving tips click on the following links.
http://www.drivingtest.in/driving-tips.php
http://www.drivingtest.in/road-marking.php
http://www.drivingtest.in/offences-penalties.php
Friday, July 23, 2010
Restart live server for your rails application
When you change any modifications in models or configuration files, then changes will not apply in server some times, in that situation you need to restart the server by connecting your hosting server through telnet. Follow the below process
Login through telnet and enter into the application root path
Ex:# ssh root@example.com
Goto application path
Ex: cd /var/www/example.com
Then run the following commands
# mongrel_rails stop
# mongrel_rails start -d
Login through telnet and enter into the application root path
Ex:# ssh root@example.com
Goto application path
Ex: cd /var/www/example.com
Then run the following commands
# mongrel_rails stop
# mongrel_rails start -d
Tuesday, July 20, 2010
Check session expiration in php
/* The below script will check for users inactivity on page, If use open one page, then store the current time on $_SESSION['start'] variable. If he doesn't move cursor or click any key from keyboard for some time, and then if he click on any link it will check his inactive time. if it is greater than the limited time we set here 5 minutes as exmple, then he will redirected to inactive.php page */
?>
session_start(); // NEVER FORGET TO START
$inactive = 300; //means expire within 5 minutes
if(isset($_SESSION['start']) ) { // if session start set
$session_life = time() - $_SESSION['start'];
if($session_life > $inactive){ //if session time expired
header("Location: inactive.php"); //session expired message page
}
}
$_SESSION['start']=time(); //in pageload current time stored in session.
?>
?>
session_start(); // NEVER FORGET TO START
$inactive = 300; //means expire within 5 minutes
if(isset($_SESSION['start']) ) { // if session start set
$session_life = time() - $_SESSION['start'];
if($session_life > $inactive){ //if session time expired
header("Location: inactive.php"); //session expired message page
}
}
$_SESSION['start']=time(); //in pageload current time stored in session.
?>
Recommended discussions forums for php
http://www.w3schools.com/
http://www.phpfreaks.com/forums/
http://forums.digitalpoint.com/forumdisplay.php?f=37
http://forums.devshed.com/php-development-5/
http://phpbuilder.com/board/
http://www.phpfreaks.com/forums/
http://www.weberforums.com/
http://www.phpbb.com/community/viewforum.php?f=1
http://www.sitepoint.com/forums/forumdisplay.php?forumid=34
http://phpdebutant.com/
http://www.phpfreechat.net/forum/
http://www.phpfreaks.com/forums/
http://forums.digitalpoint.com/forumdisplay.php?f=37
http://forums.devshed.com/php-development-5/
http://phpbuilder.com/board/
http://www.phpfreaks.com/forums/
http://www.weberforums.com/
http://www.phpbb.com/community/viewforum.php?f=1
http://www.sitepoint.com/forums/forumdisplay.php?forumid=34
http://phpdebutant.com/
http://www.phpfreechat.net/forum/
Enable SSH access for you shared hosting account in godaddy server
To Enable SSH on Your Linux Shared Hosting Account
1. Log in to your Account Manager.
2. From the Products section, click Web Hosting.
3. Next to the hosting account you want to use, click Launch.
4. In the Settings section of the Hosting Control Center, click the SSH icon.
5. Type your Country Code, Phone Number, and Extension (if applicable) in the corresponding fields and click Enable.
NOTE: SSH requires a strong password. If prompted to change your password, click Change Password, type a new password, and click OK.
6. We call the phone number provided within 10 minutes. Once the connection is established, an automated message plays a message containing a PIN. Type the PIN number into the You will be called with your PIN field and click Verify.
Once verified, it may take 24-72 hours for SSH to be enabled for your account. During this time, you are locked out from the account as it is moved to a new server.
1. Log in to your Account Manager.
2. From the Products section, click Web Hosting.
3. Next to the hosting account you want to use, click Launch.
4. In the Settings section of the Hosting Control Center, click the SSH icon.
5. Type your Country Code, Phone Number, and Extension (if applicable) in the corresponding fields and click Enable.
NOTE: SSH requires a strong password. If prompted to change your password, click Change Password, type a new password, and click OK.
6. We call the phone number provided within 10 minutes. Once the connection is established, an automated message plays a message containing a PIN. Type the PIN number into the You will be called with your PIN field and click Verify.
Once verified, it may take 24-72 hours for SSH to be enabled for your account. During this time, you are locked out from the account as it is moved to a new server.
(QA) Testing, Staging and Production environments are now available with Heroku
Hi There,
Deploying application in multiple environements is a better approach for a successfull appliation. This is the default behaviour of the rails application to maintain deployment in development, testing and production environments. Development and testing versions are live on developer's local system and production environement lives on actual server.
Now heroku offers us to maintain the application with these three evnironments in live server withing heroku so that clients and your colleagues can provide feedback and suggestions on your application before pushing them to production.
Ex: If you want to deploy an application called "myapp" in Heroku. First create the production,staging and testing(QA) versions of the application, should use --remote option to override the defaults for the git repository names.
$ heroku create myapp-production --remote production
$ heroku create myapp-staging --remote staging
$ heroku create myapp-qa --remote qa
Now, if you want to deploy code to a particular environemt, do so by specifying the appropriate option
Ex:
$ git push staging master
and if you need to run db migrations use below
$ heroku rake db:migrate --remote staging
Finally, If you probably want to periodically copy your production data into your staging environment:
$ heroku db:pull --remote production
$ heroku db:push --remote staging
Now, when you want to deploy code to a particular environment, do so by specifying the appropriate remote:
$ git push staging master
And if you need to run migrations:
$ heroku rake db:migrate --remote staging
Finally, you will probably want to periodically copy your production data into your staging environment:
$ heroku db:pull --remote production
$ heroku db:push --remote staging
Note: Keep in mind that any environment variables you create or add-ons you add must be duplicated across environments for a consistent experience. For example, if you begin using memcache on your staging app, be sure to install it on your production app before you deploy your new code.
For more details
http://jqr.github.com/2009/04/25/deploying-multiple-environments-on-heroku.html
http://stackoverflow.com/questions/1279787/staging-instance-on-heroku
Deploying application in multiple environements is a better approach for a successfull appliation. This is the default behaviour of the rails application to maintain deployment in development, testing and production environments. Development and testing versions are live on developer's local system and production environement lives on actual server.
Now heroku offers us to maintain the application with these three evnironments in live server withing heroku so that clients and your colleagues can provide feedback and suggestions on your application before pushing them to production.
Ex: If you want to deploy an application called "myapp" in Heroku. First create the production,staging and testing(QA) versions of the application, should use --remote option to override the defaults for the git repository names.
$ heroku create myapp-production --remote production
$ heroku create myapp-staging --remote staging
$ heroku create myapp-qa --remote qa
Now, if you want to deploy code to a particular environemt, do so by specifying the appropriate option
Ex:
$ git push staging master
and if you need to run db migrations use below
$ heroku rake db:migrate --remote staging
Finally, If you probably want to periodically copy your production data into your staging environment:
$ heroku db:pull --remote production
$ heroku db:push --remote staging
Now, when you want to deploy code to a particular environment, do so by specifying the appropriate remote:
$ git push staging master
And if you need to run migrations:
$ heroku rake db:migrate --remote staging
Finally, you will probably want to periodically copy your production data into your staging environment:
$ heroku db:pull --remote production
$ heroku db:push --remote staging
Note: Keep in mind that any environment variables you create or add-ons you add must be duplicated across environments for a consistent experience. For example, if you begin using memcache on your staging app, be sure to install it on your production app before you deploy your new code.
For more details
http://jqr.github.com/2009/04/25/deploying-multiple-environments-on-heroku.html
http://stackoverflow.com/questions/1279787/staging-instance-on-heroku
Thursday, July 15, 2010
PHP For Android
Hi Friends,
PHP For Android project was launched recently and the complete information available in phpclasses.org site in the form of interview with the inventor. The information url: http://www.phpclasses.org/blog/post/125-Developing-PHP-applications-to-run-natively-on-Android-phones.html
PHP For Android project was launched recently and the complete information available in phpclasses.org site in the form of interview with the inventor. The information url: http://www.phpclasses.org/blog/post/125-Developing-PHP-applications-to-run-natively-on-Android-phones.html
Wednesday, July 14, 2010
Free online php code encryption
If you want to encrypt your source to avoid others to modify your code and stealth your code try this one.
http://www.byterun.com/free-php-encoder.php
http://www.byterun.com/free-php-encoder.php
Easy Drupal version upgradation
The standard to upgrade your drupal application is download the latest version from drupal.org and follow the instructions from UPGRADE.txt file.
Some information regarding version upgrade for drupal is avalible here : http://fuerstnet.de/en/drupal-upgrade-easier
And for quality assurance testing find the information here: http://qa.drupal.org/
Some information regarding version upgrade for drupal is avalible here : http://fuerstnet.de/en/drupal-upgrade-easier
And for quality assurance testing find the information here: http://qa.drupal.org/
Agile method in software development
Agile method is nothing but building software with incremental or interactive work strategies known as sprits i.e building application by involving number of people or teams and push the work into public when considerable amount of work done. And can be able to roll back to any previous version of the application if found any thing wrong or unhappy with the new version of the appliction when some one or team push their work recently.
This approach is the better one when compare to waterfall, or traditional sequential development.In older days A project could be developed much like an automobile on an assembly line, in which each piece is added in sequential phases. This means that every phase of the project must be completed before the next phase can begin. Thus, developers first gather all of a project's requirements, then complete all of its architecture and design, then write all of the code, and so on.
In this scenario, If any thing went wrong in the development stage, can't revert it back and company has spent time and money to create a software that no one wants.
Whereas agile methodology helps a lot to the interactive development mode.
This approach is the better one when compare to waterfall, or traditional sequential development.In older days A project could be developed much like an automobile on an assembly line, in which each piece is added in sequential phases. This means that every phase of the project must be completed before the next phase can begin. Thus, developers first gather all of a project's requirements, then complete all of its architecture and design, then write all of the code, and so on.
In this scenario, If any thing went wrong in the development stage, can't revert it back and company has spent time and money to create a software that no one wants.
Whereas agile methodology helps a lot to the interactive development mode.
Build IPhone native appliactions with PHP or Ruby code
If you wanna develop IPhone native applications and don't have the time to learn completely new language i.e Objective - C, Now it is possible for the PHP and Ruby developers. By using one third party service you can write code in either PHP or Ruby and build native IPhone application also can use Html and CSS for UI Design.
You can download the source from here : http://www.appcelerator.com/
Other available tools to develop Iphone and wap applications.
You can download the source from here : http://www.appcelerator.com/
Other available tools to develop Iphone and wap applications.
Build smartphone applications using Rhodes framework
Hi Friends,
Today One of friend email me about the rhodes framework, I have gone through the rhodes framework, its an awesome framework by using this we can develop all smartphone native applications including iphone, android, blackberry etc.,
Have a look into http://rhomobile.com/products/rhodes/
Today One of friend email me about the rhodes framework, I have gone through the rhodes framework, its an awesome framework by using this we can develop all smartphone native applications including iphone, android, blackberry etc.,
Have a look into http://rhomobile.com/products/rhodes/
Tuesday, July 13, 2010
Phonegap for Iphone applications
Phonegap will lets you build a native mobile applications as a locally cached and privileged mobile website. You can leverage existing mobile site code for the native app. It will still be better than a pure website experience. It lets you piggyback on skill web developers already have. It is a great way to make use of HTML5 local DBs, local data, and HTML templates. It encourages you follow best practices for building a mobile site that works offline and requests only minimal JSON so it can fast over slow internet.
15 Frameworks and Dev Tools for Creating iPhone Apps
http://www.howtounlockiphone.org/15-mobile-frameworks-and-development-tools-for-creating-iphone-apps.html
15 Frameworks and Dev Tools for Creating iPhone Apps
http://www.howtounlockiphone.org/15-mobile-frameworks-and-development-tools-for-creating-iphone-apps.html
Thursday, July 8, 2010
CHAR Vs VARCHAR In Mysql
CHAR datatype used when you know the exact length of the value, ex: US Zipcodes (CHAR(7)), Mobile phone numbers (10 numbers only CHAR(10)) etc., And its length should be 0 to 255
VARCHAR datatype used in variable length inputs. Ex; User_firstname (VARCHAR(20)), street_address(VARCHAR(100)) etc.,
Its length should be 0 to 255 before Mysql 5.0.3 version, After 5.3.0 and later versions it should be 0 to 65,535.
See the example below:
Value CHAR(4) Storage Required VARCHAR(4) Storage Required
'' ' ' 4 bytes '' 1 byte
'ab' 'ab ' 4 bytes 'ab' 3 bytes
'abcd' 'abcd' 4 bytes 'abcd' 5 bytes
'abcdefgh' 'abcd' 4 bytes 'abcd' 5 bytes
VARCHAR datatype used in variable length inputs. Ex; User_firstname (VARCHAR(20)), street_address(VARCHAR(100)) etc.,
Its length should be 0 to 255 before Mysql 5.0.3 version, After 5.3.0 and later versions it should be 0 to 65,535.
See the example below:
Value CHAR(4) Storage Required VARCHAR(4) Storage Required
'' ' ' 4 bytes '' 1 byte
'ab' 'ab ' 4 bytes 'ab' 3 bytes
'abcd' 'abcd' 4 bytes 'abcd' 5 bytes
'abcdefgh' 'abcd' 4 bytes 'abcd' 5 bytes
Wednesday, July 7, 2010
Website optimization
Hi Friends,
Below urls are very useful for website optimization techniques.
http://www.fiftyfoureleven.com/weblog/web-development/css/css-sprites-images-optimization
http://www.peachpit.com/articles/article.aspx?p=447210
http://www.die.net/musings/page_load_time/
http://www.webdevelopment2.com/easily-increase-page-load-time-10-fold-jquery/
Below urls are very useful for website optimization techniques.
http://www.fiftyfoureleven.com/weblog/web-development/css/css-sprites-images-optimization
http://www.peachpit.com/articles/article.aspx?p=447210
http://www.die.net/musings/page_load_time/
http://www.webdevelopment2.com/easily-increase-page-load-time-10-fold-jquery/
CSS Sprites -
If your web page had lot of images and it will take more time to load all images then you should use one technique called "CSS Sprites" which will load all your common UI images in one request so that your page loads much faster than ever before.
Another technique is place the below tag in head section of your page
Another technique is place the below tag in head section of your page
Use Firebug and Yslow plugins for Firefox to know the performancd of the page load
Use Firebug for Firefox from a realistic net connection to see a graphical timeline of what it is doing during a page load. This shows where Firefox has to wait for one HTTP request to complete before starting the next one and how page load time increases with each object loaded. YSlow extends Firebug to offer tips on how to improve your site's performance
Subscribe to:
Posts (Atom)