Skip to main content

Posts

Showing posts from 2019

How to hard reset a GitHub commit

Get commit ID using this command git log Revert using the specif id git revert 497011c4a1914839a6555dc8041ac8 9b5d1f3241 Reset master branch to the parent of reverted commit id git push origin + 497011c4a1914839a6555dc8041ac8 9b5d1f3241^:master            (git interprets x^ as the parent of x and + as a forced non-fast forward push.)

How to run Django Server forever

Create a shell script with below content and save it as ‘runserver.sh’. while true; do   echo "Re-starting Django Server"   python3 manage.py runserver 0.0.0.0:8000   sleep 2 done Start Django Server using the 'runserver.sh' script If the file was created/edited in Windows environment, you might need to fix the line ending before it can be executed in Linux PC. This can be done by executing below command – sed -i 's/\r$//' runserver.sh Make the shell script executable chmod +x runserver.sh Execute shell script.      ./runserver.sh          Now the server will keep running. To stop the server, press ‘ Ctrl+C’ twice.

Falsehoods programmers believe about time

Disclaimer: This is not my own collection! I learnt a lot from different blog post about this 'famous' topic. Here is the list of some of the misconceptions and mistakes related to both calendar and system time: All of these assumptions are wrong There are always 24 hours in a day. Months have either 30 or 31 days. Years have 365 days. February is always 28 days long. Any 24-hour period will always begin and end in the same day (or week, or month). A week always begins and ends in the same month. A week (or a month) always begins and ends in the same year. The machine that a program runs on will always be in the GMT time zone. Ok, that’s not true. But at least the time zone in which a program has to run will never change. Well, surely there will never be a change to the time zone in which a program hast to run in production. The system clock will always be set to the correct local time. The system clock will always be set to a time that is not wildly differe

Fixing git error: "remote: Repository not found"

I was trying to modify one of my private repository in GitHub and ran into the below error - git clone https://github.com/<user>/DocTest.git Cloning into 'DocTest'... remote: Repository not found. fatal: repository 'https://github.com/<user>/DocTest.git/' not found After lot of trial and error attempts, I figured out that my Windows 10 PC had stored github user credentials, so it didn't let me clone a private repository which was not accessible to the saved user. This is how we can clear any saved cache - Open Control Panel from the Start Menu Select User Accounts Select "Manage your credentials" in the left hand menu Delete all user credentials related to Git or GitHub After doing that, the error was gone and I was able to clone the repositories.