Friday, February 22, 2019

Git Bash

Git Bash
----------
- Git Clone project (Get the project into your local)
  git clone <git_url>
 
- Command will show the git master (origin)
    git branch

- Command will fetch everything from the master
    git fetch

- Checkout the branch / switch to existing branch
    git checkout <branch_name>

- Revert a single file (Complete revert like SVN)
   git checkout <file_name_includes_path>

 - Creating a new branch 'branch_name'
    git checkout -b <branch_name>   

- Merge specific commit id (Advantage it pushes the same commit version over new branch)
   git cherry-pick <218c4e40654a2d53fdaf3f1b47a58867f432b8ed>

- Changes which is in local and not in remote
   git log --branches --not --remotes

- Pull the changes into local from git
  git pull origin <branch_name>

- Hard reset from local cahanges
  git reset --hard HEAD^

- Unstagged a staged file
  git reset HEAD .

- Add .gitignore file
  touch .gitignore

- Push local changes file into staged
  git add <FileName>

- Commit the file into git (From unstagged to stagged)
  git commit -m 'commit message' <filename>

  - Push the changes into remote branch from local
  git push -u origin <branch_name>

- Show the differences in local
   git diff .

- Git stash of switching between branches (store the files temperoarty storage and switch to branch (new)). It will help you to store and switch between branches
  git stash

- Stashing untracked files (save)
$ git stash -u or $ git stash --include-untracked

- save specific file file specific messages. -u untracked files to push untracked files.
git stash push -u -m "<your message>" <filename_includes_path> [<filename_includes_path>]

- Git show the stash files
git stash show stash@{1}

- Git stash show the stash files diff
git stash show -p stash@{1}

- see the `git stash list` once you see choose and apply specific. --index will stage the file in the same location where you kept earlier
git stash apply stash@{1} --index 

- Popping your stash removes the changes from your stash and reapplies the last saved state
git stash pop

- Delete from git stash (storage) the latest
git stash drop [stash_id]

- Remove all from stash
git stash clear

How to Merge:
--------------
git checkout <working_branch>
git pull origin <working_branch>
git checkout <master_branch_source_branch>
git pull origin <master_branch_source_branch>
git merge <working_branch_which_you_want_to_merge_in_source>
    (Resolve the conflicts if any)
    vi <file_name>
git add <resolved_conflict_files>
git commit -m "" <resolved_conflict_files>
git push -u origin <master_branch_source_branch>


Monday, October 2, 2017

Export / Import Putty All Settings :


Open cmd.exe (Command prompt). Execute below command in command prompt
regedit /e "%USERPROFILE%\Desktop\putty.reg" HKEY_CURRENT_USER\Software\SimonTatham

In Desktop you will see putty.reg (Exported)

To Import putty settings
Double-click on the *.reg file and accept the import.

Or from command prompt execute below command : 
regedit /i putty.reg

Thursday, September 21, 2017

Apache Configuration with Proxy in RHEL 7 / CentOS 7

Apache Web Server (httpd) in RHEL and CentOS are similar.

$ yum install httpd mod_proxy mod_ssl mod_proxy_html mod_rewrite  -y

httpd : httpd daemon install http server (web) apache
mod_proxy : This library usually comes by default. This helps for proxy setup (Forward / reverse) 
mod_ssl : This library helps for HTTPS connection support in mod_proxy (proxy) to do for HTTPS as well
mod_proxy_html : This library supports for rewrite rule to support html, images and other content loading in apache
mod_rewrite : This library helps for rewrite rule in apache configuration.

$ grep 'mod_proxy' /etc/httpd/conf.modules.d/00-proxy.conf

Above command will show you already the mod proxy libaries loaded (LoadModule) in apache (httpd) and in the same configuration you will see for ssl (LoadModule configuration) in different *.conf

In order for apache to achieve forward and reverse proxy create below configuration. 

Create reverse-proxy.conf file or your own file naming file and have the below configuration.

$ vi /etc/httpd/conf.d/reverse-proxy.conf

        # Below fields helps on forward proxy request and proxy time out
        ProxyRequests On
        ProxyVia On
        ProxyTimeout 60
# Below field helps to turn on HTTPS configurations (reverse / forward)
        SSLProxyEngine On

# Proxy servers permissions
       
                Require all granted
       

# Specify Forward proxy remote servers
        ProxyRemote "http" "http://proxy.ebiz.abccompany.com:80"
        ProxyRemote "https" "http://proxy.ebiz.abccompany.com:80"
# Specify no proxy servers
        NoProxy ".abccompany.com"

# Reverse proxy urls and connectiontimeout happens when there is no response from the url
        ProxyPass /foo http://www.webreference.com/html/tutorial2/2.html connectiontimeout=5
        ProxyPassReverse /foo http://www.webreference.com/html/tutorial2/2.html

        ProxyPass /bar https://vzweb2.abccompany.com connectiontimeout=5
        ProxyPassReverse /bar https://vzweb2.abccompany.com

        ProxyPass /geek https://www.ssllabs.com/ connectiontimeout=5
        ProxyPassReverse /geek https://www.ssllabs.com/


Restart 'service httpd restart' after configuration changes. 

You can add environment variables in file '/etc/sysconfig/httpd' if required.

Test it with :        curl http://localhost/foo

Best Article to know about forward-reverse proxy :
https://geekpeek.net/forward-reverse-apache-proxy-centos/ (The best forward and reverse proxy)

Reverse proxy well explained video link : https://www.youtube.com/watch?v=MQMIhAbPzb4

Saturday, July 22, 2017

AWS Tutorial: How to quickly set up an SSL certificate for use with Amazon Web Services ELB


View Java keystore information with "keytool list"
keytool -list -v -keystore privateKey.store

keytool executable comes in JDK/bin. You must configure $JAVA_HOME/bin in $PATH to use the command. Check the CN (CommonName) 

Article about Certificates Extensions and Encodings : http://info.ssl.com/article.aspx?id=12149

PKCS7 Decoder

Installing a SSL certificate on Amazon Web Services (AWS)

Use AWS Certificate Manager to upload SSL certificate (Import).
Certificate body : Provide the public certificate (PEM) provided by ssl team by converting .cer to pem
Certificate private key : Provide the private key (PEM) you used to generate CSR file
Certificate Chain : Provide the intermediate and Root certificate (PEM)

In order to verify the healthy of the file and port in https://

In order to verify the healthy of the file and port in http://

You also need to create keystore file and drop in tomcat 8443 port by combining keys.

Wednesday, July 19, 2017

Step by step instructions on self-signed certificate and configure Tomcat over SSL

Note : If you create self signed certificate from openssl then create keystore file also using openssl

1.1 Create a pair of PKI keys

openssl genrsa -out public-dns-name-private.pem 2048

Create a self-signed X509 certificate:

openssl req -new -x509 -key public-dns-name-private.pem -out public-dns-name-certificate.pem -days 365

Create a PKCS12 keystore and import (or export depending on how you look at it) the host certificate we just created:

openssl pkcs12 -export -out humkeystore.pkcs12 -in public-dns-name-certificate.pem -inkey public-dns-name-private.pem

2.2 Convert the PKCS12 keystore to Java keystore using Java keytool.

keytool -importkeystore -srckeystore humkeystore.pkcs12 -srcstoretype PKCS12 -destkeystore humkeystore -deststoretype JKS

Update Tomcat : In $CATALINA_HOME/CONF/server.xml


In Amazon Alexa Skill : "I will upload a self-signed certificate in X.509 format" open generated x509 certificate file and provide content : public-dns-name-certificate.pem


AWS Account Migration - Steps for some of the services to migrate from one AWS Account to other

1) Login into AWS account and go to BillingDashboard and find out list of services used.  

Note : There will be charge either 0$ or x$ for used services.

2) Go to VPC dashboard and understand VPC (custom), ElasticIps, Security Group, subnets and create the same in another account (target account you want to migrate)



Note : Only manual snapshot backup can be shared and restored.


Note : aws s3 sync s3://sourceBucket  s3://DestinationBucket  --profile AccountAAdmin --profile AccountBAdmin 
Please make sure the destinationBucket name is different as its unique. Sometimes we try to provide same assuming copy. 



6) ELB : Create LoadBalancer target Group and other details in new account from the existing account. 

7) Lambda, Lex, elasticBeanStack you need to configure the same in new account and copy the code from the old aws account.

Wednesday, February 22, 2017

Amazon - Alexa - Tips to start your own Skill Kit

Why Alexa ?

Alexa, the voice service that powers Echo, provides capabilities, or skills, that enable customers to interact with devices in a more intuitive way using voice. (Coolest IoT as well to integrate with lights and thermostat control through Amazon Echo)

Examples of these skills include the ability to play music, answer general questions, set an alarm or timer and more. Alexa is built in the cloud, so it is always getting smarter.

Official Amazon Pages about
Alexa : https://developer.amazon.com/alexa
Alexa Skill Kit : https://developer.amazon.com/alexa-skills-kit

Alexa Skill Kit (ASK) develop in an hour quick tour to get your hands dirty (JS) - Note : Alexa Skill Interaction Model creation was not updating in IE. Better use firefox / chrome.
6 Steps to build first Alexa Skill : https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/content/fact-skill-1

Steps Detailed to develop : https://developer.amazon.com/blogs/post/Tx3DVGG0K0TPUGQ/New-Alexa-Skills-Kit-Template:-Step-by-Step-Guide-to-Build-a-Fact-Skill

Alexa Skill kit Samples : https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/using-the-alexa-skills-kit-samples

Alexa Web Browser Testing tool (Works only in webRTC (RTC-RealTimeCommunication Browser)) : https://echosim.io/welcome?next=%2F

Alexa Skill Kit (ASK) forum : https://forums.developer.amazon.com/spaces/23/index.html

ASK Certification Requirements for Custom Skills : https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-submission-checklist

ASK custom skill using Web-Service - https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/deploying-a-sample-skill-as-a-web-service

Amazon 10 Minutes tutorial (Try tutorials in AWS) - https://aws.amazon.com/getting-started/tutorials/

Social Pages (YouTube) about Alexa to watch and learn :

ASK 101 by Amazon Developer : https://www.youtube.com/watch?v=31K4vse9Jmc

ASK Custom skill easy implementation step in more understandable with intents and slots includes nice examples and github sourceCode reference: https://www.youtube.com/watch?v=zt9WdE5kR6g&t=1s

Developing Alexa Skill (Explained in 1 to 6 chapter in more detail) : https://www.youtube.com/watch?v=QxgdPI1B7rg&list=PL2KJmkHeYQTO6ci5KF08mvHYdAZu2jgkJ


Find your icon for your custom app : https://www.iconfinder.com/icons/10930/badge_reddit_icon#size=128

In MSPaint open the image 512 and click -> re-size and re-size the image to size you need.

// Below script tag for SyntaxHighLighter