Skip to content

Instantly share code, notes, and snippets.

View laixintao's full-sized avatar
📟
I live in the terminal.

laixintao

📟
I live in the terminal.
View GitHub Profile

group([group1, ...])

Returns one or more subgroups of the match. If there is a single argument, the result is a single string; if there are multiple arguments, the result is a tuple with one item per argument. Without arguments, group1 defaults to zero (the whole match is returned). If a groupN argument is zero, the corresponding return value is the entire matching string; if it is in the inclusive range [1..99], it is the string matching the corresponding parenthesized group. If a group number is negative or larger than the number of groups defined in the pattern, an IndexError exception is raised. If a group is contained in a part of the pattern that did not match, the corresponding result is None. If a group is contained in a part of the pattern that matched multiple times, the last match is returned.

>>>
>>> m = re.match(r"(\w+) (\w+)", "Isaac Newton, physicist")
>>> m.group(0)       # The entire match
'Isaac Newton'
>>> m.group(1)       # The first parenthesized subgroup.

'Isaa

@laixintao
laixintao / qrify
Created July 17, 2017 04:03
Generate QR code in shell.
#!/bin/bash
# Author: Linyos Torovoltos github.com/linyostorovovoltos
currentVersion="1.13.0"
multiline="0" # flag that indicates multiline option
getConfiguredClient()
{
if command -v curl &> /dev/null ; then
@laixintao
laixintao / history-stat.sh
Created July 26, 2017 02:35
To see your most used shell command.
$ history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
1 1758 30.5208% git
2 624 10.8333% cd
3 557 9.67014% vim
4 305 5.29514% ls
5 256 4.44444% workon
6 200 3.47222% honcho
7 186 3.22917% python
8 158 2.74306% pip
  1. Week1
    1. Introduction
    2. Linear Regression with One Variable
    3. Linear Algebra Review
  2. Week2
    1. Linear Regression with Multiple Variables
    2. Octave/Matlab Tutorial
  3. Week3
    1. Logistic Regression
    2. Regularization
sed -i "s/zhangsan/lisi/g" `grep zhangsan -rl /modules`
sed -i '' "s/judical/judicial/g" `ack -l 'judical' *`
@laixintao
laixintao / Jedi-settings.rst
Last active August 4, 2017 03:34
Since Jedi doesn't support realtime complete, I use youCompleteMe for complete, and jedi for going to definition.

NOTE: subject to change! :

let g:jedi#goto_command = "<leader>d"
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = ""
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#rename_command = "<leader>r"
let g:jedi#completions_enabled = 0
@laixintao
laixintao / python_re_compile_test.py
Created August 21, 2017 06:15
python的re在函数中编译之后,退出函数并不会立即被回收,下次会使用同样的re
# -*- coding: utf-8 -*-
import re
def clean(string):
re_strip = re.compile(r'(^\s+)|([\s::]+$)')
print id(re_strip)
result = re_strip.sub('', string)
return result
@laixintao
laixintao / formdata.py
Created August 25, 2017 09:24
format chrome formdata to requests data.
# -*- coding: utf-8 -*-
"""
$ python formdata.py "typeId=2&enTableName=SYJ_SXQYHMD_SYJ&searchName=&personField=QYMC&page=1&pageSize=10"
[
('typeId', '2'),
('enTableName', 'SYJ_SXQYHMD_SYJ'),
('searchName', ''),
('personField', 'QYMC'),
('page', '1'),
@laixintao
laixintao / .vimrc
Last active September 18, 2017 06:23
test gist script
" ## Note:
" 1. vim字体受终端的限制,所以如果不是gvim, set guifont是无效的
" 2. 需要安装配色方案,还需要对终端进行配置,如果只安装了Vim的,Vim会看起来雾蒙蒙的一片
"
" 终端配色安装:
" 1. 设置Termial配色:git clone git://github.com/seebi/dircolors-solarized.git
" 2. 注意第二个参数是dircolor是的文件夹
" cp ~/dircolors-solarized/dircolors.256dark ~/.dircolors
" eval 'dircolors .dircolors'
" 3. 使设置生效
  1. develop更新了没
  2. pip install 更新了没 -U
  3. 数据库更新了没
  4. 清除cookie重新登录