Skip to content

Instantly share code, notes, and snippets.

View aamishbaloch's full-sized avatar
🎯
Focusing

Aamish Baloch aamishbaloch

🎯
Focusing
  • HelloFresh
  • Berlin, Germany.
View GitHub Profile
@aamishbaloch
aamishbaloch / accepting_boolean_value.md
Last active August 2, 2017 18:00
Accepting Boolean Value in Params in Django (Python)

Accepting Boolean Value in Params in Django (Python)

There are cases in which we have to receive a boolean value in params to fill up an object. I have came through an idea of doing this, following utility method will help you doing this:

def str2bool(value):
    """
    convert string to bool
    """
    if value:
        return value.lower() in ("true",)
 else:
@aamishbaloch
aamishbaloch / getting_code_from_remote.md
Created July 24, 2017 07:05
Getting the code as it is from the remote

Getting the code as it is from the remote

Ideal way to do this is to not use pull at all, but instead fetch and reset. You can see in the example below:

git fetch origin master
git reset --hard FETCH_HEAD
git clean -df
@aamishbaloch
aamishbaloch / squash_commits_to_one.md
Last active September 18, 2017 15:19
Squash & Merge your Commits for Pull Requests

Squash & Merge your Commits for Pull Requests

The method mentioned below only allows you to squash the last X consecutive commits into a single commit. Also, if you have merged master into your branch along the way, you will have to manually merge your new (squashed) commit into master and resolve the merge conflicts.

Combining the commits (Method 1)

To squash the last 3 commits into one:

git reset --soft HEAD~3
git commit -m "New message for the combined commit"
@aamishbaloch
aamishbaloch / remove_server_details.md
Last active November 7, 2024 19:07
Remove Server Details from Response Header - Nginx

Remove Server Details from Response Header - Nginx

Below mentioned method is used to hide or remove the NGIX details from the header of your http requests.

Install Nginx Extras

sudo apt-get update
sudo apt-get install nginx-extras

Remove Server Details