"There is only one heroism in the world: to see the world as it is, and to love it." - Romain Rolland

Practicing bisect in Go

In Python, we are used to using bisect to search for elements in the List. In Go, sort.Search() can also provide us with the same purpose. As in Python, the target array is sorted before searching. 1 2 arr := []int{9, 2, 1, 3, 6, 4, 5, 5} sort. Ints(arr) After sorting, we use sort.Search(), the first parameter is the search target, and the second is the function of the search condition.

How to mail the movie list from the remote host

Sometimes I upload videos for my family but don’t know if they already exist on the computer. At this time, I can think of a way to automatically email the titles of the videos already in the video library to myself for reference on a regular basis. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ~/Downloads ➤ cat 2021-12-03-movie_list.txt -r :10 ───────┬──────────────────────────────────────────────────────────────────────────────────────────────── │ File: 2021-12-03-movie_list.

Common Python and C++11 usage comparison

My Gist 1 Define Variables Python 1 2 3 a = 1 b = 0.0 c = 'xxx' C++ 1 2 3 4 5 6 7 8 9 int a = 1; auto a = 1; double b = 0.0; auto b = 0.0; const char c[] = "xxx"; // C string (char array) const char* c = "xxx"; // C string (pointer) std::string c = "xxx"; std::string c("xxx"); std::string c{"xxx"}; 2 Variable Scopes Python 1 2 3 4 5 6 7 8 9 10 11 global_var1 = 1 def func(arg): local_var = 2 global global_var2 global_var2 = 'xxx' # global if arg: local_var2 = 0.

台電跳電分析

使用資料 台灣電力公司_近三年每日尖峰備轉容量率.csv (http://data.gov.tw/node/25850) 台灣電力公司_本年度每日尖峰備轉容量率.csv (http://data.gov.tw/node/24945) 台灣電力公司_過去電力供需資訊.csv (https://data.gov.tw/dataset/19995) 觀察結果 首先台電並沒有提供跳電或停電紀錄,目前所知道最有可能導致跳電的數據為備轉容量(預留的發電量),當被轉容量過低則可能導致供電不足。 新聞指出今年五月頻繁跳電(http://www.storm.mg/article/477780 ),而五月也是備轉容量率低於10%累積天數之首。現在我們看看台電實際數據。 以歷年平均備轉容量率來看,2018為目前最低的年份(6%以下為供電警戒),但是2018尚未結束,所以我們用時間圖表看過去同時期的情況。 從年初到現在的備轉容量率較往年偏低,所以如果去年前年都有跳電的紀錄,今年也有可能會跳電。 分析過往用電紀錄,可以看到10月初是整體耗電最凶的時候,如果不算計畫性工作停電的話,今年最有可能在10月發生跳電。

台灣社群年齡分布

看到公開資料隨手來分析一下台灣社群年齡比例 表格一為台灣各年齡層Facebook用戶數量 年齡 人數 13-17 2372779 18-24 4898337 25-34 3151068 35-44 2557531 45-54 1842607 55-64 759609 表格二為18-24歲用戶,2017年最常互動之媒體排行 粉絲頁名稱 不重複互動人數 18-24歲用戶佔該媒體總互動人口比例 東森新聞 2114552 0.3068 ETtoday新聞雲 1759703 0.3216 ETtoday星光雲 1518584 0.3763 表格三為25-34歲用戶,2017年最常互動之媒體排行 粉絲頁名稱 不重複互動人數 25-34歲用戶佔該媒體總互動人口比例 東森新聞 1278274 0.1855 ETtoday新聞雲 1107137 0.2023 蘋果日報 台灣 1008543 0.2362 表格四為55-64歲用戶,2017年最常互動之媒體排行 粉絲頁名稱 不重複互動人數 55-64歲用戶佔該媒體總互動人口比例 大紀元 epochtimes.com 150330 0.1979 東森新聞 99128 0.1305 ETtoday新聞雲 81543 0.1073 其中,互動表示Facebook用戶對該媒體粉絲專頁之貼文按讚、愛心、笑臉、憤怒、悲傷等表情符號,不重複互動人數代表每位用戶不論與該媒體多少篇貼文互動,都僅統計為1不重複互動人數。 以表格三25-34歲台灣Facebook使用者最愛媒體中東森新聞為例,代表在2017年東森新聞發出的全部貼文中,共有1278274位屬於25-34歲之用戶與這些貼文互動。 並且25-34歲人口佔所有與東森新聞互動者中的18.55%,(即25-34歲用戶佔該媒體總互動人口比例一欄)。 年齡 東森新聞(%) ETtoday新聞雲(%) 東森新聞(人數) ETtoday新聞雲(人數) 東森新聞佔使用者比例 ETtoday新聞雲佔使用者比例 18-24 0.3068 0.