Skip to content

Instantly share code, notes, and snippets.

@quxiaowei
quxiaowei / bilibili.zsh
Last active February 23, 2017 01:42
从哔哩哔哩下载剧,并将视屏片段合并 需要:youtube-dl, ffmpeg
for i in {1..12}
do
url=http://www.bilibili.com/video/av3794937/index_$i.html
echo $url
youtube-dl -o "SeGmEnT-$i-%(playlist_index)s.%(ext)s" $url
rm -f buffer_list
touch buffer_list
for file in $(ls SeGmEnT-$i-*.flv)
do
echo file "'$file'" >> buffer_list
@quxiaowei
quxiaowei / iconv.zsh
Last active June 14, 2016 16:08
文件转码 command line
iconv -f cp936 -t utf-8 chinese-gb2312.txt > chinese-utf8.txt
bytes.fromhex(str_str).decode('ascii')
@quxiaowei
quxiaowei / delete_tag.py
Last active July 14, 2016 01:41
删除 html 中指定标签
# delete specific tags from html file
# by quxiaowei
# @ 20160702
i = j = 0
text = """
<p class="p"><b><span style="font-family: 'Times New Roman': font-size: 12pt;">一、岗位及人数</span></b><span style="font-family: 'Times New Roman'; font-size: 12pt;"><o:p></o:p></span></p><p class="p"><span style="font-family: 'Times New Roman'; font-size: 12pt;">办公室工作人员,<font face="Times New Roman">1</font><font face="微软雅黑">名;教师,</font><font face="Times New Roman">4</font><font face="微软雅黑">名。</font></span><font class="
"""
text_o = ''
@quxiaowei
quxiaowei / ws_rest_json_unitest_script.py
Last active July 14, 2016 01:55
和其他接口测试写的脚本,暂存着
import requests
from datetime import datetime
def timer(file):
def wrapper(func):
def wrapper(*argv):
d1 = datetime.now()
res = func(*argv)
d2 = datetime.now()
file.write('duration:{0.seconds}s {0.microseconds}ms\n'.format(d2-d1))
@quxiaowei
quxiaowei / abap_decoding.abap
Last active February 13, 2018 06:43
[Decoding] decoding #ABAP
DATA buffer TYPE xstring.
DATA v_text TYPE string.
DATA v_text2 TYPE string.
DATA conv TYPE REF TO cl_abap_conv_in_ce.
conv = cl_abap_conv_in_ce=>create( encoding = 'UTF-8' ).
LOOP AT response.
buffer = response.
conv->convert(
EXPORTING input = buffer
@quxiaowei
quxiaowei / abap_transformation.xml
Last active July 14, 2016 05:41
[abap] transformation from json to abap
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<!--
json: example:
[{"result":-3.585595,"errorCode":"0","errorMessage":" "},
{"result":-3.585595,"errorCode":"0","errorMessage":" "}]
abap type:
TYPES: BEGIN OF ty_result,
@quxiaowei
quxiaowei / calculator.py
Last active June 16, 2017 10:26
A humble calculator
import re
from copy import deepcopy
import operator
RE_NUM = re.compile('\s*([-+]?\d+(\.\d+)?)')
def number(word):
result = RE_NUM.match(word)
groups = result.groups()
@quxiaowei
quxiaowei / abap_url_escape_decode.abap
Last active February 13, 2018 06:45
[URL Excape] #ABAP
" escape & unescape
DATA str_name TYPE string.
str_name = cl_http_utility=>if_http_utility~escape_url( str_name ).
str_name = cl_http_utility=>if_http_utility~unescape_url( str_name ).
" encode
DATA conv TYPE REF TO cl_abap_conv_out_ce.
conv = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).
conv->convert(
EXPORTING data = v_text
@quxiaowei
quxiaowei / IF_REST_APPLICATION~GET_ROOT_HANDLER.abap
Last active March 3, 2021 16:51
[IF_REST_APPLICATION~GET_ROOT_HANDLER] #ABAP
METHOD if_rest_application~get_root_handler.
*CALL METHOD SUPER->IF_REST_APPLICATION~GET_ROOT_HANDLER
* RECEIVING
* RO_ROOT_HANDLER =
* .
DATA: lo_router TYPE REF TO cl_rest_router.
IF mo_server IS BOUND.
CREATE OBJECT lo_router.
lo_router->attach( iv_template = '/GetTest' iv_handler_class = 'ZCL_REST_WS_TEST' ).