Skip to content

Instantly share code, notes, and snippets.

View kingname's full-sized avatar
🎯
Focusing

kingname kingname

🎯
Focusing
View GitHub Profile
@kingname
kingname / train.sh
Last active June 28, 2017 08:49
[训练tesseract] #tags:tesseract
$ java -Xms4096m -Xmx4096m -jar jTessBoxEditor.jar
$ tesseract num.font.exp0.tif num.font.exp0 batch.nochop makebox
# 使用jTessBoxEditor打开并编辑num.font.exp0.tif
$ vim font_properties
# font 0 0 0 0 0
$ tesseract num.font.exp0.tif num.font.exp0 nobatch box.train
@kingname
kingname / python_decorate_use_method.py
Created April 17, 2017 07:42
[Python decorate use class method] tags:Python, decorate
def catch_exception(origin_func):
def wrapper(self=None, *args, **kwargs):
print('start')
try:
u = origin_func(self, *args, **kwargs)
return u
except Exception:
self.z()
return 'an Exception raised.'
return wrapper
@kingname
kingname / items.py
Last active April 7, 2017 03:31
[supress scrapy items] To avoid too many data printed at console when yield item in scrapy, override item's __repr__method. tags: Python, Scrapy, Item
class XXXItem(Item):
name = Field()
age = Field()
def __repr__(self):
return '========data stored==========='
@kingname
kingname / Tracks.md
Last active May 12, 2017 04:43
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

@kingname
kingname / change_selenium_log_level.py
Last active April 2, 2017 02:33
修改Selenium的Log Log Level #tags: Python,Selenium
import logging
from selenium.webdriver.remote.remote_connection import LOGGER
LOGGER.setLevel(logging.WARNING)
@kingname
kingname / set_line_number_for_jupyter.js
Created February 5, 2017 12:29
add line number for jupyter
/*If you want line numbers only for code cells, there is a simpler approach. Select a code cell, open the Chrome/Firefox JavaScript console, type the following lines:*/
```javascript
var cell = Jupyter.notebook.get_selected_cell();
var config = cell.config;
var patch = {
CodeCell:{
cm_config:{lineNumbers:true}
}
}