Monday, September 3, 2012

how to use timestamp data type in more than two columns in mysql

If you use phpmyadmin and want to have two columns that hold timestamp fields, it will give you an error. We can't add more then one field as timestamp value.
Sometime, we have created_at and updated_at fields which might be timestamp column. To add these two columns as timestamp, we have alter table structure and run the following sql command:
ALTER TABLE customer_info CHANGE created_at created_at TIMESTAMP NOT NULL DEFAULT 0,
CHANGE  `updated_at`  `updated_at` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL;

At first, we set the default value of the first timestamp column as zero and set the current timestamp on second timestamp column.

See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Friday, August 10, 2012

.gitignore file not working

I have created a file to ignore some specific files and folders with git. I have created the following file:

abc
abc/*
xyx
xyx/*

When I try to add files with the below command:

git add *

I got the error 'no files added'.
Then I run:

git rm -r --cached .

This removes everything from the cache. Now I run the command:

git add .

Now it will add the files. So, I can commit the changes.
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Wednesday, July 18, 2012

how to create git branch

To see the existing list of branches on the local machine, run the below command:

git branch

To create a new branch, use this:
git checkout -b new_branch

This is a shorthand for:
git branch new_branch
git checkout new_branch

To delete a branch from local machine:
git branch -D new_branch

See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Tuesday, July 17, 2012

Get the list of cookies in iOS phonegap

To get the list of cookies stored into our iPhone, we use below code block:

NSArray *cookieArray;
cookieArray = [cookieStorage cookies];
NSInteger numcookies = [cookieArray count]; 
NSLog(@"cookies count:%d", numcookies); 

for (NSHTTPCookie *each in [cookieStorage cookies]) {
    NSLog(@"\nCOOKIE Name: %@, Value:%@, Expires At: %@\n", [each name], [each value], [each expiresDate]); 
    }


Cookies are stored into the NSHTTPCookieStorage. From that storage, we get each one using NSHTTPCookie object. each object has name, value and expireDate attributes.


See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Monday, July 16, 2012

Password protected directory

We work with test and staging server. But we don't want others to access the website. We can stop access for unauthorized users by using passwd feature. First, we create a user/password pair with the passwd command.

htpasswd -c /home/pwww/.htpasswd jerry


Then we create a .htaccess file on the same level where our directory is located that we want to be protected. We placed the below code block in the file:

AuthUserFile /home/pwww/.htpasswd
AuthGroupFile /dev/null
AuthName EnterPassword
AuthType Basic
require user jerry


Then try to reload your directory access using browser. You will get a window asking for authentication.


See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Thursday, July 12, 2012

iptables configuration

We can set several different configuration values for the iptables.
To flush the current rules we run the below command:
sudo /sbin/iptables -F

To accept a certain port, run the below:
sudo /sbin/iptables -A INPUT -i eth0 -p tcp -m tcp --dport 30000 -j ACCEPT

To accept certain state, run the below:
sudo /sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

We rejected all incoming and forwarded requests:
sudo /sbin/iptables -A INPUT -j REJECT
sudo /sbin/iptables -A FORWARD -j REJECT

Now accept all outgoing and selected incoming request:
sudo /sbin/iptables -A OUTPUT -j ACCEPT
sudo /sbin/iptables -I INPUT -i lo -j ACCEPT

Reject all incoming loop requests
sudo /sbin/iptables -I INPUT ! -i lo -d 127.0.0.0/8 -j REJECT

It displays the existing rules with line numbers
sudo /sbin/iptables -L --line-numbers

We accept HTTP and HTTPS requests.
sudo /sbin/iptables -I INPUT 3 -p icmp -m icmp --icmp-type 8 -j ACCEPT
sudo /sbin/iptables -I INPUT 5 -p tcp --dport 80 -j ACCEPT 
sudo /sbin/iptables -I INPUT 5 -p tcp --dport 443 -j ACCEPT

We enable the logging features of iptables.
sudo /sbin/iptables -I INPUT 8 -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
To save an existing rules table, use the below commands:
sudo sh -c '/sbin/iptables-save > /etc/iptables.save'


See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

How to install fail2ban

We can install fail2ban quite easily in ubuntu. Just install it from aptitude.
sudo apt-get install fail2ban

We make a local copy for the configuration file.
 
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

In the configuration file, we can change several different options as per our need. Like below:
enabled = true
port    = ssh
filter  = sshd
logpath  = /var/log/auth.log
maxretry = 5

We enable the fail2ban for a specific section by setting enable to true. After changing the configuration, we restart fail2ban.
sudo /etc/init.d/fail2ban restart

See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

How to Change Git user

If you want to change the git user credentials in a machine, Then following the below steps.
First, go to the .ssh folder under your user directory.
cd ~/.ssh

We create a folder to backup your existing keys.
mkdir key_backup

And then copy those keys to the backup folder.
cp id_rsa* key_backup

And delete the old keys
rm id_rsa*

Now we create the new keys for our email address.
ssh-keygen -t rsa -C "your_email@youremail.com"

See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

How to install sqlitebrowser

To view sqlite data, we can use the sqlitebrowser from aptitude. The installation command is pretty simple, same as other plugin installation. Just run the following command:
sudo apt-get install sqlitebrowser


See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Error with Frontaccounting branch creation

I was trying to create sales report for a customer with the frontaccounting software. But I was facing the following error with the system:
The selected customer and branch are not valid, or the customer does not have any branches.

After googleing the problem, I found that I need to set the default_location value to DEF in the cust_branch table.
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide