Git tagging

List available tags:

$ git tag
$ git tag -l <tag name>

Creating tags:

$ git tag -a <tag name> -m <comment>

Show tag data:

$ git show <tab name>

Sharing Tags:

$ git push origin <tag name>
$ git push origin --tags  // share all tags

Checking out tags:

$ git checkout -b <branchname> <tag name>

Web-Based Guacamole tool

Guacamole website:

Create database for Guacamole: (DB name is guacamole_db)

$ mysql -u root -p

mysql> create database guacamole_db;
mysql> grant all privileges on guacamole_db.* to guacamole_user@localhost identified by 'secure password';
mysql> flush  privileges;

Initializing the MySQL database

$ docker run --rm guacamole/guacamole /opt/guacamole/bin/ --mysql > initdb.sql

$ mysql -u guacamole_user -p guacamole_db < initdb.sql

Create my-guacd docker container

$ docker run --name my-guacd -d guacamole/guacd

Create my-guacamole docker container

docker run --name my-guacamole \
  --link my-guacd:guacd \
  -d -p 8080:8080 guacamole/guacamole


http://<server ip>:8080/guacamole/


$ docker logs my-guacamole

Behind apache proxy:

<Location /guacamole/>
    Order allow,deny
    Allow from all
    ProxyPass http://HOSTNAME:8080/guacamole/ flushpackets=on
    ProxyPassReverse http://HOSTNAME:8080/guacamole/

<Location /guacamole/websocket-tunnel>
    Order allow,deny
    Allow from all
    ProxyPass ws://HOSTNAME:8080/guacamole/websocket-tunnel
    ProxyPassReverse ws://HOSTNAME:8080/guacamole/websocket-tunnel

SMTP setting for Drupal, Django, and WordPress

Drupal, Django, and WordPress are using localhost as SMTP server by default. But there is a way to use another SMTP server to send email.

Drupal security modules

Base security modules for drupal:

  1. Login security
  2. Password policy
  3. Update manager
  4. Captcha
  5. Flood Control
  6. Secure Pages Hijack Prevention
  7. XFS (cross frame scripting)
  8. Idle Session Timeout
  9. Concurrent Sessions
  10. ACL
  11. Two-factor Authentication (TFA)
  12. Paranoia
  13. Coder
  14. Security Review
  15. SpamSpan filter


Change django administration title

There are two ways to change them.

  1. Create //templates/admin/base_site.html file with the following content

    {% extends "admin/base.html" %}
    {% block title %}{{ title }} | Your website title here {% endblock %}
    {% block branding %}
    <h1 id="site-name">
        <a href="{% url 'admin:index' %}">Your website title here</a>
    {% endblock %}

    The original file is

  2. Change and

    $ vi
    ADMIN_SITE_HEADER = "My shiny new administration"
    $ vi
    from django.conf import settings
    ... = settings.ADMIN_SITE_HEADER = settings.ADMIN_SITE_HEADER


Using pyenv on Ubuntu

Installing pyenv

$ sudo apt-get install -y --fix-missing make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils
$ git clone ~/.pyenv
$ git clone ~/.pyenv/plugins/pyenv-virtualenv
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
$ . ~/.bash_profile

Installing python

$ pyenv install 3.5.2

Setting python version

$ pyenv versions
$ pyenv global system
$ pyenv global 3.5.2
$ pyenv global
$ pyenv local
$ pyenv local 3.5.2

Using virtualenv

$ pyenv virtualenv 3.5.2 venv
$ pyenv activate venv
$ pyenv deactivate venv

Checking python version

$ python -V

Install nodejs on ubuntu

Installing nodejs

sudo apt install nodejs
sudo apt-get install npm

Installing pm2

sudo npm install pm2@latest -g
cd /usr/bin
sudo ln -s nodejs node

Create user to run nodejs

sudo useradd nodeuser
sudo passwd nodeuser
sudo addgroup nodejs
sudo adduser nodeuser nodejs

Using pm2 to start nodejs app

pm2 start hello.js

Using pm2 to autostart nodejs apps

sudo env PATH=$PATH:/usr/local/bin pm2 startup -u nodeuser
sudo su -c "chmod +x /etc/init.d/ && update-rc.d defaults"
pm2 save

Install java on ubuntu

Installing default jre/jdk

sudo apt update
sudo apt install default-jre
sudo apt install default-jdk

Installing openjre/jdk 7

sudo apt-get install openjdk-7-jre 
sudo apt-get install openjdk-7-jdk

Installing Oracle java

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

sudo apt-get install oracle-java6-installer

sudo apt-get install oracle-java7-installer

sudo apt-get install oracle-java8-installer

Managing java

sudo update-alternatives --config java
sudo update-alternatives --config javac


sudo vi /etc/environment