Skip to content

Instantly share code, notes, and snippets.

@kingname
Last active May 12, 2017 04:43
Show Gist options
  • Save kingname/0de31d9a15a472d008a877850b7774e3 to your computer and use it in GitHub Desktop.
Save kingname/0de31d9a15a472d008a877850b7774e3 to your computer and use it in GitHub Desktop.
all kinds of tracks.

VIM

  1. when you paste your python code into vim, the indent will be crazy. but if you run the command in the normal mode first:
:set paste

Everything will be fine.

Python

import datetime

start = datetime.datetime.now()
# some time later
end = datetiem.datetime.now()
second_delta = (end - start).total_seconds()

MongoDB Query by ObjectId:

from bson.objectid import ObjectId
import pymongo
handler = pymongo.MongoClient().xx.yy
handler.update({'_id': ObjectId('asdfasd24234asdf8ajk')}, {'$set': {'aa': 1}})

Scrapy

from scrapy.selector import Selector

selector = Selector(text='<html>.....</html>')

Jypyter

change the size of figure and x label:

matplotlib.rcParams['figure.figsize'] = (20.0, 15.0)
matplotlib.rc('xtick', labelsize=20) 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment