Skip to content

Instantly share code, notes, and snippets.

View weaming's full-sized avatar
🦀
Rustacean

Garden Yuen weaming

🦀
Rustacean
  • Shenzhen, China
View GitHub Profile
#!/usr/bin/env python3
class C:
a = 1
def __init__(self):
self.a += 1
def update(self):
@weaming
weaming / generate-sqalchemy-model-code.py
Created July 19, 2020 13:50
根据 csv 生成 SQLAlchemy models 代码
#!/usr/bin/env python3
# Author : weaming
# Mail : garden.yuen@gmail.com
# Created : 2020-07-19 21:01:50
# Usage:
# csv_json: pip3 install pretty-format-json
# xsv: brew install xsv
# cat esf-nn-rst.csv | xsv stats | csv_json | generate-sqalchemy-model-code.py
名称 代码 交易平台 交易量 市值 最新价 涨跌幅 技术5分钟 技术15分钟 技术30分钟 技术每小时 技术5小时 技术每天 技术每周 技术每月 value count
Bank of America Corp Pl Pref BAC_pl 纽约 2.10K 207690000000.0 1378.18 0.38 强力买入 强力买入 强力买入 强力买入 强力买入 强力买入 强力买入 强力买入 强力买入 8
贝莱德 BLK 纽约 113.72K 87740000000.0 569.03 0.08 强力买入 强力买入 强力买入 强力买入 强力买入 强力买入 强力买入 强力买入 强力买入 8
直觉外科公司 ISRG 纳斯达克 296.26K 70430000000.0 605.69 -0.35 强力买入 强力买入 强力买入 强力买入 强力买入 强力买入 强力买入 强力买入 强力买入 8
宣伟公司 SHW 纽约 114.31K
#!/usr/bin/env python3
# Author : weaming
# Mail : garden.yuen@gmail.com
# Created : 2020-07-15 14:05:23
import pdb
import os
from typing import Optional
#!/usr/local/bin/python3
# Created : 2020-07-16 13:06:10
import sys
import os
from graphviz import Digraph
fmt = os.getenv('GRAPH_FMT', 'dot')
dot = Digraph(comment='alembic', format=fmt)
import json
from functools import wraps
import requests
allow_methods = [
'options',
'head',
'get',
'post',
@weaming
weaming / install-python-with-tk-supported-via-pyenv-on-macos.sh
Last active June 2, 2020 12:22
Install python with tk supported via pyenv on macOS.
#!/usr/bin/bash
# https://github.com/pyenv/pyenv/issues/1375#issuecomment-524280004
# NOTE: following steps does work on my macOS 10.15.4, pyenv 1.2.18 :(
# Error example:
# ERROR: invalid Python executable: /Users/weaming/.pyenv/versions/3.8.2/bin/python3.8
# The python-build could not find proper executable of Python after successful build.
# Finally solution: download .pkg installer from https://www.python.org/downloads/release/python-382/
# it includes its own private version of Tcl/Tk 8.6. It does not use any system-supplied or third-party supplied versions of Tcl/Tk.
(+ 1 (+ 3 4))
(setq name "weaming")
(defun hello (name) (insert "Hello, " name))
(hello "weaming")
(switch-to-buffer-other-window "*test*")
(progn
(switch-to-buffer-other-window "*test*")
(erase-buffer)
(hello "you")
@weaming
weaming / st_heap.py
Last active May 21, 2020 18:10
数据结构:堆 heap
# Created : 2020-05-22 00:14:21
# 创建和调整:https://zhuanlan.zhihu.com/p/77527032
# 插入和删除:https://www.jianshu.com/p/e0a40d6748b8
import operator
default_op = operator.ge
def heap_adjust(A, i, size, op):
@weaming
weaming / aliyun-dm-send-email.py
Last active May 16, 2020 07:11
阿里云邮件推送服务 Python 发送示例
"""
https://dm.console.aliyun.com/
https://help.aliyun.com/document_detail/29444.html
https://www.jeesns.cn/article/detail/3422
https://text-compare.com/
"""
import time, datetime
import hmac
import base64
from urllib.parse import quote