Skip to main content

Posts

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.

Installing virtualenv in Custom MSC Linux board

I am currently working on a Python project which runs on MSC board (with custom Linux OS). Even installing something as basic as virtualenv on this board needed some 'efforts'.  So, I decided to summarize the steps that helped me to get python virtual environment working on this Linux based board.  Hopefully, it might also help some other developers facing similar issues.   Install virtualenv package     I had to use ' --trusted-host ' flag for both pypi.org and      ' files. pythonhosted.org ' to avoid ssl certificate errors.      However, use of this flag should be avoided in general      because it overrides some essential security checks.          python3.6 -m pip install --trusted-host= pypi.org virtualenv      --trusted-host= files. pythonhosted.org Define symbolic library path     We need to d...

Hosting your Django app in Cloud Based Server

Let’s say that you have a solid business plan and you decide to go with Python and Django framework to take this project from concept to reality. One of the most fundamental things to do at this stage is to find a Django-friendly hosting service. Since Django framework has a special syntax and structure, it’s important to make sure that a chosen provider makes it possible to easily deploy and scale any Django project. There are many Django-compatible hosting providers which are worth considering. This post documents my experience deploying a basic Python based web app in " PythonAnywhere". PythonAnywhere runs on powerful Amazon EC2 servers and it is pre-configured with tons of libraries. Steps: Create a free user account in GitHub.com (If you haven't done it yet!)           Then, create a new repository, giving it the name. My test project was named " DjangoTest ". Set up our Django Test App on PythonAnywhere ...

Installing g++ compiler on Windows

Download MinGW - Minimalist GNU for Windows from below link –                 https://sourceforge.net/ projects/mingw/ Now run the installer as admin. It will download some files and then open the MinGW download manager Select MinGW base and MinGW G++ (for c++ compilation) check boxes Go to File -> Apply Changes. The selected options will be installed. Add the below path to System Path in environment variable                 “C:\MinGW\bin” Now you can try to verify in g++ is installed properly by running the below command in Command Promt –                  g++ --version