Skip to content

Instantly share code, notes, and snippets.


Qiushi Pan qqhann

Block or report user

Report or block qqhann

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
qqhann /
Created Jul 18, 2019
Get full path to a file
realpath file.txt
#=> /data/real/path/to/file.txt
qqhann /
Created Jun 16, 2019
Reinitialize unique item index
item_ids, data[ITEM_IDX_KEY] = np.unique(data[item_id_col], return_inverse=True)
qqhann /
Last active Jun 14, 2019
[Amazing GIF emoji for slack] funny gif emojis chosen for slack #gif #slack
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 as xt
prefix = $(git rev-parse --show-prefix).strip()
sep = xt.get_sep()
if len(prefix) == 0:
qqhann /
Created Mar 19, 2019
[Django image upload_to uuid filename snipet] #django
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 /
Created Mar 16, 2019
[Matplotlib on server] #python #matplotlib
# do this before importing pylab or pyplot
import matplotlib
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
qqhann /
Created Mar 16, 2019
[Without root] #linux
# Ubuntu
# ====================
# dpkg
dpkg -x package.deb dir
qqhann / nginx.conf
Created Feb 28, 2019
[Django deploy with uWSGI & Nginx] #django #uwsgi #nginx
View nginx.conf
# the upstream component nginx needs to connect to
upstream django {
server unix:///home/user/api/master.sock; # for a file socket
# configuration of the server
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
qqhann /
Created Feb 19, 2019
[Dotenv snippet] python dotenv snippet #python #dotenv #env
import os
from pathlib import Path
from dotenv import load_dotenv
env_path = Path('.') / '.env'
qqhann /
Created Feb 14, 2019
[Vim Cheat Sheet] vim cheat sheet #vim

Go Uppercase in current word


~ will reverse the case of the selected characters it takes a count e.g. 5~ will reverse the case of 5 characters. g~w to change case of a whole word.

You can’t perform that action at this time.