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
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
@qqhann
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
qqhann / env.py
Created Feb 19, 2019
[Dotenv snippet] python dotenv snippet #python #dotenv #env
View env.py
import os
from pathlib import Path
from dotenv import load_dotenv
env_path = Path('.') / '.env'
load_dotenv(dotenv_path=env_path)
@qqhann
qqhann / init.md
Created Feb 14, 2019
[Vim Cheat Sheet] vim cheat sheet #vim
View init.md

Go Uppercase in current word

gUiw

~ 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.