item_ids, data[ITEM_IDX_KEY] = np.unique(data[item_id_col], return_inverse=True)
This file contains hidden or 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
# 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: |
This file contains hidden or 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 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() |
This file contains hidden or 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
# 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') |
This file contains hidden or 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
# Ubuntu | |
# ==================== | |
# dpkg | |
# https://askubuntu.com/a/350 | |
dpkg -x package.deb dir |
This file contains hidden or 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
# 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 |
This file contains hidden or 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 os | |
from pathlib import Path | |
from dotenv import load_dotenv | |
env_path = Path('.') / '.env' | |
load_dotenv(dotenv_path=env_path) |
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.
~
This file contains hidden or 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
# Thanks: https://github.com/ghmagazine/awesomebook | |
# Filter | |
df.query('"2016-10-13" <= checkout_date <= "2016-10-14"') | |
# Sampling | |
df.sample(frac=0.5) # Random sample 50% | |
df.sample(n=100) # Specify by N | |
# 集約ID単位のサンプリング |