Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
StayHome

Qiushi Pan qqhann

🏠
StayHome
View GitHub Profile
@qqhann
qqhann / index.js
Created Jul 9, 2020 — forked from uiur/index.js
slack emoji -> github issue
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) {
@qqhann
qqhann / readme.md
Created Jan 5, 2020
[GitHub aware unicode check and ballot] #github #markdown #unicode
@qqhann
qqhann / currentfilepath.py
Created Oct 30, 2019
[Current file absolute path] python #python
View currentfilepath.py
import os
os.path.dirname(os.path.abspath(__file__))
@qqhann
qqhann / command.sh
Created Jul 18, 2019
Get full path to a file
View command.sh
realpath file.txt
#=> /data/real/path/to/file.txt
@qqhann
qqhann / index.md
Created Jun 16, 2019
Reinitialize unique item index
View index.md
item_ids, data[ITEM_IDX_KEY] = np.unique(data[item_id_col], return_inverse=True)
@qqhann
qqhann / index.md
Last active Jun 14, 2019
[Amazing GIF emoji for slack] funny gif emojis chosen for slack #gif #slack
@qqhann
qqhann / xonshrc
Last active Mar 25, 2019
[Xonsh Awesome Prompt] #xonsh #shell #prompt
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:
@qqhann
qqhann / sample.py
Created Mar 19, 2019
[Django image upload_to uuid filename snipet] #django
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()
@qqhann
qqhann / sample.py
Created Mar 16, 2019
[Matplotlib on server] #python #matplotlib
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')
@qqhann
qqhann / terminal.sh
Created Mar 16, 2019
[Without root] #linux
View terminal.sh
# Ubuntu
# ====================
# dpkg
# https://askubuntu.com/a/350
dpkg -x package.deb dir
You can’t perform that action at this time.