Skip to content

Instantly share code, notes, and snippets.

@kolunar
kolunar / gist:40655ca5f5b8f0a7efcbdcb004183cc6
Created April 24, 2017 23:01
Enabling the MySQL slow query log
To enable the slow query log in MySQL, follow these steps:
1). Log in to your server using SSH.
2). At the command line, type the following command:
mysql -u root -p
3). Type the MySQL root password.
4). To enable the slow query log, type the following command at the mysql> prompt:
@kolunar
kolunar / gist:2fa22246694f94959d2e1a87969cb267
Last active April 24, 2017 23:01
Java Programming :: Declarations and Access Control
Ref: http://www.indiabix.com/java-programming/declarations-and-access-control/
Access modifiers dictate which classes, not which instances, may access features.
Methods and variables are collectively known as members. Method and variable members are given access control in exactly the same way.
private
makes a member accessible only from within its own class
protected
makes a member accessible only to classes in the same package or subclass of the class
@kolunar
kolunar / gist:919fdd8460ef53b6eb3bbbed5db08794
Created April 24, 2017 23:00
Procedures for publishing the source code to live production site online
+--------------------+
| Feature |
+--------------------+
Start a new feature
|- Development of new features starting from the 'develop' branch.
Finish up a feature
|- Finish the development of a feature.
|- Merges the feature branch into 'develop'
Command to display Memory usage, Disk Usage and CPU Load
========================================================
free -m | awk 'NR==2{printf "Memory Usage: %s/%sMB (%.2f%%)\n", $3,$2,$3*100/$2 }'
df -h | awk '$NF=="/"{printf "Disk Usage: %d/%dGB (%s)\n", $3,$2,$5}'
top -bn1 | grep load | awk '{printf "CPU Load: %.2f\n", $(NF-2)}'
# should also try monit
@kolunar
kolunar / gist:5670f0f0d21f2e3b21bb7117c7320cae
Created April 24, 2017 22:57
memcached installation on Ubuntu
Ubuntu-12-04
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-memcache-on-ubuntu-12-04
Ubuntu-14-04
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-memcache-on-ubuntu-14-04
Read More:
https://www.digitalocean.com/community/tags/caching?type=tutorials
=======================================================
@kolunar
kolunar / gist:f07aa6ac2752640db1efe0f619889220
Created April 24, 2017 22:57
MySQL Cloning the database using mysql-utilities' mysqldbcopy
mysqldbcopy is part of mysql-utilities.
apt-get install mysql-utilities (if not yet installed)
Usage: mysqldbcopy --source=user:pass@host:port:socket --destination=user:pass@host:port:socket orig_db:new_db
Example:
mysqldbcopy --source=user_name:password@localhost:3306 --destination=user_name:password@localhost:3306 mddb:mddb_demo
Working Example:
@kolunar
kolunar / gist:5ca43eeaa138c0486fe9b0beaacdff8c
Created April 24, 2017 22:57
Ubuntu open file limit for all users
When you see PHP Warning: something like
"failed to open stream: Too many open files in /var/www/...
You need to check open file limit as below:
$ ulimit -n
4096
Change the following lines in the file: /etc/security/limits.conf
* soft nofile 4096
* hard nofile 4096
@kolunar
kolunar / gist:aa9d645717afe74add0b6d408cb3bde3
Created April 24, 2017 22:55
Changing open file limit for all users on Ubuntu
First, check "$ ulimit -a".
Go to /etc/security/limits.conf and add the two lines described below:
* soft nofile 10240
* soft nproc 10240
Reboot system or add following line to the end of /etc/pam.d/common-session:
session required pam_limits.so
@kolunar
kolunar / gist:265620ed21fcca6eeb920b95bb5c2040
Created April 24, 2017 22:55
Creating and Enabling ftp user and access
1. mkdir /var/www/mydomain.com
2. mkdir /var/www/mydomain.com/html
3. useradd <-username>
4. passwd <-username>
5. chown –R <-username> /var/www/mydomain.com
5. groupadd <-groupname>
6. gpasswd -a <-username> <-groupname>
7. chgrp -R <-groupname> /var/www/mydomain.com
8. chmod -R g+rw /var/www/mydomain.com
@kolunar
kolunar / gist:3586a459e371d328f4d766d34c82782a
Created April 24, 2017 22:55
How To Set Up mod_rewrite for Apache on Ubuntu 14.04
Ref: https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite-for-apache-on-ubuntu-14-04
Ref: https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite
sudo a2enmod rewrite
sudo service apache2 restart
sudo nano /etc/apache2/sites-enabled/000-default.conf
Follow the instructions from the link given above