檢視主機名稱

使用 hostnamectl 來檢視主機名稱相關資訊,如下:

1
2
3
4
5
6
7
8
9
10
11
12
root@bobochen-vm [01:22:14 AM] [~]
-> $ hostnamectl
Static hostname: bobochen-vm
Icon name: computer-vm
Chassis: vm
Machine ID: OOOXXX78a943ae8f3cc26602e3
Boot ID: OOOXXXc0a48a89974cb4b6a66a
Virtualization: xen
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-327.22.2.el7.x86_64
Architecture: x86-64

來看一下官方手冊說明:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
NAME
hostnamectl - Control the system hostname
SYNOPSIS
hostnamectl [OPTIONS...] {COMMAND}
DESCRIPTION
hostnamectl may be used to query and change the system hostname and related settings.
This tool distinguishes three different hostnames: the high-level "pretty" hostname which might include all kinds of special characters
(e.g. "Lennart's Laptop"), the static hostname which is used to initialize the kernel hostname at boot (e.g. "lennarts-laptop"), and
the transient hostname which is a default received from network configuration. If a static hostname is set, and is valid (something
other than localhost), then the transient hostname is not used.
Note that the pretty hostname has little restrictions on the characters used, while the static and transient hostnames are limited to
the usually accepted characters of Internet domain names.
The static hostname is stored in /etc/hostname, see hostname(5) for more information. The pretty hostname, chassis type, and icon name
are stored in /etc/machine-info, see machine-info(5).
Use systemd-firstboot(1) to initialize the system host name for mounted (but not booted) system images.

修改主機名稱

使用 hostnamectl set-hostname [Host Name] 來修改主機名稱

1
$ hostnamectl set-hostname server-www1

設定後,我們可以再用 hostnamectl 檢查看看是否生效。

前言

.DS_Store 是 Mac 的一種隱藏文件資料檔,目的在於存貯目錄的自定義屬性。
專案在使用 Git 追蹤時,在沒有注意下很容易不小心就出現一堆 .DS_Store 已經被 Git 追蹤。
例如這個專案,在使用 git status 檢視目前狀態就會發現…

1
2
3
4
5
modified: .DS_Store
modified: app/.DS_Store
modified: bootstrap/.DS_Store
modified: database/.DS_Store
modified: storage/.DS_Store

如何移除掉已經被 git 追蹤的檔案

可以使用 git rm -f 來移除掉特定的檔案類型

例如:git rm -f *.DS_Store

如果要移除 repository 內所有的 .DS_Store 檔案
find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch

參考來源

作者介紹

Dave Thomas 是一位程式設計師,他喜歡分享很酷的玩意兒。他是「The Pragmatic Programmer」這本書的共同作者,也是「Manifesto for Agile Software Development」 敏捷軟體開發宣言的簽署者之一。
他寫的「Programming Ruby」這本書,使得更多人認識 Ruby 這個程式語言,並且開啟了使用 Rails 框架來進行網頁敏捷開發的一大革命。

本書簡介

以非學術色彩的方式探索函數式程式設計(會提到 monads)
開發共時性的應用程式,但不需要在意令人頭痛的閉鎖、一致性問題。
遇見 Elixir 這樣一個現代化、函數式的共時性程式語言,建立在堅若磐石的 Erlang 虛擬機器之上。
Elixir 的實用語法和內建支援 metaprogramming 都將讓你開發效率提升,帶給你滿滿的驚喜。
現在即將迎接下一件大事情,也許就是 Elixir。這本介紹 Elixir 的書是給有經驗的開發者,已經完整地更新到 Elixir 1.3 版。

關於這本書

函數式程式設計技巧可幫助您管理現代複雜的真實世界、共時性系統。最大化正常化運行時間,而且管理安全性。
進入 Elixir 世界,伴隨著它現代化、類似 Ruby、可擴充的語法,編譯和執行階段賦值,Hygienic macro 等等。
同樣重要的是,Elixir 帶來的是平行運算、函數程式設計的樂趣。您的應用程式開發將會變得有趣,而且語言鼓勵您去嘗試。

第1部分介紹撰寫序列式 Elixir 程式的基本知識。我們將會專注在語言、工具、約定俗成的默契上。
第2部分使用這些技巧開始撰寫共時性的程式碼,讓應用程式可在您的機器或在您的網路上的所有機器上使用全部的內核運算資源。
並且我們可以同時使用 OTP 或是完全不需要 OTP 來達到這一點。
第3部分著眼於這個語言的更多進階特色,從 DSLs 和擴展語法的程式碼生成。

這個版本已經完整地更新到 Elixir 1.3 的新特色,帶來新的章節在探討工具、覆蓋測試 (常規和基於屬性),程式碼和相依性的探討,以及伺服器監控。
閱讀完這本書,您將會了解 Elixir 且知道如何運用它來解決您所遇到的複雜現代化問題。

閱讀前準備

您需要一台電腦,以及一些些其他高階語言的開發經驗,同時帶有一點冒險的精神。沒有函數式程式設計的經驗亦可。

購買方式

可以直接上 The Pragmatic Bookshelf 購買,或是參加雲端讀書會團購活動 (有優惠價格)

p.s 作者會持續更新內容,並且很佛心的可以免費更新到最新版的內容(目前是 Elixir 1.3)

加碼 Elixir 介紹影片:

9分鐘快速認識 Elixir by Dave Thomas