Skip to content

Instantly share code, notes, and snippets.

View onriv's full-sized avatar
🎯
Focusing

onriv onriv

🎯
Focusing
View GitHub Profile
/**
* TODO refactor
*/
@Override
public XResPostableStatus canXResPostable(XResPostableOrder order) {
boolean valid = true;
String msg = null;
String orderStatus = order.getOrderStatus();
OrderCategory orderCategory = order.getOrderCategory();
@onriv
onriv / template.tex
Created November 6, 2016 14:02 — forked from hsanchez/template.tex
My Latex Template for Kindle (Or IPAD)
\documentclass[8pt]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[paperwidth=9cm, paperheight=11.5cm, top=0.5cm, left=0.5cm, right=0.5cm, bottom=0.5cm]{geometry}
\usepackage{graphicx}
\usepackage{tikz, blindtext}
\makechapterstyle{box}{
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapnumfont}{\normalfont\sffamily\huge\bfseries}
\renewcommand*{\printchapternum}{
@onriv
onriv / .gitignore
Last active October 9, 2016 02:01
gitignroe
## Ignore Python compiled files
*.pyc
## Ignore vim temporary files
*.swp
*~
## Ignore JetBrains temporary files
.idea/
@onriv
onriv / mechanize_settings.py
Last active August 29, 2015 14:21
python:mechanize模块的常用设置
#!/usr/bin/env/ python
#coding=utf-8
import mechanize
import cookielib
import itertools
import string
import threading
import time
# Cookie Jar
cj = cookielib.LWPCookieJar()
@onriv
onriv / configparser.py
Created May 5, 2015 02:48
python:ConfigParser:设置
import ConfigParser, sys
_data = ConfigParser.ConfigParser()
_data.read(sys.argv[1])
@onriv
onriv / candies.py
Last active August 29, 2015 14:07
python:algorithm:candies.py
# -*- coding: utf-8 -*-
'''
输入一个数组(元素假设为整数),对其元素进行赋值(赋予权重,为整数),使得
- 每个元素的权重至少为1
- 如果某一元素比其相邻的元素大(左或右),那么该元素的权重也比对应元素的权重大
输出:权重最小的赋值算法
解决思路:
@onriv
onriv / lcs.py
Last active August 29, 2015 14:06 — forked from istepanov/lcs.py
#!/usr/bin/env python
# -*- coding: utf-8
"""
Search longest common substrings using generalized suffix trees built with Ukkonen's algorithm
Author: Ilya Stepanov <code at ilyastepanov.com>
(c) 2013
"""
@onriv
onriv / sub_index.py
Created September 15, 2014 14:56
python:文本处理:依次替换(如'ababab'替换为'1b2b3b'):sub_index.py
# -*- coding: utf-8 -*-
# 依次替换示例
def f(m, count=[0]):
count[0] += 1
return str(count[0])
re.sub('a', f, 'ababab')
# 输出为
# '1b2b3b'
@onriv
onriv / change_note.py
Last active August 29, 2015 14:06
python:文本处理:处理圆圈序号形式的脚注:change_note.py
# -*- coding: utf-8 -*-
import re
def changeText(paragraph, prefix, countMatch = 0):
pattern = r'[①②③④⑤⑥⑦⑧⑨⑩]'
text = '<a class="duokan-footnote" href="%s#df-%d"><img src="../Images/note.png"/></a>'
def changeRule(matchobj):
nonlocal countMatch
countMatch += 1
return text % (prefix, countMatch)
#!/usr/bin/python -O
# partition A[p:r] in place about x, and return the final position of the pivot
def partition(A, p, r, x):
# find the index of the pivot
i = -1
for j in range(p, r):
if A[j] == x:
i = j
break