-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
guoqiang1
committed
Oct 21, 2020
0 parents
commit 548347e
Showing
11 changed files
with
1,052 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# syntax=docker/dockerfile:experimental | ||
FROM ubuntu:16.04 | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
ENV TERM=xterm-256color | ||
|
||
RUN echo "dash dash/sh boolean false" | debconf-set-selections && \ | ||
dpkg-reconfigure dash | ||
|
||
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list \ | ||
&& apt clean | ||
|
||
RUN --mount=type=cache,sharing=locked,id=aptlib,target=/var/lib/apt \ | ||
--mount=type=cache,sharing=locked,id=aptcache,target=/var/cache/apt \ | ||
apt update && apt install -y --no-install-recommends \ | ||
autoconf \ | ||
automake \ | ||
autotools-dev \ | ||
bison \ | ||
build-essential \ | ||
ctags \ | ||
curl \ | ||
docker.io \ | ||
flex \ | ||
gdb \ | ||
global \ | ||
git \ | ||
htop \ | ||
libevent-dev \ | ||
liblua5.2-dev \ | ||
libncurses5 \ | ||
libncurses5-dev \ | ||
libperl-dev \ | ||
libreadline-dev \ | ||
libssl1.0.0 \ | ||
locales \ | ||
lsb-release \ | ||
lua5.2 \ | ||
m4 \ | ||
man \ | ||
nasm \ | ||
openssh-server \ | ||
openssl \ | ||
pkg-config \ | ||
psutils \ | ||
silversearcher-ag \ | ||
software-properties-common \ | ||
sudo \ | ||
wget \ | ||
zsh && \ | ||
apt clean && rm -rf /var/lib/apt/lists/* | ||
|
||
# python3.7 | ||
RUN add-apt-repository -y ppa:deadsnakes/nightly && \ | ||
apt update && \ | ||
apt install -y python3.7 python3.7-dev python3.7-venv python3.7-distutils && \ | ||
apt clean && rm -rf /var/lib/apt/lists/* && \ | ||
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 35 && \ | ||
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 37 | ||
|
||
# pip | ||
RUN curl https://bootstrap.pypa.io/get-pip.py | python3 | ||
|
||
# vim & tmux | ||
RUN --mount=type=tmpfs,target=/tmp \ | ||
# vim 8.2 \ | ||
pushd /tmp && \ | ||
git clone --depth 1 --branch v8.2.1862 https://github.com/vim/vim.git && \ | ||
pushd vim && \ | ||
./configure \ | ||
--prefix=/usr/local \ | ||
--with-features=huge \ | ||
--enable-multibyte \ | ||
--enable-python3interp=yes \ | ||
--with-python3-config-dir='/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu' \ | ||
--enable-perlinterp=yes \ | ||
--enable-luainterp=yes \ | ||
--enable-cscope && make -j$(nproc) install && \ | ||
popd && \ | ||
# tmux 2.6 \ | ||
git clone --depth 1 --branch 2.6 https://github.com/tmux/tmux.git && \ | ||
pushd tmux && \ | ||
bash ./autogen.sh && ./configure --prefix=/usr/local && make -j$(nproc) install && \ | ||
popd && \ | ||
# su-exec \ | ||
git clone https://github.com/ncopa/su-exec.git && \ | ||
pushd su-exec && \ | ||
make && cp su-exec /sbin && \ | ||
popd | ||
|
||
# add user | ||
RUN useradd -ms /bin/zsh guoqiang && \ | ||
echo "guoqiang:a" | chpasswd && \ | ||
echo 'guoqiang ALL=(ALL:ALL) ALL' >> /etc/sudoers | ||
WORKDIR /home/guoqiang | ||
ENV HOME /home/guoqiang | ||
|
||
# oh-my-zsh | ||
RUN bash -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && \ | ||
git clone https://github.com/zsh-users/zsh-autosuggestions $HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions && \ | ||
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting && \ | ||
find $HOME/.oh-my-zsh -name .git | xargs rm -rf | ||
|
||
# vim | ||
COPY /dotfiles/vimrc .vimrc | ||
RUN curl -fLo $HOME/.vim/autoload/plug.vim --create-dirs \ | ||
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim && \ | ||
vim +PlugInstall +qall && \ | ||
find $HOME/.vim/plugged/YouCompleteMe -name 'libclang-*.tar.*' -delete | ||
# find $HOME/.vim/plugged -name .git | xargs rm -rf && | ||
|
||
COPY /ycm_extra_conf.py .ycm_extra_conf.py | ||
COPY /dotfiles/tmux.conf .tmux.conf | ||
COPY /dotfiles/zshrc .zshrc | ||
COPY /dotfiles/UltiSnips .vim/UltiSnips | ||
|
||
# locales | ||
ENV LANGUAGE=en_US.UTF-8 | ||
ENV LANG=en_US.UTF-8 | ||
ENV LC_ALL=en_US.UTF-8 | ||
RUN locale-gen en_US.UTF-8 && dpkg-reconfigure locales | ||
|
||
# git config | ||
RUN git config --global user.name "gq" && \ | ||
git config --global user.email "gq" | ||
|
||
RUN mkdir -p $HOME/.pip && \ | ||
echo "[global]" > $HOME/.pip/pip.conf && \ | ||
echo "http://mirrors.aliyun.com/pypi/simple/" >> $HOME/.pip/pip.conf && \ | ||
pip3 install -U --no-cache-dir \ | ||
cmake \ | ||
ipdb \ | ||
jupyter \ | ||
matplotlib \ | ||
numpy \ | ||
opencv-python \ | ||
six \ | ||
tqdm | ||
|
||
# entrypoint | ||
COPY entrypoint.sh /bin/entrypoint.sh | ||
ENTRYPOINT ["/bin/entrypoint.sh"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
image_name := gqdev | ||
|
||
build: | ||
DOCKER_BUILDKIT=1 docker build -t $(image_name) . |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This repo collects useful snippets. | ||
|
||
Add `let g:UltiSnipsSnippetsDir="~/.vim/UltiSnips"` to `~/.vimrc`. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
snippet msg "message" b | ||
message(STATUS "$1=\$\{${1}\}")$0 | ||
endsnippet | ||
|
||
snippet blk "block" b | ||
$1 ($2) | ||
$3 | ||
end$1() | ||
endsnippet | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
snippet todo "single line todo" b | ||
// TODO: $1 | ||
endsnippet | ||
|
||
snippet usestd "using namespace std" b | ||
using namespace std; | ||
endsnippet | ||
|
||
snippet using "using" b | ||
using std::$1; | ||
endsnippet | ||
|
||
snippet loginfo "LOG(INFO)" b | ||
LOG(INFO) << "$1"; | ||
endsnippet | ||
|
||
snippet vec "vector<..." w | ||
vector<$1> $0 | ||
endsnippet | ||
|
||
snippet vv "vector<vector<..." w | ||
vector<vector<$1>> $0 | ||
endsnippet | ||
|
||
snippet begend "begend" w | ||
${1:v}.begin(), $1.end() | ||
endsnippet | ||
|
||
snippet cfor "for ( : )" | ||
for (const auto &$1 : $2)$0 | ||
endsnippet | ||
|
||
snippet cauto "const auto &" w | ||
const auto& | ||
endsnippet | ||
|
||
snippet ptr "shared_ptr" | ||
shared_ptr<$1> $0 | ||
endsnippet |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
#! header | ||
snippet #! "Shebang header for python scripts" b | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
$0 | ||
endsnippet | ||
|
||
|
||
snippet nphead "import np and plt" b | ||
import numpy as np | ||
import matplotlib | ||
matplotlib.use('Agg') | ||
import matplotlib.pyplot as plt | ||
import cv2 | ||
endsnippet | ||
|
||
snippet argparse "ArgumentParser head" b | ||
from argparse import ArgumentParser | ||
|
||
def parse_args(): | ||
parser = ArgumentParser() | ||
args = parser.parse_args() | ||
return args | ||
endsnippet | ||
|
||
snippet osp "import os.path" b | ||
import os.path as osp | ||
endsnippet | ||
|
||
snippet savefig "plt save figure" b | ||
plt.savefig($1) | ||
endsnippet | ||
|
||
snippet glob "glob" b | ||
from glob import glob | ||
endsnippet | ||
|
||
snippet time "time" b | ||
from time import time | ||
endsnippet | ||
|
||
snippet logging "logging" b | ||
import logging | ||
|
||
logging.basicConfig(format='[%(filename)s:%(lineno)d] %(message)s', level=logging.INFO) | ||
endsnippet | ||
|
||
snippet mkdir "make_dir" b | ||
if not osp.isdir($1): | ||
os.makedirs($1) | ||
endsnippet | ||
|
||
snippet addarg "addarg" b | ||
parser.add_argument('--$1') | ||
endsnippet | ||
|
||
snippet loginfo "loginfo" b | ||
logging.info('$1'.format($2))$0 | ||
endsnippet | ||
|
||
snippet logdebug "logdebug" b | ||
logging.debug('$1'.format($2))$0 | ||
endsnippet | ||
|
||
snippet logwarn "logwarning" b | ||
logging.warning('$1') | ||
endsnippet | ||
|
||
snippet logerror "logerror" b | ||
logging.error('$1') | ||
endsnippet | ||
|
||
snippet np "np" b | ||
import numpy as np | ||
endsnippet | ||
|
||
snippet subplot "subplot" b | ||
plt.subplot(M, N, $1) | ||
endsnippet | ||
|
||
snippet figure "figure" b | ||
M, N = 1, 1 | ||
h_fig = plt.figure(figsize=(N*5, M*5), dpi=150, tight_layout=True) | ||
plt.savefig($1) | ||
plt.close(h_fig) | ||
endsnippet | ||
|
||
snippet mpi "mpi" b | ||
from mpi4py import MPI | ||
|
||
comm = MPI.COMM_WORLD | ||
MPI_rank = comm.Get_rank() | ||
MPI_size = comm.Get_size() | ||
endsnippet | ||
|
||
snippet readlines "readlines" b | ||
with open($1) as f: | ||
lines = f.readlines() | ||
$0 | ||
endsnippet | ||
|
||
snippet writelines "writelines" b | ||
with open($1, 'w') as f: | ||
f.writelines($2) | ||
$0 | ||
endsnippet | ||
|
||
snippet embed "IPython embed" b | ||
from IPython import embed; embed(colors='linux') | ||
endsnippet | ||
|
||
snippet imread "cv2.imread" b | ||
im = cv2.imread(${1:im_p})[..., ::-1] | ||
endsnippet | ||
|
||
snippet plot "plt.plot" b | ||
plt.plot($1) | ||
endsnippet | ||
|
||
snippet pprint "pprint" b | ||
from pprint import pprint, pformat | ||
endsnippet | ||
|
||
snippet random "np.random.random" w | ||
np.random.random($1) | ||
endsnippet | ||
|
||
snippet filehead "osp, glob" b | ||
import os.path as osp | ||
from glob import glob | ||
endsnippet | ||
|
||
snippet mn "mn" w | ||
osp.splitext(osp.basename($1))[0]$0 | ||
endsnippet | ||
|
||
snippet dot "sys.stdout.write('.')" b | ||
sys.stdout.write('${1:.}') | ||
sys.stdout.flush() | ||
endsnippet | ||
|
||
snippet future "__future__" b | ||
from __future__ import absolute_import , division, print_function | ||
endsnippet | ||
|
Oops, something went wrong.