.htaccess Redirect all request to index file

Redirect all request to index.php using .htaccess file. 

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php?$1 [L]

URI value after root folder will be set as SCRIPT_URI OR QUERY_STRING.

Tags: Rewrite, Htaccess

How to connect GitHub from Linux using private key

  1. Login to ternimal 
  2. Create ssh public key using the following command 
    ssh-keygen -t rsa -b 4096 -C ""
    Will ask for id.rsa file number. jus hit enter.
    Next will ask for passphrase, If you need to secure you git repository provide a phrase. Otherwise just hit enter. (remember it, will ask every time when you try to commit and push the code)
  3. ~/.ssh/id_rsa.pub file is created in your user home directory.
  4. using vi ~/.ssh/id_rsa.pub or gedit ~/.ssh/id_rsa.pub edit it and copy the content of the file.
  5. Login in to https://github.com/
  6. Select your repository => "Settings" in top menu.=> Click "Deploy keys"
  7. Input "Title" for your reference, paste the copied key in to "Key" textarea.
  8. It will ask you to confirm you account password.
    Now your are ready to connect to you repository.
  9. Now create a folder and using "git clone https://github.com/account/project.git" command.

During git push it will ask for passphrase, If you provided during the private key generation.(@Step 2)

Tags: Linux, GitHub, SSH Private Key, GIT

Useful GIT commands

Here are the list of major git commands and their short descriptions.

git init

    Initializes a git repository – creates the initial ‘.git’ directory in a new or for an existing project.

git config

    Configure git with username,  password, email-id, and server details. It can be configured --global / --system / --local

git clone

    Download a copy of project from GIT server (Eg: git clone https://github.com/account/project.git)

git add

    Add the files to local repository. Eg: git add file.txt / git add . - remove all changed files.

git rm

    Remove files from local repository. Eg: git rm file.txt / git rm . - remove all changed files.

git commit

    Save the added files to local repository, creates a new commit object pointing to it and sets the branch to point to that        new commit. Eg: git commit -m ‘committing added changes’ git commit -a -m ‘committing all changes, equals to git add      and git commit’

git status

    Show the current status of changes. Changed not add/commited/push to local.

git branch

    Show the list of local branches. In the output it will highlight the current active branch.

git push

    Push the commited changes from local repository to GIT server. Need to authenticate using username/password if it's       a private.

git checkout

    Switch for one branch to another. need to mention the branch name. Eg: git branch

git pull

    Fetches the files from the remote repository and merges it with your local one. This command is equal to the git fetch        and the git merge sequence. Example: git pull origin.

git diff

    Generates patch files or statistics of differences between paths or files in your git repository, or your index or your              working directory. Example: git diff

Tags: GIT Commands, GIT

What is Gradle

Gradle is an open source build automation system that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-specific language (DSL) instead of the XML form used by Apache Maven for declaring the project configuration.

Gradle build consists of one or more projects. Projects can be something which should be built or something that should be done. Each project consists of tasks. A task represents a piece of work which a build performs, e.g., compile the source code or generate the Javadoc.

Unlike Apache Maven, which defines lifecycles, and Apache Ant, where targets are invoked based upon a depends-on partial ordering, Gradle utilizes a directed acyclic graph ("DAG") to determine the order in which tasks can be run.

Build Anything

Write in Java, C++, Python or your language of choice. Package for deployment on any platform. Go monorepo or multi-repo. And rely on Gradle's unparalleled versatility to build it all.

Scale out development with elegant, blazing-fast builds. From compile avoidance to advanced caching and beyond, we pursue performance relentlessly so your team can deliver continuously.

Tags: Gradle, Built Automation

See the Brightest Supermoon of 2017

On the night of December 3 2017, sky-watchers around the world will get a chance to revel under the first—and last—full supermoon of the year.

This December 2017 full moon officially occurs at 9:17 p.m. IST (15:47 UT) on the 3rd. Less than a day later, the lunar orb will make its closest approach to Earth for the month, coming within 222,443 miles of our planet at 3:30 p.m. ET (9:00 UT) on the 4th. That means the moon on the day of December 4 will appear about seven percent larger and 16 percent brighter than usual.

A supermoon is the popular term for a full or new moon that coincides with the lunar orb making an especially close approach to Earth. The moon’s orbit around Earth is not a perfect circle but is somewhat elongated. That means the moon changes its distance to Earth by a few thousand miles over time, reaching a closest point (perigee) and a farthest point (apogee) in any given month.

Technically, this will be the fourth supermoon of the year, but it’s the only one we’ve been able to see with naked eyes. That’s because the other three supermoons of 2017 coincided with new moons, when the lunar disk shows a totally darkened face.

Courtesy: NGC

Tags: SuperMoon, Moon

Linux find which process is using which port

Below commands can be used to find what are the ports currently used and associated process.

$ netstat -ant

Which tells the list of ports currently used by the system

$ lsof -i:8080

Above command lists the process name with details which uses the port 8080. Also shows process id PID and in which user the process is running.

 $ fuser 80/tcp

Also can find the process/service listening on a particular port by running the command below (specify the port).

Tags: Linux, Networking Commands

Find External or Internet IP address from Linux and Windows

Find External/Public IP Address using windows

From windows command prompt you can find the internet address of your system or modem address using the following command.

C:\>nslookup myip.opendns.com resolver1.opendns.com
           Server:  resolver1.opendns.com
           Address:  xxx.xxx.xxx.xxx
           Non-authoritative answer:
           Name:    myip.opendns.com
           Address:  xxx.xxx.xxx.xxx

Above command output two ipv4 address. Address shown for myip.opendns.com highlighted will be you external ip or internet/modem ip address.

Find External/Public IP Address using Linux

In linux it can be find using dig command. It will output lost of information. Can be filtered using +shot options.

:~$ dig +short myip.opendns.com @resolver1.opendns.com

Command ouptus the your external internet IP address.

Tags: Nslookup, Dig, Public IPv4

Use full Linux commands

Here are some of Linux usefull general commands

View all Environment variables

env command can be used to view all enviroment variable and its value for current logged user via terminal.

ubuntu@ip-xx-xx-xx-xx:~/maven/JavaProj$ env
SSH_CLIENT= 54904 22

Set Environment Variables on Linux

You can modify each environmental or system variable using the export command. Set the PATH environment variable to include the directory where you installed the bin directory with perl and shell scripts:

export ANT_HOME=/path/to/ant/dir
export PATH=${PATH}:${ANT_HOME}/bin:${JAVA_HOME}/bin

Above command will set value for variable ANT_HOME and append it to PATH

Unset a environment variable

Enviroment variable can be removed from current user environment dynamically without any reboot and affecting other user or same user any other environment using unset command as follows

unset ANT_HOME

Above command remove the ANT_HOME variable and it's value from current user enviroment without affecting same user other enviroment.

View verbose output for git command

Normal git command will not show the output of communication performed with GIT server while executing clone/pull/push command. To view the output of full culr response header value, we need to set the verbose output as true while executing every git command as follows.

GIT_CURL_VERBOSE=1 git clone

command will output the request and response for curl command performand by git command.

ubuntu@ip-xxx-xx-xx-xxx:~/maven/JavaProj$ GIT_CURL_VERBOSE=1 git pull
* Couldn't find host git-codecommit.us-east-1.amazonaws.com in the .netrc file; using defaults
*   Trying
* Connected to git-codecommit.us-east-1.amazonaws.com ( port 443 (#0)
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 596 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_CBC_SHA1
*        server certificate verification OK
*        server certificate status verification SKIPPED
*        common name: git-codecommit.us-east-1.amazonaws.com (matched)
*        server certificate expiration date OK
*        server certificate activation date OK
*        certificate public key: RSA
*        certificate version: #3
*        subject: CN=git-codecommit.us-east-1.amazonaws.com
*        start date: Thu, 14 Dec 2017 00:00:00 GMT
*        expire date: Fri, 14 Dec 2018 12:00:00 GMT
*        issuer: C=US,O=Amazon,OU=Server CA 1B,CN=Amazon
*        compression: NULL
* ALPN, server did not agree to a protocol
> GET /v1/repos/PHPWordPress/info/refs?service=git-upload-pack HTTP/1.1
Host: git-codecommit.us-east-1.amazonaws.com
User-Agent: git/2.7.4
Accept: */*
Accept-Encoding: gzip
Accept-Language: en-US, *;q=0.9
Pragma: no-cache
< HTTP/1.1 401 Unauthorized



Tags: GIT, CURL, Env, Export