Skip to content

Instantly share code, notes, and snippets.

View wastemobile's full-sized avatar

wastemobile wastemobile

View GitHub Profile
#!/bin/bash
# install xcode command tool
xcode-select --install
# check
xcode-select -p
# install brew
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

Vagrant 可以配置本地開發環境(虛擬機),同時管理遠端主機(Digital Ocean),在一個專案目錄下、只用一個 Vagrantfile。

首先安裝外掛:

vagrant plugin install vagrant-digitalocean

if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
function git_since_last_commit {
@wastemobile
wastemobile / helloHtml.js
Last active April 29, 2017 01:52
一個檔案理解 Node for Web
var http = require('http'),
fs = require('fs');
function serveStaticFile(res, path, contentType, responseCode) {
if(!responseCode) responseCode = 200;
fs.readFile(__dirname + path, function(err, data){
if(err) {
res.writeHead(500, {'Content-Type': 'text/plain'});
res.end('500 - Internal Error');
} else {
@wastemobile
wastemobile / nginx_with_ssl.md
Last active May 13, 2018 20:01
Nginx + Let's Encrypt
@wastemobile
wastemobile / dailyupdate
Last active February 12, 2019 01:39
Daily Update Script for Mac
#!/bin/bash
echo "Update Homebrew"
echo "brew update && brew upgrade --all"
brew update && brew upgrade
echo "brew cleanup"
brew cleanup -s
echo "Update NPM global"
@wastemobile
wastemobile / prototype.md
Created June 12, 2019 15:09
Hugo prototype with Pipes #hugo
@wastemobile
wastemobile / npmlist.md
Last active June 19, 2019 02:26
npm #node
@wastemobile
wastemobile / .env
Last active February 29, 2020 15:49
Django settings
# dev
SECRET_KEY=4(hf^my1$a*dwf^78^x0zl-z)*)p&)40z#o307o*)p_x2ker^v
DEBUG=True
ALLOWED_HOSTS=.localhost,127.0.0.1
# for PostgreSQL
# DATABASE_URL=postgres://dba:password@localhost:5432/db
# for Gmail
# EMAIL_BACKEND="django.core.mail.backends.console.EmailBackend"
@wastemobile
wastemobile / Initial.md
Last active March 20, 2020 07:02
Ubuntu 18.04 on Linode Initial

由 Linode 後台介面新增主機時,會要求設置 root 密碼,也可以增加 SSH Key、讓 root 能使用 SSH Key 無密碼登入,由於後面會關閉 root 的登入權限,因此選擇不設置金鑰。

新增用戶

  1. ssh root@your_ip 以 root 身份登入乾淨的新創主機
  2. adduser new_user 建立例行登入使用的新用戶,設置密碼與必要資訊
  3. adduser new_user sudo 將新用戶加入 sudo 群組
  4. 先不要關閉 root 登入的終端機視窗,另開一個新視窗
  5. ssh-copy-id -i ~/.ssh/id_ed25519.pub new_user@your_ip 替新用戶增加公鑰
  6. ssh new_user@your_ip 確認新用戶能以金鑰模式登入無誤