Skip to content

Instantly share code, notes, and snippets.

View lisabug's full-sized avatar
😇
Focusing

Yuanqin Lu lisabug

😇
Focusing
View GitHub Profile
@lisabug
lisabug / INSTALL.md
Created March 4, 2019 11:00 — forked from arya-oss/INSTALL.md
Ubuntu 16.04 Developer Tools installation

Ubuntu 16.04 Developer Tools Installation

First things first !

sudo apt update
sudo apt upgrade

Standard Developer Tools

sudo apt-get install build-essential git
@lisabug
lisabug / .tmux.conf
Created December 30, 2016 10:28
tmux conf
bind R source-file ~/.tmux.conf ; display-message "Config reloaded.."
# Use vim keybindings in copy mode
setw -g mode-keys vi
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# 状态栏
# 颜色
set -g status-bg black
set -g status-fg white
"""想要继承JsonMixin类,类需要包含名为to_dict的方法;__init__方法需要接受关键字参数"""
import json
class JsonMixin(object):
@classmethod
def from_json(cls, data):
kwargs = json.loads(data)
return cls(**kwargs)
def to_json(self):
@lisabug
lisabug / ToDictMixin.py
Created December 21, 2016 09:53
ToDictMixin Class in Python
class ToDictMixin(object):
def to_dict(self):
return self._traverse_dict(self.__dict__)
def _traverse_dict(self, instance_dict):
output = {}
for key, value in instance_dict.items():
output[key] = self._traverse(key, value)
return output
@lisabug
lisabug / progressbar.py
Last active December 5, 2016 10:10
ProgressBar in Python
# pip install progressbar
import progressbar
import time
progress = progressbar.ProgressBar(widgets=[progressbar.Bar('=', '[', ']'), ' ',
progressbar.Percentage(), ' ',
progressbar.ETA()])
for i in progress(range(100)):
# do something here
from collections import Counter
import numpy
def _bleu_stats(hypothesis, reference):
yield len(hypothesis)
yield len(reference)
for n in xrange(1, 5):
s_ngrams = Counter([tuple(hypothesis[i:i + n]) for i in xrange(len(hypothesis) + 1 - n)])
r_ngrams = Counter([tuple(reference[i:i + n]) for i in xrange(len(reference) + 1 - n)])
yield sum((s_ngrams & r_ngrams).values())
@lisabug
lisabug / vgg16_mxnet.py
Created April 9, 2016 04:11
VGG16 symbol definition of mxnet
def vgg16_symbol():
data = mx.sym.Variable('data')
# conv1
conv1_1 = mx.sym.Convolution(data=data, kernel=(3, 3), pad=(1, 1), num_filter=64, name="conv1_1")
relu1_1 = mx.sym.Activation(data=conv1_1, act_type="relu", name="relu1_1")
conv1_2 = mx.sym.Convolution(data=relu1_1, kernel=(3, 3), pad=(1, 1), num_filter=64, name="conv1_2")
relu1_2 = mx.sym.Activation(data=conv1_2, act_type="relu", name="relu1_2")
pool1 = mx.sym.Pooling(data=relu1_2, kernel=(2, 2), stride=(2, 2), pool_type="max", name="pool1")
@lisabug
lisabug / ssh_gfw.sh
Created March 26, 2016 10:33
利用ssh翻墙
ssh -qTfNn -D 7070 username@remotehost
@lisabug
lisabug / git.md
Created March 17, 2016 15:32 — forked from suziewong/git.md
Git的多账号如何处理? 1.同一台电脑多个git(不同网站的)账号 2.同一台电脑多个git(同一个网站的比如github的)多个账号

1.同一台电脑可以有2个git账号(不同网站的)

首先不同网站,当然可以使用同一个邮箱,比如我的github,gitlab,bitbucket的账号都是monkeysuzie[at]gmail.com 这时候不用担心密钥的问题,因为这些网站push pull 认证的唯一性的是邮箱 比如我的windows 上 2个账号一个gitlab 一个github (用的都是id_rsa)

host github
  hostname github.com
  Port 22

host gitlab.zjut.com

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: