Skip to content

Instantly share code, notes, and snippets.

View zhangysh1995's full-sized avatar
🤣
I have a 150-star repo now!

Yushan zhangysh1995

🤣
I have a 150-star repo now!
  • Tencent
  • Shenzhen, China
  • 13:29 (UTC +08:00)
View GitHub Profile
@zhangysh1995
zhangysh1995 / Dockerfile
Last active March 12, 2018 08:30
A Dockerfile to build minimum local environment to test your projects
#
# This is an image to test building your projects,
# which may use cmake, automake, or scons
#
# basic info
FROM ubuntu:xenial-20180123
MAINTAINER Yushan Zhang <zhangysh1995@gmail.com>
# software management
@zhangysh1995
zhangysh1995 / docker_rabbitmqctl.md
Created March 1, 2018 02:54 — forked from jemc/docker_rabbitmqctl.md
Controlling Docker RabbitMQ via rabbitmqctl

Example invocation of a RabbitMQ docker container (use -d instead of -t -i to run in the background):

sudo docker run -t -i --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management

Example of controlling the rabbitmq-server inside the container using rabbitmqctl (also inside the container).

sudo docker exec rabbitmq su rabbitmq -- /usr/lib/rabbitmq/bin/rabbitmqctl status
@zhangysh1995
zhangysh1995 / zoomin.py
Created August 4, 2017 03:54
pandas/matplotlib: zoom in part of plots
import pandas as pd
from matplotlib import pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes
from mpl_toolkits.axes_grid1.inset_locator import mark_inset
# original plots
fig = plt.figure(figsize=(14,5))
ax = plt.axes()
ax.plot(ts)
@zhangysh1995
zhangysh1995 / ticks.py
Last active August 2, 2017 07:50
matplotlib/pandas ticks: show percentage
import matplotlib.ticker as mtick
fmt = '%.0f%%'
yticks = mtick.FormatStrFormatter(fmt)
# also apply to subplots
ax.yaxis.set_major_formatter(yticks)
@zhangysh1995
zhangysh1995 / sharex.py
Created August 2, 2017 07:24
pandas/matplotlib sharex for subplots
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import gridspec
fig = plt.figure()
# split the space
gs = gridspec.GridSpec(2, 1)
# the fisrt subplot
ax0 = plt.subplot(gs[0])
@zhangysh1995
zhangysh1995 / scp.py
Created July 28, 2017 09:36
python3 scp elegantly
import os
from paramiko import SSHClient
from scp import SCPClient
def scp(local, remote):
server = 'xxx'
# setup ssh
ssh = SSHClient()
ssh.load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))
ssh.connect(server, username='xxx', password='xxx')