Pipenv and Pipfile: The officially recommended Python packaging tool

Pipenv and Pipfile: The officially recommended Python packaging tool

You no longer need to use pip and virtualenv separately. Use pipenv instead.

ref:
https://docs.pipenv.org/

Install

$ pip install pipenv

ref:
https://github.com/pypa/pipenv

Usage

Caution: Pipenv is not compatible with Anaconda.

$ pyenv global 3.6.4

# initialize project virtualenv with a specific Python version
# automatically generate both Pipfile and Pipfile.lock from an existed requirements.txt
$ pipenv install --python python3

$ cd /path/to/project-contains-Pipfile
$ pipenv install

$ pipenv install pangu
$ pipenv install -r requirements.txt

# install packages to dev-packages
$ pipenv install --dev \
ipdb \
flake8 \
flake8-bandit \
flake8-bugbear \
flake8-comprehensions \
flake8-debugger \
flake8-print \
flake8-string-format \
pep8-naming \
pylint \
pylint-common \
pylint-celery \
pylint-django \
pylint-flask

# switch your shell environment to project virtualenv
$ pipenv shell
$ exit

# uninstall everything
$ pipenv uninstall --all

# remove project virtualenv
$ pipenv --rm

ref:
https://docs.pipenv.org/basics/
https://docs.pipenv.org/advanced/

Example Pipfile

[[source]]
url = "https://pypi.python.org/simple" 
verify_ssl = true 
name = "pypi" 

[packages] 
requests = ">=2.0.0" 

[dev-packages] 
flake8 = "*" 
ipdb = "*" 
ipython = "*" 
pylint = "*" 

[requires] 
python_version = "3.6" 

oh-my-zsh

oh-my-zsh is a community-driven framework for managing zsh configuration.

ref:
https://github.com/robbyrussell/oh-my-zsh

Installation

$ curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
$ brew install zsh-completions

Plugins

ref:
https://github.com/vinta/dotfiles/blob/master/zshrc
https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins
https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins-Overview

$ alias
$ tab
$ ..
$ ~

j, z, fasd

這幾個指令都需要你曾經 cd 到該目錄作為歷史紀錄之後才能用
檔案的話需要被 vim 或 sublime 過

$ cd ~/Project
$ j pro
$ o pro

$ sublime /private/etc/hosts
$ sublime ~/.ssh/config
$ v hosts
$ v ssh config

jump

$ cd ~/Projects/streetvoice
$ mark sv
$ jump sv
$ unmark sv
$ marks

Themes

ref:
https://github.com/robbyrussell/oh-my-zsh/wiki/Themes

Use Docker Machine to setup Docker environments

Docker Machine is a command-line tool to help you create Docker environments on your computers or cloud providers.

ref:
https://docs.docker.com/machine/

Installatino on Mac

$ curl -L https://github.com/docker/machine/releases/download/v0.3.0/docker-machine_darwin-amd64 > /usr/local/bin/docker-machine
$ chmod +x /usr/local/bin/docker-machine

Usage

$ docker-machine ls

$ docker-machine create --driver virtualbox dev

# list arguments for creating a VirtualBox VM
$ docker-machine create -d virtualbox

# see how to connect Docker to this machine
$ docker-machine env dev

# run this command to configure your shell
$ eval "$(docker-machine env dev)"

# then
$ docker info

Issues

Error response from daemon: client and server don't have same version (client : 1.19, server: 1.18)

$ docker-machine upgrade dev
Install Go (Golang)

Install Go (Golang)

Go is a programming language created by Google.

ref:
https://golang.org/

Installation

on Ubuntu:

$ sudo apt-get install -V golang

# or

$ wget https://dl.google.com/go/go1.10.1.linux-amd64.tar.gz
$ tar -C /usr/local -xzf go1.10.1.linux-amd64.tar.gz
$ vim /etc/profile
export PATH=$PATH:/usr/local/go/bin

$ which go

on macOS:

$ brew install go

$ go env
GOCACHE="/Users/vinta/Library/Caches/go-build"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/vinta/go"
GOROOT="/usr/local/Cellar/go/1.10/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.10/libexec/pkg/tool/darwin_amd64"
...

ref:
https://golang.org/dl/

Environment Variables

  • GOPATH is your workspace.
    • go get fetches source code and puts them into $GOPATH/src.

ref:
https://golang.org/doc/code.html

nvm: Node.js Version Manager

Install nvm

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash

ref:
https://github.com/creationix/nvm

Install Node.js

$ nvm install --lts

$ nvm install 4.8.1 && \
  nvm use 4.8.1 && \
  nvm alias default 4.8.1

# 列出所有安裝的版本
$ nvm ls

# 列出總共有哪些版本可以安裝
$ nvm ls-remote

Install Packages by npm (Node Packaged Manager)

# 會安裝到當前目錄的 node_modules 目錄底下
# 適合 node.js project
$ npm install express

# 會安裝到 ~/.nvm/vx.x.x/lib
$ npm install -g coffee-script

$ npm update -g bower

$ npm uninstall -g grunt-cli

# 查看安裝了哪些 lib
# 類似 pip list
$ npm ls
$ npm ls -g
$ npm ls --depth=0

$ npm search underscore

ref:
http://book.nodejs.tw/zh-tw/node_npm.html
https://npmjs.org/doc/