OpenShift: Error 503 – Service Temporarily Unavailable

Tags

When you try to execute the git push command and the deployment status is SUCCESS. However the open shift return an error 503 – Service Temporarily Unavailable

artheman@localmachine /home/mywebappblog (master) $ git push origin master
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 341 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
remote: CLIENT_MESSAGE: Stopping Node.js application...
remote: CLIENT_RESULT: Node.js application stopped.
remote: Building git ref 'master', commit 63efa24
remote: CLIENT_RESULT: Node.js modules installed.
remote: Preparing build for deployment
remote: Deployment id is 291b0274
remote: Activating deployment
remote: CLIENT_MESSAGE: Starting Node.js application...
remote: CLIENT_RESULT: Node.js application started.
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success
To ssh://123456789@mywebappblog.rhcloud.com/~/git/mywebappblog.git/
   7783eb5..63efa24  master -> master

When accessing the website https://mywebappblog-myaccount.rhcloud.com I got this error Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Solution:
In Express.JS, to fix it make sure that your app properly listen to the correct Port number and IP address. Use process.env.OPENSHIFT_NODEJS_PORT and process.env.OPENSHIFT_NODEJS_IP

/**
 * Get port from environment and store in Express.
 */
var port = process.env.OPENSHIFT_NODEJS_PORT || 4010;
port = normalizePort(port);
var ip = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';
app.set('port', port);

var server = http.createServer(app);
server.listen(port, ip); ## Here we assigned the OPENSHIFT_NODEJS_PORT and OPENSHIFT_NODEJS_IP variables.
server.on('error', onError);
server.on('listening', onListening);
...
...

That’s it.. it should be working now.

OpenShift: Install rhc client tools on Windows

Tags

Step1. Install Ruby
Step2. Install Git
Step3. Install rhc – a Ruby gem

Step1. Install Ruby
* Download Ruby installer for windows at https://rubyinstaller.org/

Step2. Install Git
* Download the Git for windows and install it to your local machine – https://git-for-windows.github.io/

Step3. Install rhc – a Ruby gem

$ gem install rhc
Successfully installed net-ssh-4.1.0
Successfully installed net-scp-1.2.1
Successfully installed net-ssh-gateway-2.0.0
Successfully installed net-ssh-multi-1.2.1
The `minitar` executable is no longer bundled with `minitar`. If you are
expecting this executable, make sure you also install `minitar-cli`.
Successfully installed minitar-0.6.1
Successfully installed powerbar-1.0.18
Successfully installed minitar-cli-0.6.1
'archive-tar-minitar' has been deprecated; just install 'minitar'.
Successfully installed archive-tar-minitar-0.6.1
Successfully installed highline-1.6.21
Successfully installed commander-4.2.1
Successfully installed httpclient-2.6.0.1
Successfully installed open4-1.3.4
===========================================================================
If this is your first time installing the RHC tools, please run 'rhc setup'
===========================================================================
Successfully installed rhc-1.38.7
13 gems installed

Once you installed the rhc gem, you’ll change directory to your root app then execute this command:

$ rhc setup
OpenShift Client Tools (RHC) Setup Wizard
This wizard will help you upload your SSH keys, set your application namespace, and check that other programs like Git are properly installed.
If you have your own OpenShift server, you can specify it now. Just hit enter to use the server for OpenShift Online: openshift.redhat.com.

Enter the server hostname: |openshift.redhat.com|
You can add more servers later using 'rhc server'.
Login to openshift.redhat.com: myemail@gmail.com
Password: **********

OpenShift can create and store a token on disk which allows to you to access the server without using your password. The key is stored in your home directory
and should be kept secret.  You can delete the key at any time by running 'rhc logout'.
Generate a token now? (yes|no) yes
Generating an authorization token for this client ... lasts about 1 month

Saving configuration to C:\Users\ADMIN\.openshift\express.conf ... done

No SSH keys were found. We will generate a pair of keys for you.

    Created: C:/Users/ADMIN/.ssh/id_rsa.pub

Your public SSH key must be uploaded to the OpenShift server to access code.  Upload now? (yes|no) no

You can upload your public SSH key at a later time using the 'rhc sshkey' command

In order to fully interact with OpenShift you will need to install and configure a git client if you have not already done so. Documentation for installing
other tools you will need for OpenShift can be found at https://www.openshift.com/developers/install-the-client-tools

We recommend these free applications:

  * Git for Windows - a basic git command line and GUI client http://msysgit.github.io/
  * TortoiseGit - git client that integrates into the file explorer http://code.google.com/p/tortoisegit/
 Checking common problems

Your private SSH key file should be set as readable only to yourself.  Please run 'chmod 600 C:\Users\ADMIN\.ssh\id_rsa'

Checking for a domain ... sudogem
Checking for applications ... found 1

  nodeexpressjsblogv1 http://nodeexpressjsblogv1-sudogem.rhcloud.com/

  You are using 1 of 3 total gears
  The following gear sizes are available to you: small

Your client tools are now configured.

That’s it!!

References:
https://developers.openshift.com/getting-started/windows.html

Rails: Omniauth-oauth2 gem for Linkedin, Twitter, Facebook is not working

Tags

, ,

If you’re using a Devise gem and the latest Omniauth Oauth2(1.4.0) for authentication chances are you may encounter an errors below:

Facebook:
ERROR — omniauth: (facebook) Authentication failure! invalid_credentials: >OAuth2::Error, : {“error”:{“message”:”Error validating verification code. Please make sure your >redirect_uri is identical to the one you used in the OAuth dialog request”,”type”:”OAuthException”,”code”:100,”fbtrace_id”:”XXXXXXXXXX”}}

LinkedIn:
ERROR — omniauth: (linkedin) Authentication failure! invalid_credentials: >OAuth2::Error, invalid_request: missing required parameters, includes an invalid parameter value, parameter more than once. : Unable to retrieve access token : appId or redirect uri does not match authorization code or authorization code expired {“error_description”:”missing required parameters, includes an invalid parameter value, parameter more than once. : Unable to retrieve access token : appId or redirect uri does not match authorization code or authorization code expired”,”error”:”invalid_request”}

Google
ERROR — omniauth: (google_oauth2) Authentication failure! invalid_credentials: >OAuth2::Error, redirect_uri_mismatch: { “error” : “redirect_uri_mismatch” }

Solution:
We need to update the Gemfile and add this line:
gem ‘omniauth-oauth2’, ‘~> 1.3.1’.
Then run the command: bundle update

How to display environment variables in a terminal ?

Tags

, , , , ,

How to display environment or system variables in your terminal ?
For Linux:
$ printenv – Print all or part of environment.
$ env – Print all exported environment or run a program in a modified environment.

For Windows:
$ SET
$ SET | more

Display PATH variables
$ PATH
======================================
How to display Rubygems variables ?
$ gem env

Rails: Specified ‘mysql2’ for database adapter, but the gem is not loaded. Add `gem ‘mysql2’` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

Tags

If you’ve encounter an error like this:

$ bundle exec rake db:create db:migrate
Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:174:in `spec'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:50:in `establish_connection'
C:in `establish_connection'

Solution:
Add this line in your Gemfile
gem ‘mysql2’, ‘~> 0.3.20’

App environments that the error above will occured:
ruby -v: ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]
mysql -v: mysql Ver 14.14 Distrib 5.7.16, for Win64 (x86_64)

Bluemix commands

Tags

## Set or view target api url 
$ cf api https://api.ng.bluemix.net

## Log user in
$ cf login -u armando@gmail.com
$ cf login -u armando@gmail.com -s rails-space
$ cf login -u armando@gmail.com -o "MobileOrgs" -s "rails_space"
$ cf login -u armando@gmail.com -o "MIT" -s "node_space"

## Log user out
$ cf logout

## target - Set or view the targeted org or space 
## e.g. switch to space "rails_space" from MIT organization
$ cf target -o "MIT" -s "rails_space"
$ cf target -s "my_space"
$ cf target -o "my_org"

## logs - Tail or show recent logs for an app 
$ cf logs myrailsapp

## rename - Rename an app 
$ cf rename myrailsapp railsapp-cloudant-stage

##  map-route - Add a url route to an app 
$ cf map-route myrailsapp example.com   # example.com

## unmap-route - Remove a url route from an app 
$ cf unmap-route myrailsapp example.com   # example.com

## set-env - Set an env variable for an app
$ cf set-env myrailsapp mongoURL "mongodb://username:password@xxxx.xxx.com"

## start - Start an app
$ cf start|stop|restart APP_NAME

More info at http://cli.cloudfoundry.org/en-US/cf/

Git: Basic commands(deprecated)

Tags

How to add and commit a
add & commit
You can propose changes (add it to the Index) using
git add {filename} or git add .
git commit -am “Commit message”
Now the file is committed to the HEAD, but not in your remote repository yet.

————————————————————————————
Pushing changes
Your changes are now in the HEAD of your local working copy. To send those changes to your remote repository,
execute: git push origin master

git fetch origin
git diff master origin/master
git merge origin/master
————————————————————————————
Comparing two files
git diff HEAD {filename}
————————————————————————————
Check if your current branch has any updates from remote
git remote show origin
————————————————————————————
In my local dev,
git add filename
git push origin master
git remote show origin

In server02,
git remote show origin
simply execute: git pull
or
git fetch origin
git reset –hard origin/master

The third options is to discard the local changes using: git reset –hard
————————————————————————————
List remote branches
git ls-remote ssh://git@mysite.com/myapp.git OR SIMPLE git ls-remote in your current git repo
output:
2be5142f0e05b495a7708dad41e9fbff0096308a HEAD
bfb71abf9e00224e27166b27b28d49d747facd2d refs/heads/develop
e2be5142f0e05b495a7708dad41e9fbff0096308 refs/heads/master

Or like this:
$ git branch -r
output:
origin/HEAD -> origin/master
origin/master
————————————————————————————
How to update your master branch ?
$ git branch
* no branch
master
so, need ta mo switch sa master branch para makuha ang updated source files
$ git checkout master
Switched to branch ‘master’
Your branch is behind ‘origin/master’ by 1 commit, and can be fast-forwarded.

$ git remote show origin
* remote origin
Fetch URL: ssh://git@mycompany.com/httphelper.git
Push URL: ssh://git@mycompany.com/httphelper.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for ‘git pull’:
master merges with remote master
Local ref configured for ‘git push’:
master pushes to master (local out of date)

if it is out of date then execute git pull in order to update it
$ git pull

$ git remote show origin
* remote origin
Fetch URL: ssh://git@mysite.com/httphelper.git
Push URL: ssh://git@mysite.com/httphelper.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for ‘git pull’:
master merges with remote master
Local ref configured for ‘git push’:
master pushes to master (up to date)
————————————————————————————
How to checkout a branch(master) ?
git branch
output: * master
git fetch origin
output:
remote: Compressing objects: 100% (29/29), done.
From ssh://mysite.com/api
* [new branch] develop -> origin/develop

git checkout {mybranch} e.g git checkout develop
————————————————————————————
after sa git fetch
then git diff master origin/master ### for checking
then git merge origin/master

Create the branch on your local machine and switch in this branch :
git checkout -b [name_of_your_new_branch]

Push the branch on github :
git push origin [name_of_your_new_branch]

Discard unstaged changes in git: $ git checkout — {filename}
Discard all changes: $ git checkout .
But if the file is already staged, you will reset back to HEAD:
$ git reset HEAD
————————————————————————————————————-
How to change the remote Git repository for origin
$ git remote -v
origin ssh://git@mysite.com/testapp.git (fetch)
origin ssh://git@mysite.com/testapp.git (push)
## Change the URI (URL) for a remote Git repository
$ git remote set-url origin git@github.mycompany.com:MyGroup/myrepo.git
————————————————————————————————————-
git config –global push.default simple
git push or git push –set-upstream origin email_trigger
————————————————————————————————————-
zz – move current line to the middle of the screen
zt – move current line to the top of the screen
shift g – end of file
gg – top of file
————————————————————————————————————-
In my local dev machine:
git checkout master —to switch to master branch
git pull

From email_trigger branch:
git status
git fetch origin
git rebase origin/ui_changes
git checkout ui_changes —to switch to ui_changes branch
————————————————————————————————————-
From git gui, select the emailer branch

current branch,
git fetch origin
git rebase origin/master
————————————————————————————————————-
Force delete the branch: git push origin –delete ldap_authentication
git rebase origin/connections_trigger
git rebase –continue
git rebase –abort
git rebase –skip
————————————————————————————————————-
git checkout -b {mybranch}
git checkout
————————————————————————————————————-
How to update the remote git repo
$ git commit -am ‘#taskNumber a very detail commit message’
$ git fetch origin
$ git rebase origin/develop
if SUCCESS
git push origin develop
else
if naay conflict, manually resolve and then
git add {conflictFile} to mark resolution. Note: no git commit command
if all conflicts fixed, then
git rebase –continue
git push origin develop
————————————————————————————————————-
How to update your local repo
$ git fetch origin master ## OR git fetch origin
$ git status
On branch master
Your branch is behind ‘origin/master’ by 4 commits, and can be fast-forwarded.
(use “git pull” to update your local branch)
nothing to commit, working tree clean
$ git pull -v
Updating ed20586..dde2ac6
Fast-forward
public/css/app.css | 16 ++++++++++++++–
public/js/components/index.jsx | 19 ++++++++++++——-
2 files changed, 26 insertions(+), 9 deletions(-)

————————————————————————————————————-
How to preview first before pushing?
* git diff 0da94be..59ff30c
* git diff origin/develop
————————————————————————————————————-
This will list out your local comment history (not yet pushed) with corresponding message
git cherry -v

————————————————————————————————————-
git fetch origin develop
git rebase origin/develop
————————————————————————————————————-
How to merge DEVELOP(staging) TO MASTER(production)
Solution 1
git checkout master
git fetch origin
git rebase origin/master
git push origin master
# Note: The major benefit of rebasing is that you get a linear and much cleaner project history.

Solution 2
git checkout master
git pull origin master or git pull origin –rebase
# Merge branch develop into master
git merge develop
git push origin master
# If there are conflicts then we need to resolve it first
# Once we resolve all the conflicts it is now ready to push to master
git push origin master

# breaking something on the merge then abort it.
git merge –abort
————————————————————————————————————-
$ git clean -d -x -n
This removes untracked files, including directories (-d) and files ignored by git (-x).

$ git clean -d -x -f
Perform the delete operation

$ git checkout — js/app.js
$ git diff HEAD js/app.js
————————————————————————————————————-
$ npm install
$ bower install
$ grunt copy
$ grunt sass
$ grunt deploy (to run all task)
————————————————————————————————————-
How to update/sync your fork repo from the original repo?
$ cd myforkedApp
$ git remote -v
origin git@github.com:sudogem/rdash.git (fetch)
origin git@github.com:sudogem/rdash.git (push)
$ git remote add upstream git@github.com:tuxrace/rdash.git
$ git remote -v
origin git@github.com:sudogem/rdash.git (fetch)
origin git@github.com:sudogem/rdash.git (push)
upstream git@github.com:tuxrace/rdash.git (fetch)
upstream git@github.com:tuxrace/rdash.git (push)
$ git fetch upstream
$ git merge upstream/develop
———————————————————
artheman@ub3c:/var/www/_js/rdash(develop)$ git pull –rebase -v
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), done.
From github.com:sudogem/rdash
94545e9..d9e083f develop -> origin/develop
3769d24..94545e9 master -> origin/master
Changes from 067377061d2ebbd9ad19667c6b71085d9fd3cd56 to d9e083ff9a03e4ef68937860f9d8dde8eec2bce1:
First, rewinding head to replay your work on top of it…
Applying: testing
Applying: testnews
Applying: new
artheman@ub3c:/var/www/_js/rdash(develop)$
————————————————-

How to see code changes BEFORE git pull from master branch?
$ git fetch origin master or git fetch # Load changes from remote server
$ git status
On branch master
Your branch is behind ‘origin/master’ by 7 commits, and can be fast-forwarded.
(use “git pull” to update your local branch)
nothing to commit, working tree clean

# Before git pull need to check what are the changes.
$ git diff master origin/master

————————————————————————————————————-
How to change/update the git comments?
Will open your editor, allowing you to change the commit message of the most recent commit.
git commit –amend

————————————————————————————————————-
$ vi ~/.bash_profile ## or vi ~/.bashrc

#!/bin/bash
alias cls='clear;clear'

alias gitlogtree="git log -n 10 --graph --decorate -30 --all --date-order --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%C(cyan)%h%Creset %C(black bold)%ad%Creset%C(auto)%d %s'"

alias gitlog="git log -n 10 --pretty=format:'%Cgreen%h%Creset%x09%C(cyan)%an%Creset%x09%C(black bold)%ad%Creset%x09%s'"

How to add and commit a
add & commit
You can propose changes (add it to the Index) using
git add {filename} or git add .
git commit -am “Commit message”
Now the file is committed to the HEAD, but not in your remote repository yet.

————————————————————————————
Pushing changes
Your changes are now in the HEAD of your local working copy. To send those changes to your remote repository,
execute: git push origin master

git fetch origin
git diff master origin/master
git merge origin/master
————————————————————————————
Comparing two files
git diff HEAD {filename}
————————————————————————————
Check if your current branch has any updates from remote
git remote show origin
————————————————————————————
In my local dev,
git add filename
git push origin master
git remote show origin

In server02,
git remote show origin
simply execute: git pull
or
git fetch origin
git reset –hard origin/master

The third options is to discard the local changes using: git reset –hard
————————————————————————————
List remote branches
git ls-remote ssh://git@mysite.com/myapp.git OR SIMPLE git ls-remote in your current git repo
output:
2be5142f0e05b495a7708dad41e9fbff0096308a HEAD
bfb71abf9e00224e27166b27b28d49d747facd2d refs/heads/develop
e2be5142f0e05b495a7708dad41e9fbff0096308 refs/heads/master

Or like this:
$ git branch -r
output:
origin/HEAD -> origin/master
origin/master
————————————————————————————
How to update your master branch ?
$ git branch
* no branch
master
so, need ta mo switch sa master branch para makuha ang updated source files
$ git checkout master
Switched to branch ‘master’
Your branch is behind ‘origin/master’ by 1 commit, and can be fast-forwarded.

$ git remote show origin
* remote origin
Fetch URL: ssh://git@mycompany.com/httphelper.git
Push URL: ssh://git@mycompany.com/httphelper.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for ‘git pull’:
master merges with remote master
Local ref configured for ‘git push’:
master pushes to master (local out of date)

if it is out of date then execute git pull in order to update it
$ git pull

$ git remote show origin
* remote origin
Fetch URL: ssh://git@mysite.com/httphelper.git
Push URL: ssh://git@mysite.com/httphelper.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for ‘git pull’:
master merges with remote master
Local ref configured for ‘git push’:
master pushes to master (up to date)
————————————————————————————
How to checkout a branch(master) ?
git branch
output: * master
git fetch origin
output:
remote: Compressing objects: 100% (29/29), done.
From ssh://mysite.com/api
* [new branch] develop -> origin/develop

git checkout {mybranch} e.g git checkout develop
————————————————————————————
after sa git fetch
then git diff master origin/master ### for checking
then git merge origin/master

Create the branch on your local machine and switch in this branch :
git checkout -b [name_of_your_new_branch]

Push the branch on github :
git push origin [name_of_your_new_branch]

Discard unstaged changes in git: $ git checkout — {filename}
Discard all changes: $ git checkout .
NOTE: If the file is already staged, you need to reset it, first:
$ git reset HEAD ; git checkout —
————————————————————————————————————-
How to change the remote Git repository for origin
$ git remote -v
origin ssh://git@mysite.com/testapp.git (fetch)
origin ssh://git@mysite.com/testapp.git (push)
## Change the URI (URL) for a remote Git repository
$ git remote set-url origin git@github.mycompany.com:MyGroup/myrepo.git
————————————————————————————————————-
git config –global push.default simple
git push or git push –set-upstream origin email_trigger
————————————————————————————————————-
zz – move current line to the middle of the screen
zt – move current line to the top of the screen
shift g – end of file
gg – top of file
————————————————————————————————————-
In my local dev machine:
git checkout master —to switch to master branch
git pull

From email_trigger branch:
git status
git fetch origin
git rebase origin/ui_changes
git checkout ui_changes —to switch to ui_changes branch
————————————————————————————————————-
From git gui, select the emailer branch

current branch,
git fetch origin
git rebase origin/master
————————————————————————————————————-
Force delete the branch: git push origin –delete ldap_authentication
git rebase origin/connections_trigger
git rebase –continue
git rebase –abort
git rebase –skip
————————————————————————————————————-
git checkout -b {mybranch}
git checkout
————————————————————————————————————-
How to update the remote git repo
$ git commit -am ‘#taskNumber a very detail commit message’
$ git fetch origin
$ git rebase origin/develop
if SUCCESS
git push origin develop
else
if naay conflict, manually resolve and then
git add {conflictFile} to mark resolution. Note: no git commit command
if all conflicts fixed, then
git rebase –continue
git push origin develop
————————————————————————————————————-
How to update your local repo
$ git fetch origin master ## OR git fetch origin
$ git status
On branch master
Your branch is behind ‘origin/master’ by 4 commits, and can be fast-forwarded.
(use “git pull” to update your local branch)
nothing to commit, working tree clean
$ git pull -v
Updating ed20586..dde2ac6
Fast-forward
public/css/app.css | 16 ++++++++++++++–
public/js/components/index.jsx | 19 ++++++++++++——-
2 files changed, 26 insertions(+), 9 deletions(-)

————————————————————————————————————-
How to preview first before pushing?
* git diff 0da94be..59ff30c
* git diff origin/develop
————————————————————————————————————-
This will list out your local comment history (not yet pushed) with corresponding message
git cherry -v

————————————————————————————————————-
git fetch origin develop
git rebase origin/develop
————————————————————————————————————-
How to merge DEVELOP(staging) TO MASTER(production)
Solution 1
git checkout master
git fetch origin
git rebase origin/master
git push origin master
# Note: The major benefit of rebasing is that you get a linear and much cleaner project history.

Solution 2
git checkout master
git pull origin master or git pull origin –rebase
# Merge branch develop into master
git merge develop
git push origin master
# If there are conflicts then we need to resolve it first
# Once we resolve all the conflicts it is now ready to push to master
git push origin master

# breaking something on the merge then abort it.
git merge –abort
————————————————————————————————————-
$ git clean -d -x -n
This removes untracked files, including directories (-d) and files ignored by git (-x).

$ git clean -d -x -f
Perform the delete operation

$ git checkout — js/app.js
$ git diff HEAD js/app.js
————————————————————————————————————-
$ npm install
$ bower install
$ grunt copy
$ grunt sass
$ grunt deploy (to run all task)
————————————————————————————————————-
How to update/sync your fork repo from the original repo?
$ cd myforkedApp
$ git remote -v
origin git@github.com:devUser1/rdash.git (fetch)
origin git@github.com:devUser1/rdash.git (push)
$ git remote add upstream git@github.com:devUser2/rdash.git
$ git remote -v
origin git@github.com:devUser1/rdash.git (fetch)
origin git@github.com:devUser1/rdash.git (push)
upstream git@github.com:devUser2/rdash.git (fetch)
upstream git@github.com:devUser2/rdash.git (push)
$ git fetch upstream
$ git merge upstream/develop
———————————————————
artheman@ub3c:/var/www/_js/rdash(develop)$ git pull –rebase -v
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), done.
From github.com:devUser1/rdash
94545e9..d9e083f develop -> origin/develop
3769d24..94545e9 master -> origin/master
Changes from 067377061d2ebbd9ad19667c6b71085d9fd3cd56 to d9e083ff9a03e4ef68937860f9d8dde8eec2bce1:
First, rewinding head to replay your work on top of it…
Applying: testing
Applying: testnews
Applying: new
artheman@ub3c:/var/www/_js/rdash(develop)$
————————————————-

How to see code changes BEFORE git pull from master branch?
$ git fetch origin master or git fetch # Load changes from remote server
$ git status
On branch master
Your branch is behind ‘origin/master’ by 7 commits, and can be fast-forwarded.
(use “git pull” to update your local branch)
nothing to commit, working tree clean

# Before git pull need to check what are the changes.
$ git diff master origin/master

————————————————————————————————————-
How to change/update the git comments?
Will open your editor, allowing you to change the commit message of the most recent commit.
git commit –amend

————————————————————————————————————-
$ vi ~/.bash_profile ## or vi ~/.bashrc

#!/bin/bash
alias cls='clear;clear'

alias gitlogtree="git log -n 10 --graph --decorate -30 --all --date-order --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%C(cyan)%h%Creset %C(black bold)%ad%Creset%C(auto)%d %s'"

alias gitlog="git log -n 10 --pretty=format:'%Cgreen%h%Creset%x09%C(cyan)%an%Creset%x09%C(black bold)%ad%Creset%x09%s'"

HTTP Token Authentication workflow

Tags

Sample API workflow.

Step 1)

curl -k -X GET "https://mysampleapp.com/api/info?id=3727&apiKey=48254c477c&user=johndoe@mysampleapp.com" \
-H "Content-Type: application/json" \
-H "Authorization: Basic b311ZWdhYAcGguaWJtLcsxb55TpteXBhc3Nbaa3Jk"
...

The authorization header contains a Base64 encoded of the intranetID+Password
johndoe@mysampleapp.com:mypassword which is equal to b311ZWdhYAcGguaWJtLcsxb55TpteXBhc3Nbaa3Jk
Once hes authenticated, you will get a JSON response like this

{
  "status": "SUCCESS",
  "data": {
    "title": "Hello world",
    "author": "Arman Ortega"
  },
  "token": "E4QYBAGWLJEDBH43RK5DQ======"
}

Then we can use the generated token(200 chars) and add it to your Authorization header
Step 2)

curl -k -X GET "https://mysampleapp.com/api/like?apiKey=48254c477c&id=3727&action=like&user=johndoe@mysampleapp.com" \
-H "Content-Type: application/json" \
-H "Authorization: Token token=E4QYBAGWLJEDBH43RK5DQ======"
...

If the like action is success, youll have the response like this:

{"status":"SUCCESS","message":"Successfully updated record."}