Tao He

Tao He

  • Docs
  • API
  • Help
  • Blog

›Recent Posts

Recent Posts

  • Microsoft PowerPoint
  • Chrome
  • Alfred
  • Docusaurus
  • Git Commands

Qt Library

June 2, 2014

{% include JB/setup %}

Creating Shared Libraries

Qt Console I/O

June 2, 2014

{% include JB/setup %}

QT 控制台输出

输出最后一定要加endl之类的清空流,否则不会显示。这跟VC不同,VC最后总会输出流的所有内容。

Linux Wakeonlan

June 2, 2014

{% include JB/setup %}

Ubuntu下是wakeonlan

CentOS下是wol

linux远程开机

Linux SVN

June 2, 2014

{% include JB/setup %}

linux常用svn命令

Linux Network

June 2, 2014

{% include JB/setup %}

基于Linux Socket实现的网卡抓包程序

IP包头部格式

Encode

June 2, 2014

{% include JB/setup %}

字符编码笔记:ASCII,Unicode和UTF-8

关于URL编码

Backtrack

June 2, 2014

{% include JB/setup %}

vlc

apt-get install vlc vlc-plugin-pulse mozilla-plugin-vlc
cp /usr/bin/vlc /usr/bin/vlc.bak
hexedit /usr/bin/vlc

Use "Tab" key to start ascii string editing. Then press "/" key. Input the search keyword below.

change from

geteuid._libc_start_main

to

getppid.libc_start_main

Press "Ctrl+X" to save and exit.

Some useful command for hexedit

chromium

apt-get install chromium-browser

Then modify the hex of "/usr/lib/chromium-browser/chromium-browser", which is almost the same as vlc.

Docker

April 26, 2014

{% include JB/setup %}

Installation

Ubuntu

Get Docker CE for Ubuntu

sudo apt-get remove docker docker-engine docker.io
sudo apt-get update
sudo apt-get install \
    linux-image-extra-$(uname -r) \
    linux-image-extra-virtual
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
sudo apt-get update
sudo apt-get install docker-ce
sudo docker run hello-world

Manage Docker as a non-root user

sudo groupadd docker
sudo usermod -aG docker $USER

Start Docker

docker version
docker images
docker ps -a

macOS

Start Docker

export DOCKER_HOST=tcp://localhost:4243
docker
docker version
docker images
docker ps -a

Work

docker login
docker search centos
docker search ubuntu
docker pull centos
docker pull ubuntu

AWS

sudo yum install docker
sudo service docker restart

Build Image

vim Dockerfile
docker build --rm -t app_server .
docker images

Run Container from Image

CentOS

docker run -it --name=centos_1 centos bash  # run and exec shell
docker exec -it centos_1 bash  # exec another shell

Ubuntu

docker run -it --name=ubuntu_1 ubuntu bash  # run and exec shell
docker exec -it ubuntu_1 bash  # exec another shell

Run as daemon

docker run -itd --name=ubuntu_2 ubuntu bash
docker attach ubuntu_2
# press up arrow to show shell
# after operation, press Ctrl+P Ctrl+Q to detach

Remove Containers and Images

docker will NOT remove dead containers. Remove them manually is needed.

Stop container

docker stop CONTAINER_NAME_OR_ID

Remove container

docker rm CONTAINER_NAME_OR_ID

Remove all stopped containers

docker rm $(docker ps -a -q)

Remove image

docker rmi IMAGE_NAME_OR_ID

Remove all untagged images

docker rmi $(docker images | grep "^<none>" | awk "{print $3}")

Remove Untagged Images From Docker

SSH

In host

vim Dockerfile
docker build --rm -t eg_sshd .
docker run -P --name=test_sshd eg_sshd

In container

/usr/sbin/sshd
adduser taohe

In host

docker port test_sshd 22
# mark down the port of localhost
ssh taohe@localhost -p 49154

In container

apt-get install netcat
kill 13  # kill sshd to release port 22
nc -p 22 -l -vv  # for linux (netcat-traditional)
nc 22 -l -v  # for macos (netcat-openbsd)
netstat -ntlp | grep nc

In host

nc localhost 49154 -vv  # for linux (netcat-traditional). no `-p`!
nc localhost 49154 -v  # for macos (netcat-openbsd)
curl localhost:49154

Dockerize an SSH service

macOS上的Docker Container与主机通讯

  1. 确保Dockerfile里面暴露了端口,如EXPOSE 1883
  2. docker build --rm -t test_docker .
  3. docker run -P -it --name=test_docker_1 test_docker bash
  4. docker network inspect bridge确认包含test_docker_1,记录IP地址
  5. docker port test_docker_1 1883或者docker ps -a记录端口
  6. 本地用地址localhost和上面记录的端口连接

Comparing --expose/EXPOSE and -p

Network

docker network ls
docker network inspect bridge

Shell Access

docker exec -it some-mysql bash

Commit

Commit container changes to image

docker commit CONTAINER_NAME_OR_ID IMAGE_NAME

File

docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH

Docker Hub

Firstly, create a repository on Docker Hub.

In order to push a repository to the Docker Hub, you need to name your local image using your Docker Hub username and the repository name.

docker tag phx:latest phxtest/phxtest:latest
docker push phxtest/phxtest
docker pull phxtest/phxtest  # test

Clean useless data

Large data remain in /var/lib/docker/aufs/ and /var/lib/docker/volumes/.

docker volume ls -qf dangling=true | xargs -r docker volume rm

https://lebkowski.name/docker-volumes/

MySQL

Start server

docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=000000 -d mysql:5.7

Shell access

docker exec -it some-mysql bash
mysql -h localhost -P 3306 -u root -p

If failed, view logs

docker logs some-mysql

Start client

# $MYSQL_PORT_3306_TCP_ADDR is the MySQL server IP that get from
# `docker network inspect bridge` or
# `docker inspect some-mysql | grep IP`
docker run -it --rm mysql:5.7 sh -c 'exec mysql -h "$MYSQL_PORT_3306_TCP_ADDR" -P 3306 --protocol=tcp -u root -p'

MySQL

sameersbn (deprecated)

https://github.com/sameersbn/docker-mysql

docker pull sameersbn/mysql
docker stop mysql && docker rm mysql
docker run --name mysql -d -p 3306:3306 -v ~/mnt:/mnt -v ~/etc/mysql:/etc/mysql -v ~/var/lib/mysql:/var/lib/mysql sameersbn/mysql
docker ps -a
docker run -it --rm --volumes-from=mysql sameersbn/mysql mysql -uroot
docker inspect mysql | grep IP

Java

https://github.com/dockerfile/java

docker pull dockerfile/java
docker nohup run -it --rm -w /workspace/bin -v ~/workspace/bin:/workspace/bin dockerfile/java:oracle-java8 java -jar /workspace/bin/weibominer.jar uid 1000000000L 4 &

dive

dive

A tool for exploring each layer in a docker image

brew tap wagoodman/dive
brew install dive

Microsoft Word

April 15, 2014

{% include JB/setup %}

Underline the Space After a Word in Microsoft Word

One way is to type a non-breaking space (Ctrl+Shift+Spacebar) at the end of the line, select from the end of word to the end of the line, and then apply underline.

A better way is to set a tab with underline leader at the right margin, and then you can press Tab after the end of word to create an underline to the right margin. This method is better (and faster) than using underlined spaces because the underline will end evenly at the right margin, whereas underlined spaces tend to be slightly uneven at the right margin.

How do I underline the space AFTER a word in Microsoft Word?

Microsoft Word Citation and Bibliography Styles

April 7, 2014

{% include JB/setup %}

Citation and Bibliography Using Word

how to create a bibliography using word

Using My PKU Style

Office 2013

Copy PKU_IEEE_Reference.XSL to %APPDATA%\Roaming\Microsoft\Bibliography\Style.

Office 2010 or older

Copy PKU_IEEE_Reference.XSL to %OFFICE_INSTALL_DIR%\Office1x\Bibliography\Style.

Create Custom Styles

If you want to create your custom styles, do this.

Download BibWord

Download styles.zip and put it under %APPDATA%\Roaming\Microsoft\Bibliography\Style.

BibWord

Office 2013

Copy IEEE_Reference.XSL to %APPDATA%\Roaming\Microsoft\Bibliography\Style. Rename and modify it as PKU_IEEE_Reference.XSL

Office 2010 or older

Copy IEEE_Reference.XSL to %OFFICE_INSTALL_DIR%\Office1x\Bibliography\Style. Rename and modify it as PKU_IEEE_Reference.XSL

How to: Create Custom Bibliography Styles

← PrevNext →
Tao He
Docs
Getting Started (or other categories)Guides (or other categories)API Reference (or other categories)
Community
User ShowcaseStack OverflowProject ChatTwitter
More
BlogGitHubStar
Facebook Open Source
Copyright © 2019 Your Name or Your Company Name