Reduce git branch into 1 commit

Make sure to rebase from master (or parent branch):

git rebase origin/master

Say your current local branch has 4 commits. To squash into 1 commit, do the following:

git rebase -i HEAD~4

Brings up editor that will allow you to p (pick) and f (fixup -- like squash) the commits you want. Save your commit text.

If you want to merge to master:

git checkout master
git merge name-of-branch
git push

If you want to delete the branch:

git branch -D name-of-branch

Revert Git remote branch to commit without history

git reset <commit-hash> --hard
git push origin -f

Install Spotify on Ubuntu

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0DF731E45CE24F27EEEB1450EFDC8610341D9410
echo deb http://repository.spotify.com stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list
sudo apt-get update
sudo apt-get install spotify-client

Postgres common calls

Disconnect sessions:

SELECT * FROM pg_stat_activity;
SELECT pg_terminate_backend(<pid>);

Common ElasticSearch queries`

Find duplicates:

curl -XGET 'localhost:9200/<your_index>/_search?pretty' -d '
{
   "aggs": {
      "dups": {
         "terms": {
            "field": "<your_field>",
            "size": 0,
            "min_doc_count": 2
         }
      }
   }
}'

Delete an index:

curl -XDELETE 'localhost:9200/<your_index>?pretty'

Count number of records in doc:

curl -XGET 'localhost:9200/<your_index>/_count?&pretty'
curl -XGET 'localhost:9200/<your_index>/_count?pretty' -H 'Content-Type: application/json' -d'
{
    "query" : {
      ...

Install elasticsearch on Ubuntu

Install java if needed:

sudo apt-get update
sudo apt-get install default-jre
sudo update-alternatives --config java

sudo nano /etc/environment
source /etc/environment

Add JAVA_HOME for java:

echo $JAVA_HOME

Then install elasticsearch:

sudo apt-get update
wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.3.1/elasticsearch-2.3.1.deb
sudo dpkg -i elasticsearch-2.3.1.deb
sudo systemctl enable elasticsearch.service

Before running elasticsearch:

sudo nan...