This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ripgrep 13.0.0 | |
Andrew Gallant <[email protected]> | |
ripgrep (rg) recursively searches the current directory for a regex pattern. | |
By default, ripgrep will respect gitignore rules and automatically skip hidden | |
files/directories and binary files. | |
Use -h for short descriptions and --help for more details. | |
Project home page: https://github.com/BurntSushi/ripgrep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 5 * * * /opt/apps/ptt.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Git branch in prompt. | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
# Execute function in prompt | |
setopt PROMPT_SUBST | |
# Enable color in prompt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import base64 | |
import json | |
import hmac | |
import hashlib | |
import requests | |
URL = 'https://api.bitfinex.com' | |
API_VERSION = '/v1' | |
API_KEY = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
good_nums = {1, | |
3, | |
5, | |
6, | |
7, | |
8, | |
11, | |
13, | |
15, | |
16, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Simple view decorator for flask and mongoengine/pymongo to auto-retry with delay on | |
pymongo.errors.AutoReconnect exception. | |
""" | |
from functools import wraps | |
import time | |
from pymongo.errors import AutoReconnect | |
import flask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inspired from http://coding4streetcred.com/blog/post/Asymmetric-Encryption-Revisited-(in-PyCrypto) | |
# PyCrypto docs available at https://www.dlitz.net/software/pycrypto/api/2.6/ | |
from Crypto import Random | |
from Crypto.PublicKey import RSA | |
import base64 | |
def generate_keys(): | |
# RSA modulus length must be a multiple of 256 and >= 1024 | |
modulus_length = 256*4 # use larger value in production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import flask | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/") | |
def index(): | |
return "hello" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class KMP: | |
def partial(self, pattern): | |
""" Calculate partial match table: String -> [Int]""" | |
ret = [0] | |
for i in range(1, len(pattern)): | |
j = ret[i - 1] | |
while j > 0 and pattern[j] != pattern[i]: | |
j = ret[j - 1] | |
ret.append(j + 1 if pattern[j] == pattern[i] else j) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import time | |
endpoint = 'http://mis.twse.com.tw/stock/api/getStockInfo.jsp' | |
targets = ['0050'] | |
timestamp = int(time.time() * 1000 + 1000000) | |
channels = '|'.join('tse_{}.tw'.format(target) for target in targets) | |
query_url = '{}?_={}&ex_ch={}'.format(endpoint, timestamp, channels) | |
req = requests.session() | |
req.get('http://mis.twse.com.tw/stock/index.jsp') | |
print(query_url) |
NewerOlder