2015年8月29日 星期六

Run Commands Remotely via SSH with No Password

1. Generate SSH key pair: ssh-keygen -t rsa
you will get a id_rsa.pub file in .ssh/


2. add content in id_rsa.pub to remote server .ssh/authorized_keys file

2015年8月25日 星期二

Docker tips

Installation:
  • Mac: https://docs.docker.com/installation/mac/
  • Ubuntu: curl -sSL https://get.docker.com/ubuntu/ | sudo sh 
  • Linux: wget -qO- https://get.docker.com/ | sudo sh
  • CentOS: 
    • sudo tee /etc/yum.repos.d/docker.repo <<- span="">'EOF' [dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/ enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg EOF
    • sudo yum install docker-engine
    • sudo service docker start
CA not find error:
> unset ${!DOCKER*}

Start/Stop docker service: service docker start/stop

Build image: docker build -t="test:latest" .
List images: docker images
Run a command in a new container:

  • docker run -it -p 8888:8080 -d test:latest
  • docker run -it --rm -p 8888:8080 test:latest
  • docker run -w /ICADL icadl:latest bash -c "python dockertest.py"

List containers: docker ps
Connect to running docker container: docker exec -i -t "IMAGE ID" /bin/bash
Stop containers: docker stop $(docker ps -a -q)

Remove image: docker rmi "IMAGE ID"
Remove containers: docker rm $(docker ps -a -q)
Removing all unused docker images: docker images -q |xargs docker rmi

Docker hub commands:
Push docker image:
  • docker tag 515ba39974ef test/icadl:version1
  • docker push test/icadl
Recreate default env
  • docker-machine rm default
  • docker-machine create default --driver virtualbox
  • eval $(docker-machine env default)
Show docker-machine ip
  • docker-machine ip
Docker-compose command

  • rebuild image: docker-compose build or docker-compose up --build
  • docker-compose up -d 
  • docker-compose stop 
  • docker-compose rm -f

2015年8月24日 星期一

grep commands

Search within a directory:
  • Show both file and matched string: 
    • grep -R text /home/users/workspace
    • grep -lir text /home/users/workspace 
  • Show only file: grep -Rl text /home/users/workspace
  • Grep and append string: more musiclist.txt | grep ecx | sed -e 's/^/wget /' 
  • Append a string on the every line from the grep result.
    • ls -a | grep "Vol_" | perl -ne 'print "zip $_"'
    • ls -a | grep "rar" | perl -ne 'print "unrar x $_"'
  • Grep than replace string: 
    • grep -rl matchstring somedir/ | xargs sed -i 's/string1/string2/g'
    • grep -rl 'windows' ./ | xargs sed -i 's/windows/linux/g'

2015年8月23日 星期日

Time machine commands

List paths to all of the computer's backups: sudo tmutil listbackups

Delete a backup: sudo tmutil delete "path to the backup file"


2015年8月22日 星期六

IBM Bluemix - Virtual Machines

1. Start virtual machines. Go to dashboard and click run virtual machines

2. Select VM size, create security key, select image, and create your VM group

3. You can see your VMs in the dashboard
4. Click the VM to see the detail of that VM

5. You can scale up and scale down the VM


2015年8月20日 星期四

TACC tips

TACC user guidehttps://portal.tacc.utexas.edu/user-guides

Stampede:
  • Environment:
    • $HOME: 
      • Use the environment variable $HOME to reference your home directory in scripts.
      • Use the "cdh" or "cd" commands to change to $HOME .
    • $WORK:
      • Use the environment variable $WORK to reference this directory in scripts.
      • Use "cdw" to change to $WORK.
    • $SCRATCH
      • Use $SCRATCH to reference this directory in scripts.
      • Use the "cds" command to change to $SCRATCH.
  • Python:
    • load module: module load python, module load hdf5, module load
      matplotlib
  • Submit job:
    • sbatch thescript
  • Check queue:
    • showq -u userid
    • squeue -u userid

2015年8月19日 星期三

Java installation

Java 8 installation:

Ubuntu:
> sudo add-apt-repository ppa:webupd8team/java
> sudo apt-get update
> sudo apt-get install oracle-java8-installer


2015年8月18日 星期二

Virtual Box Tips

CentOS7 installation:
  1. yum install qt
  2. yum install qt-x11.x86_64 
  3. rpm -Uvh VirtualBox-5.0-5.0.2_102096_el7-1.x86_64.rpm

Export VM into file: VBoxManage export win8 --output win8.ova
List VMs: VBoxManage list vms

Port forward:




2015年8月16日 星期日

Apple 常用設定與軟體

MacBook 快速鍵設定
Spaces setup: setup the mouse setting to mouse 4.
Dock setup: Add/Delete icons. Just drag in/out icons.
Dashboard setup: click little i in each widget.
Function key: press fn + F12 for example.
Mac 同程式內不同視窗切換:command-`(1左邊那個符號鍵)
Mac Page Up/Down/Home/End:fn + 上下左右
Safari 上下頁切換: Apple + [ 上一頁,Apple + ] 下一頁
Command+Alt+Esc:Windows Ctrl+Alt+Del
螢幕放大縮小:放大螢幕 Command+option+加號。縮小螢幕 Command+option+減號。

MacBook 好用的軟體:
Chmox: 看.chm檔案的軟體 http://chmox.sourceforge.net/
CoRD: 遠端連線Windows軟體 http://cord.sourceforge.net/
Cyberduck: SFTP http://cyberduck.ch/
DiskAid: 將檔案從電腦傳到 iPhone or Touch http://www.digidna.net/diskaid/
Dvd2onex2: DVD 燒入軟體 http://www.dvd2one.com/ note
HandBrake: 將影片轉成IPhone/Touch 可看的格式 http://handbrake.fr/
iWork: Replace existing com.apple.iWork09.Installer.plist file in Macintosh HD > Library > Preferences with the included plsit. (Or edit the existing com.apple.iWork09.Installer.plist and change InstallMode from "Trial" to "Retail"
Nally: BBS 連線軟體 http://yllan.org/app/Nally/
Paparazz!: 將網頁轉成圖檔 http://derailer.org/paparazzi/
Skitch: 抓圖軟體: https://skitch.com/
Tooble: 將youtube的影片儲存於iPhone & iTouch http://tooble.tv/
Unarchiver: 解壓縮軟體 http://wakaba.c3.cx/s/apps/unarchiver.html
Xee: 很好的看圖軟體http://wakaba.c3.cx/s/apps/xee.html
Fetchy: 下載YouTube影片 https://fetchy.io/

相關文章:
MacUknow:必備軟體 http://www.macuknow.com/essentialapps

MacBook 使用小技巧

1. 將選單列和Dock放在延伸螢幕上,打開"系統偏好設定"裡頭的"顯示器">"排列方式",然後將圖片中紅框所示的白色Bar拖拉過去你要的螢幕上,那麼選單列和Dock就會跑到那個螢幕上。

參考來源:MacUknow

2. 中文繁簡切換: http://www.macuknow.com/node/229 ps. 基本原則選擇 Services -> ChineseTextConverter -> 繁to簡 or 簡to繁

3. 快速建立捷徑:按住 Apple + Alt 然後拖住要建立捷徑的應用程式到你想要的地方。

Install xrdp in Ubuntu 14.04 and CentOS 7 for remote desktop

Ubuntu 14.04:
Prerequisites:
  • Update OS: sudo apt-get update & upgrade -y
  • Install gnome desktop : sudo apt-get install ubuntu-gnome-desktop -y
Install xrdp:

  1. sudo apt-get install xrdp
  2. sudo apt-get install xfce4 -y
  3. echo xfce4-session >~/.xsession
  4. sudo service xrdp restart


CentOS 7:
Prerequisites:
  • Update OS: sudo yum update
  • Install gnome desktop : sudo yum groupinstall "GNOME Desktop" "Graphical Administration Tools"
Install xrdp:
  • Create a repository file: 
    1. vi /etc/yum.repos.d/xrdp.repo
    2. add these content into that file
      [xrdp]
      name=xrdp
      baseurl=http://li.nux.ro/download/nux/dextop/el7/x86_64/
      enabled=1
      gpgcheck=0
    3. yum -y install xrdp tigervnc-server
  • Start xrdp service: systemctl start xrdp.service
  • Enable service at startup: systemctl enable xrdp.service
  • Config firewall: 
    1. firewall-cmd --permanent --zone=public --add-port=3389/tcp
    2. firewall-cmd --reload
  • Configure SELinux:
    1. chcon --type=bin_t /usr/sbin/xrdp
    2. chcon --type=bin_t /usr/sbin/xrdp-sesman
Resume to the same connection:
  1.  sudo vi /etc/xrdp/xrdp.ini
[xrdp1] 
name=sesman-vnc 
lib=libvnc.so 
username=ask 
password=ask 
ip=127.0.0.1 
port=-1  ⇐ change to 5912, so the connect will resume.

2015年8月15日 星期六

Tech/Tool links



Javascripts:
Meteor, the JavaScript App Platform: https://www.meteor.com/

Python:
Flask, a microframework for Python: http://flask.pocoo.org/
Testing frameworks:


Tools:
Upsidedown, make word upside down: http://www.upsidedowntext.com/
VS code: https://code.visualstudio.com/
Business plan: http://leanstack.com/
Diffchecker: https://www.diffchecker.com/diff
XML viewer: http://codebeautify.org/xmlviewer

Programming language tutorials:

Java:

Vision Control System:

Google: