tips

personal snipetts – under construction

find/grep で検索

$ find . -name ".git" -prune -o -name "*.py" -print0 \
  | xargs -0r grep -in some

smb をマウント

# dnf install cifs-utils

# cat > /etc/samba_cred
username=username
password=password
domain=domain
# chmod 0700 /etc/samba_cred

# mount -t cifs //machine-name/Document /mnt \
  -o credentials=/etc/samba_cred,uid=1000,gid=1000,netbiosname=machine-name,iocharset=utf8,rw

Java

雑にプロジェクトを作る

要 Maven/Gradle

> mvn.cmd archetype:generate -B "-DarchetypeGroupId=org.springframework.boot" `
    "-DarchetypeArtifactId=spring-boot-sample-simple-archetype" `
    "-DgroupId=io.github.jptomo" "-DartifactId=example" "-Dversion=0.0.1-SNAPSHOT" "-DinteractiveMode=false"
> cd example
> gradle init --type pom

closure-linter をインストールする

$ python -m pip install -U install git+https://github.com/google/closure-linter#egg=closure-linter

MySQL dump で圧縮してダンプする

$ mysqldump -u user -p -h host --default-character-set=binary \
  -c --compact -n -t dbname tables \
  | gzip > mysqldump-`date +%Y_%m%d_%H%M%S`.sql.gz

Java

Linux に Official Java をインストールする

$ curl -OL -b "oraclelicense=accept-securebackup-cookie" \
  http://download.oracle.com/otn-pub/java/jdk/8u112-b15/jdk-8u112-linux-x64.tar.gz
$ tar xf jdk-8u112-linux-x64.tar.gz
$ sudo mkdir -p /usr/java
$ sudo mv jdk1.8.0_112 /usr/java/
$ sudo alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_112/jre/bin/java 1
$ sudo alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_112/bin/javac 1
$ sudo sh -c 'cat >> /etc/environment'
JAVA_HOME=/usr/java/jdk1.8.0_112
JRE_HOME=/usr/java/jdk1.8.0_112/jre

Docker

特定の Dockerfile でビルド

$ docker build -t local-xxx -f Dockerfile .

コンテナ削除

$ docker rm `docker ps -a -q`

(none) image 削除

$ docker rmi `docker images | awk '/^<none>/ { print $3 }'`