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
@weaming
weaming / confirm.go
Created February 3, 2021 09:47 — forked from r0l1/confirm.go
Go (golang): How to ask for user confirmation via command line
/* MIT License
*
* Copyright (c) 2017 Roland Singer [roland.singer@desertbit.com]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
package main
import (
"flag"
"fmt"
"os"
"strings"
)
type Cli struct {
where type name sha remote
local tag 0.7.0-rc1 cd9a8ecfa9d7a810e42717ddc93ae066880d6519
local tag 0.9.1-pre1 26ed6af0405b027470b88f893577d35fca9af5bd
local tag 1.1.0-pre1 8f4ab925fafb7b7d5f565d0561f149d17edbda59
local tag interop.5.13 d11e375f828526eab2a59fd6fd3db88e3c5cb9d3
local tag interop.6.1 06670f4caecc9b37fc4b1467e4447359f92852f0
local tag interop.6.16.0 bead3bf412954c02ac82e5367e6e9c498a8a897b
local tag interop.6.5 613226dec59d3ed2a48b228aa8ed5c1ca7cdafe8
local tag interop.6.6 4068c9a7d863d56347f3256566889b909d2cc51b
local tag interop.6.8 96a5e579cfb3fdb67bd2c22b202db3c312928995
import queue
import threading
import traceback
import sys
def map_do(fn, iterable, n=20):
from concurrent.futures import ThreadPoolExecutor
with ThreadPoolExecutor(n) as executor:
@weaming
weaming / macOS-like.ahk
Last active December 2, 2020 02:32
模仿 #macOS 的 #AutoHotKey 的脚本,主要是把 Alt 键当成 Ctrl 键来用,另外就是 CMD + a/e 调到行首/行尾,还在 CMD + Shift + 箭头来切换 chrome 标签页。
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
#SingleInstance Force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
CapsLock::Esc
return
#!/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)
@weaming
weaming / google-center.css
Created July 6, 2018 11:24
Make google search center on wide screen
.mw,
.tsf{
margin: 0 auto;
}
/* search tool bar */
#hdtb-msb,
#resultStats {
position: relative;
left: calc((100vw - 950px)/2);
#!/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