Some useful Coding techniques
#Git
###Remove bad commit from remote
git reset --hard <good commit id>
git push origin HEAD --force
###Revert to some previous commit
git log
Pick up a commit by commit code, e.g.,
commit 955cd428160a6d61a260564b193b175ae26f43c2
git checkout 955cd428160a6d61a260564b193b175ae26f43c2
###Remove files from Git but keep local copies
git ls-files
git rm --cached filename
git status
git add -u
git commit -m'commit message'
#Python
###Repeat a string
'this is a string' * 100
###Sort a list nums
and return index
>>> nums=[1,2,3,4,2,2,1,2,3,2,1,2,3,4,5]
>>> ind = sorted(range(len(nums)), key = lambda x: nums[x])
###Iterate over a list with index and value
for i,v in enumerate(mylist):
print i,v
###Pair up value in lists
for v1,v2 in zip(None,v1List,v2List):
print v1,v2
###Product of lists
import itertools
for v1,v2 in list(itertools.product(v1List,v2List))
print v1,v2
pop()
l.pop()
is to get and remove the last item from the list.l.pop(i)
is to get and remove the ith item from the list.