Fix: ClockworkMod Recovery MD5 mismatch

Tags

Hello all, i was trying to restore my backup of the system image which is about 6 months older via ClockworkMod Recovery. But i got a error which says something like:

MD5 mismatch!

Then after searching over the internet i found out the solution to this. Hope this might be useful to you.

Solving the problem

In the backup image folder you will see several files including nandroid.md5. Open this file with text editor such as vim or any of your favorite editor.

Delete the content of the file and make it empty. Optionally if you have any problem editing the file and simply delete this file and make a new file with same name(nandroid.md5) and keep this in the back image folder.

So, by deleting the content of this file i was able to fix the problem. Hope you will be able to solve the problem with this method.

“Constitution of Nepal” Android App

Tags

It’s been so great to feel that the Constitution of Nepal has finally arrived. Congratulations to all the Nepalese. May this Constitution brings peace, prosperity and rapid development in the country is the wish of all the Nepalese.

On this occasion with the intention of easy distribution of Constitution and making available of Constitution in the hand of all the people, i have developed an Android app to read the Constitution.

It is available on Google Play

Download Constitution of Nepal.

Decorators in Python

While learning Python in the beginning, i skipped the portion of the chapters on Decorators. After i worked on Flask and Django, I was introduced with the Decorators.

Let us consider a simple flask app example:

@app.route("/")
def hello():
    return "Hello World!"

In this code the line with @ symbol is decorators. Decorators is one of the important feature in Python that you must learn to master it. It is not that hard, so let us learn it.

First let us see Closures

>>> def out_func():
...     def in_func():
...             print("I am inner function")
...     return in_func
... 
>>> call = out_func()
>>> call
<function in_func at 0x7f0d6819a758>
>>> call()
I am inner function
>>> 

Also let us see by passing the parameter in the function.

>>> def out_func():
...     def in_func(x):
...             print(x)
...     return in_func
... 
>>> call = out_func()
>>> call
<function in_func at 0x7f66ff93f5f0>
>>> call(3)
3
>>> 

We can also pass the function as the parameter in the function. Let us write a function wrap which takes a function. We write another function checkNumber inside the wrap. It’s main task is to return same number if the number is greater than or equal to 100 otherwise return number by adding 100. It actually adds 100 using function that we pass to wrap.

We also write function incrementHundered to add 100 to passed number.

def wrap(func):
   def checkNumber(a): # check
       return (a if a >= 100 else func(a))
   return checkNumber

def incrementHundered(a):
    return a+100

# We pass incrementHundered to wrap
incrementHundered = wrap (incrementHundered) # decorators

print (incrementHundered(2)) # 102
print (incrementHundered(300)) # 300
print (incrementHundered(29)) # 129

The above code can be re-written using @ symbol for decorators as follows:

def wrap(func):
   def checkNumber(a): # check
       return (a if a >= 100 else func(a))
   return checkNumber

@wrap
def incrementHundered(a):
    return a+100

print (incrementHundered(2)) # 102
print (incrementHundered(300)) # 300
print (incrementHundered(29)) # 129

By writing @wrap and function just below it, think as if we have passed whole function to wrap. And it works as usual. So that was the quick and easy introduction to Decorators.

I hope you understood the Decorators.

How to delete the commit history in github

Tags

Sometimes you may find deleting the commit history of your github project repository useful. You can easily delete the commit history by following the procedure below.

It is always useful to keep the backup of your repository in your computer before removing all the commit history.

Let us start by cloning a github project. I am cloning ‘myproject’, you clone yours.

$ git clone https://github.com/acsudeep/myproject.git

Since all the commit history are in the “.git” folder, we have to remove it. So, go inside your project folder. For me the project folder is ‘myproject’.

$ cd myproject

And delete the ‘.git folder’ with this command.

$ sudo rm -rf .git

Now, let us re-initialize the repository.

$ git init

$ git remote add origin https://github.com/acsudeep/myproject.git
# add remote url

$ git remote -v
# verify

Next, let us add all our files and commit the changes.

$ git add --all
$ git commit -am 'initial commit'

Now, since we just have one commit i.e ‘initial commit’. Let us force push update to our master branch of our project repository.

$ git push -f origin master

You may need to provide the credentials for your account.

Go and check your project repository in github, you should see only one commit.

Django Tutorial – Building URL Shortener with Django

Tags

, ,

I finally got the time to write a Django tutorial. In this tutorial we are building URL Shortener. If you are confused with what we are building then we are building something similar to (bit.ly) or (goo.gl).

We are building the app that will make a shorter URL of a longer URL. (Example) Normally the shorter URL will be localhost:8000/4hh5kr for http://www.facebook.com

I am using¬†Django 1.7.1 with Python 3.3.2+. Don’t worry if you have different version of Django because we will set up our virtual environment and install latest version of Django. But be sure you do have Python 3+ because installing Python will not be covered in this tutorial.

I assume that you have completed Writing your first Django app. It is not really essential to complete this tutorial but it is highly recommended that you complete this tutorial before we begin. It will give you a lot of knowledge that will be useful in this tutorial.

You can also get the source code of this app in Github(django_urlshortener).

This tutorial is divided into 5 parts:

Continue reading