git windows 換行問題

git在windows下對於pull下來檔案的換行有三種處理方式:

  1. true: check out時自動將\n轉換成\r\n,commit時將\r\n轉成\n.
  2. input: check out時不轉換\n,commit時將\r\n轉成\n.
  3. false: 不做任何轉換

若不清楚目前設定是哪一種,可以用下列指令查詢:

git config core.autocrlf

若要修改成input,則可用下列指令修改(請用超級管理者執行命令提示字元)

git config --system core.autocrlf input

或是(一般使用者)

git config --global core.autocrlf input

chmod 設定權限

設定test資料夾下的所有檔案權限

find test -type f -exec chmod 644 {} +

設定test資料夾下的所有資料夾權限

find test -type d -exec chmod 755 {} +

generator & list on python

generator不同於list,沒有list,且只能遊走一次.
下面的code可以發現generator的元素是在被用的時候才產生.

import time

b=[time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) for i in range(3)]

time.sleep(1)
print("A:",time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
time.sleep(1)

for ii in b:
  print("B:",ii)
  time.sleep(1)

###########################################################################

b=(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) for i in range(3))

time.sleep(1)
print("C:",time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
time.sleep(1)

for ii in b:
  print("D:",ii)
  time.sleep(1)

地震預警的構想

筆記
1868年 Copper提出的地震預警的構想

San Francisco Daily Evening Bulletin of 3rd November 1868
Earthquake Indicator
EDITOR BULLETIN.

Since the Japanese magnet indicator has proved a failure, we are now obliged to look for some other means of prognosticating these fearful convulsions, and I wish to suggest the following mode by which we may make electricity the means, perhaps, of saving thousands of lives in case of the ccurrence of more severe shocks than we have yet experienced. It is well known that these shocks are produced by a wavemotion of the surface of the earth, the waves radiating from a center just as they do in water when a stone is thrown in. If this center happens to be far enough from this city, we may be easily notified of the coming wave in time for all to escape from dangerous buildings before it reaches us. The rate of velocity, as observed and recorded in Dr. J. B. Trask’s work on Earthquakes in California from 1800 to 1864, is 61.5 (six and one fifth) miles per minute, or a little less per hour (40 miles) than the tidal wave is reported to have traveled across the ocean to this port from the Sandwich Islands or Japan. A very simple mechanical contrivance can be arranged at various points from 10 to 100 miles from San Francisco, by which a wave of the earh high enough to do damage, will start an electric current over the wires now radiating from this city, and almost instantaneously ring an alarm bell, which should be hung in a high tower near the center of the city. This bell should be very large, of peculiar sound, and known to everybody as the earthquake bell. Of course nothing but the distant undulation of the surface of the earth should ring it. This machinery would be self-acting, and not dependent on the telegraph operators, who might not always retain presence of mind enough to telegraph at the moment, or might sound the alarm too often. As some shocks appear to come from the west, a cable might be laid to the Farallone Islands, 25 miles distant, and warnings thus given of any danger from that direction. Of course there might be shocks, the central force of which was too near this city to be thus protected, but that is not likely to occur once in a hundred times.
J.D. COOPER, M.D.

Ubuntu 16.04 架設HylaFAX筆記

1.首先需要一個USB Modem以及一台Ubuntu(這邊是在iMac下用Parallels Desktop跑Ubuntu 16.04)

2.設定ttyACM相關權限
編輯udev

sudo vim /etc/udev/rules.d/70-ttyusb.rules

加入下面設定:

KERNEL=="ttyUSB[0-9]*",MODE="0666"
KERNEL=="ttyACM[0-9]*",MODE="0666"

以及透過chmod修改權限

sudo chmod o+rw /dev/ttyS0

3.安裝

sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y cu hylafax-server hylafax-client

4.測試USB Modem

sudo cu -l ttyS0

出現connected.既可按兩下“.離開

5.設定HylaFAX

sudo faxsetup

6.設定撥號前按下0

sudo vim  /var/spool/hylafax/etc/config.ttyACM0 

修改ModemDialCmd設定:

ModemDialCmd:           ATX3D0T%s       # press 0 before dialing

7.傳真a.pdf至11223344

sendfax -n -d 11223344 a.pdf

8.查看

#歷史狀態
faxstat -d
#接收狀態
faxstat -r
#傳送狀態
faxstat -s

9.刪除job 1

faxrm 1

10.清除所有傳送資料(如果隔一陣子想要清除所有傳送資料的話)

sudo service hylafax stop
sudo rm -rf /var/spool/hylafax/docq/*
sudo rm -rf /var/spool/hylafax/doneq/*
sudo rm -rf /var/spool/hylafax/info/*
sudo rm -rf /var/spool/hylafax/log/*
sudo rm -rf /var/spool/hylafax/sendq/*
sudo service hylafax restart
faxstat -d

install nodejs on macos with nvm

#安裝nvm
brew install nvm

#設定路徑
echo "source $(brew --prefix nvm)/nvm.sh" >> ~/.bash_profile
. ~/.bash_profile

#查看版本
nvm ls-remote

#安裝8.x
nvm install v8.15.1

#顯示已安裝版本
nvm ls

#切換版本
nvm use v8.15.1

#設定PATH
echo "PATH=$PATH:$(dirname $(nvm which v8.15.1))" >> ~/.bash_profile
. ~/.bash_profile

install docker 18.06 on raspberry pi

最近在raspberry pi上面安裝docker 18.09後,
會發生無法啟動docker的問題.
因此需要降版至18.06,語法如下:

sudo apt-mark unhold docker-ce
sudo apt-get purge -y docker-ce
sudo apt-get autoremove -y --purge docker-ce
sudo apt-get autoclean
sudo rm -rf /var/lib/docker
export VERSION=18.06 && curl -sSL get.docker.com | sh
sudo apt-mark hold docker-ce

k375s在macos下的建議設定

個人因為已經習慣Windows鍵盤,
因此鍵盤排列方式會是: Ctrl/Command/Option
而K375s鍵盤有幾種選擇方式:

  • Fn+P(3秒): Windows模式,也就是 Ctrl/Command/Option
  • Fn+I(3秒): iOS模式,也就是 Ctrl/Option/Command
  • Fn+O(3秒): MacOS模式,也就是 Ctrl/Option/Command

因此我會用Fn+P(3秒)強制設定為Windows模式,以便符合我的習慣.

另外,鍵盤預設F1~F12是必須要搭配Fn才能使用的.
這邊則是要透過Fn+Esc(3秒)來將鍵盤設定為標準鍵盤.