Skip to content

Instantly share code, notes, and snippets.

View vincentwyshan's full-sized avatar

Vincent Wen vincentwyshan

  • Shanghai
View GitHub Profile
@vincentwyshan
vincentwyshan / multi_cron_timetable.py
Created September 3, 2024 14:18
Airflow plugin support config multiple cron expression schedule
from typing import Any, Dict, List, Optional
import pendulum
from airflow.exceptions import AirflowTimetableInvalid
from airflow.plugins_manager import AirflowPlugin
from airflow.timetables.base import DagRunInfo, DataInterval, TimeRestriction, Timetable
from croniter import croniter
from pendulum import DateTime, timezone
@vincentwyshan
vincentwyshan / generate_alembic_flowchart.py
Last active June 7, 2024 10:13
Generate alembic flow chart for history versions
# pip install graphviz required
import alembic.config
from alembic import script
from graphviz import Digraph
def collect_alembic_versions():
# Path to the Alembic configuration file
alembic_cfg = "alembic.ini"
@vincentwyshan
vincentwyshan / profiling_decorator.py
Last active February 26, 2024 15:30 — forked from nealtodd/decorator.py
Python profiling decorator
"""
Python decorator for profiling a function using cProfile. Stats are output to wherever print statements would
normally go to, e.g. stdout or a log file. Can be used with Django view functions.
pstats' sort and print arguments can be supplied to the decorator. The default is to sort cumulatively and
list to first 10 lines.
See http://docs.python.org/library/profile.html#instant-user-s-manual for details on pstats sort and print arguments.
cProfile is a standard module in most python distributions. pstats is also in many but not all. If pstats doesn't
@vincentwyshan
vincentwyshan / aes_cipher.py
Last active December 21, 2018 07:37
AES Cipher with PyCryptodome
""" python3.6+ """
from hashlib import md5
from base64 import b64decode
from base64 import b64encode
from Crypto.Cipher import AES
from typing import ByteString
BLOCK_SIZE = 32
pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * \
@vincentwyshan
vincentwyshan / TAP - bechmark - 20170205
Last active February 5, 2017 11:55
TAP - bechmark - 20170205
This is ApacheBench, Version 2.3 <$Revision: 1663405 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
{
"Seti_SB_bright": true,
"Seti_SB_med": true,
"color_scheme": "Packages/Seti_UX/Seti.tmTheme",
"ignored_packages":
[
],
"theme": "Seti_orig.sublime-theme",
"vintage_ctrl_keys": true,
"vintage_start_in_command_mode": true
@vincentwyshan
vincentwyshan / elasitcsearch.yaml
Created September 6, 2013 03:59
ES ik 分词 1.2.0
index:
analysis:
analyzer:
ik:
alias: [ik_analyzer]
type: org.elasticsearch.index.analysis.IkAnalyzerProvider
use_smart: true
test:
tokenizer : 'ik'
filter : ["synonym"]
Test thrift
start: 1357457502.17
File length: 796500
File length: 796500
File length: 796500
File length: 796500
File length: 796500
File length: 796500
File length: 796500
File length: 796500
[["ticker", "cnt_institution", "strong_buy", "buy", "neutral", "sell", "strong_sell", "cnt_maintain", "cnt_upgrade", "cnt_downgrade", "avg_score", "adjustment"], [["00358", 1, "", "", "961917:3:-1", "", "", 0, 0, 1, 3, null]], [["00874", 1, "", "", "961635:3:-1", "", "", 0, 0, 1, 3, null]], [["000778", 35, "959156:1:1,959611:1:1,959646:1:1,960513:1:1,960554:1:1,963153:1:1,965280:1:1,965591:1:1,965718:1:1,965840:1:1,966412:1:1,967001:1:1,970914:1:1,971010:1:1,971738:1:1,972134:1:1,972197:1:1,975801:1:1,975840:1:-1,976782:1:1,977085:1:1,977265:1:1,978141:1:1,978532:1:1", "959147:2:2,959160:2:2,960027:2:2,960556:2:2,961771:2:2,965684:2:2,967358:2:2,969486:2:2,970012:2:2,971638:2:2,973461:2:2", "", "", "", 34, 0, 1, 1, "Maintain"]], [["600860", 8, "960898:1:-1,964020:1:1,967496:1:1,972068:1:1,975806:1:1", "964915:2:-1,965008:2:-1,966061:2:-1", "", "", "", 4, 0, 4, 1, "Maintain"]], [["000629", 17, "978532:1:1", "959147:2:2,959160:2:2,960027:2:2,960513:2:2,960556:2:2,961771:2:2,965280:2:2,965684:2:2,967358:2:2,9692
#coding=utf8
import time
import simplejson as json
from cadaapi.stock.ttypes import *
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol