✘ (U+2718) Heavy Ballot X
View bq_hash.py
from pathlib import Path | |
from hashlib import sha256 | |
datadir = Path('data') | |
def get_df_from_bq(sql: str, **opt): | |
hashed = sha256(sql.encode("utf-8")).hexdigest() | |
cache = datadir / "cache" | |
cache.mkdir(exist_ok=True) | |
fname = cache / f"{hashed}.csv" |
View index.js
const axios = require('axios') | |
const decode = require('decode-html') | |
const CHANNEL = '#dev' | |
const ISSUE_REPO = 'foo/bar' | |
exports.otochan = (req, res) => { | |
console.log('Received request:', req.body) | |
// slack challenge | |
if (req.body.challenge) { |
View readme.md
View currentfilepath.py
import os | |
os.path.dirname(os.path.abspath(__file__)) |
View command.sh
realpath file.txt | |
#=> /data/real/path/to/file.txt |
View index.md
item_ids, data[ITEM_IDX_KEY] = np.unique(data[item_id_col], return_inverse=True)
View xonshrc
# final edit for xonsh 0.8.12 | |
# Author: Qiushi Pan (@qqhann) | |
def _git_prefix(): | |
import xonsh.tools as xt | |
prefix = $(git rev-parse --show-prefix).strip() | |
sep = xt.get_sep() | |
if len(prefix) == 0: |
View sample.py
import uuid, os, base64 | |
def uuid32(): | |
return base64.b32encode(uuid.uuid4().bytes).decode('ASCII').rstrip('=') | |
def get_filefield_ascii_uuid(instance, filename): | |
# file will be uploaded to MEDIA_ROOT/user_<id>/<filename> | |
prefix = 'image' | |
name = uuid32() |
View sample.py
# https://matplotlib.org/faq/howto_faq.html#matplotlib-in-a-web-application-server | |
# do this before importing pylab or pyplot | |
import matplotlib | |
matplotlib.use('Agg') | |
import matplotlib.pyplot as plt | |
fig = plt.figure() | |
ax = fig.add_subplot(111) | |
ax.plot([1,2,3]) | |
fig.savefig('test.png') |
NewerOlder