2017年1月7日 星期六

[think] 千禧世代在職場上到底出了什麼問題? - Simon Sinek 賽門.西奈克


最近很火紅的一個影片

Simon 最有名的 TED 演講,也就是黃金圈圈(Golden Circle)的理論 。
Why How What

Why 理念跟目標
How 執行的方法跟過程
What 最終呈現的產品與領導風格

The Golden Circle

WHAT
Every person on the planet knows What they do.
This is your job title, function, the products you sell or services you offer.
HOW
Most people know How they do it.
These are the things they do that make them special or set them apart from their peers.
WHY
Very few people know WHY they do what they do.
The Why is not about making money - that’s a result. The Why is a purpose, cause or belief.
Your Why is the very reason you exist.






千禧世代在職場上到底出了什麼問題? - Simon Sinek 賽門.西奈克 - YouTube
https://www.youtube.com/watch?v=KsGiDrt5U2c 




如同Leaders Eat Last 談到人的滿足是由多巴胺達成生理獎勵,而millennials生存的環境有許多快速達成反饋的科技,使得人的真實相處慢慢的喪失,而不能體驗跟享受這個世界帶來的美好。

從四個面向講起,教育的影響,科技的發展,導致沒有耐心的等待事情發生的機會,還有整個環境的影響,造就這樣的狀況。

要避免快速回饋的成癮情況,這也是是科技發展,對人與人的互動跟體驗的影響。


2016年12月28日 星期三

高等遊民的意思



高等遊民,是日本明治時代至昭和初期大學畢業後沒就業學生的稱呼,他們以閱讀為主要活動,政府認為他們無所事事,容易接觸自然主義、社會主義、無政府主義等危險思想。
高等遊民以讀有興趣的書為主要活動,很多人最後成為作家,如夏目漱石、石川啄木和川端康成。
最終在昭和初期,因對中戰爭和一系列對外戰爭帶來的戰爭景氣和國家總動員法實行,就職困難開始解決。


2016年12月27日 星期二

[tech_note] firebase push id Unique Identifiers method guid 產生方法


The Firebase Blog: The 2^120 Ways to Ensure Unique Identifiers https://firebase.googleblog.com/2015/02/the-2120-ways-to-ensure-unique_68.html

昨天剛好看到一篇 firebase 提到,怎麼產生不重複的 guid的方式。


What's in a Push ID?

A push ID contains 120 bits of information. The first 48 bits are a timestamp, which both reduces the chance of collision and allows consecutively created push IDs to sort chronologically. The timestamp is followed by 72 bits of randomness, which ensures that even two people creating push IDs at the exact same millisecond are extremely unlikely to generate identical IDs. One caveat to the randomness is that in order to preserve chronological ordering if a client creates multiple push IDs in the same millisecond, we just 'increment' the random bits by one.
To turn our 120 bits of information (timestamp + randomness) into an ID that can be used as a Firebase key, we basically base64 encode it into ASCII characters, but we use a modified base64 alphabet that ensures the IDs will still sort correctly when ordered lexicographically (since Firebase keys are ordered lexicographically).

使用 timestamp + randomness 在使用 base64 encode 而成,實作上,只要是產生的時候, timestamp 還沒改變,就把最後一個 bit +1 。 
這些gits 是個版本的實作方式。
JavaScript code for generating Firebase Push IDs https://gist.github.com/mikelehen/3596a30bd69384624c11
Firebase push algorithm in Python (ref: https://www.firebase.com/blog/2015-02-11-firebase-unique-identifiers.html) https://gist.github.com/risent/4cab3878d995bec7d1c2


ref
[tech_note] hackpad 的 unique padid 產生方式 / etherpad 與 appjet - peicheng note
http://peichengnote.blogspot.tw/2015/10/technote-hackpad-unique-padid-etherpad.html
Parse.com ObjectId 產生方法 unique id - peicheng note http://peichengnote.blogspot.tw/2016/01/parsecom-objectid-unique-id.html

2016年12月26日 星期一

[電影] 火線掏寶 War Dogs




《火線掏寶》(英語:War Dogs,前稱作Arms and the Dudes)是一部於2016年上映的美國傳記犯罪戰爭喜劇片,由陶德·菲利普斯執導,並和史考特·巴德尼克、布萊德利·庫柏、布萊恩·祖里佛共同監製,而劇本則由菲利普斯、史蒂芬·欽、傑森·斯米洛維奇共同負責。電影改編自蓋·羅森在《滾石》上撰寫的文章《Arms and the Dudes》[3]。由麥爾斯·泰勒和喬納·希爾分別飾演主角大衛·帕克歐茲與伊弗倫·佛羅里,其他主演包括安娜·德哈瑪斯與J·B·布蘭克。
《火線掏寶》於2016年8月19日在美國上映。

故事改編自真人真事。主要敘述於07年冬天,兩個從未上過戰場的年輕軍火商人大衛和伊弗倫為了想要一夜致富而接受了美軍和阿富汗的軍火招標,但兩人很快察覺到自己將深陷於危機之中,這使得他們必須想辦法平安回家。


抓準機會跟把握時機,還有人面對一些誘惑的時候又會怎麼去應對。



2016年12月23日 星期五

Titan Gremlin Server start http rest server solve "not a WebSocket handshake request: missing upgrade”




Titan 1.0 配置好啟動後,如果出現
“not a WebSocket handshake request: missing upgrade”
其實預設是啟用 WebSocket 的

如果要啟用 Gremlin  server 的 http interface

可以在下面 file 註解到websocket channel 增加這行 啟動 HttpChannelizer

 conf/gremlin-server/gremlin-server.yaml file:


channelizer: org.apache.tinkerpop.gremlin.server.channel.HttpChannelizer

三年的試驗 three years startup retrospective



上一篇文章促使我開始反思,
從 2013 年聖誕節前夕,上線了一個service
一路走到可以自動營運的程度。

以前前期來說,一直投入不少時間在摸索,不過到後來真的可以驗證,這樣的模式是有一定的成效的。

這些服務,主要就是在測試一些技術性的細節。

驗證一些,人數不需要太多,但是有一定經濟的規模的商業模式。

期望,在未來的一年內,能夠基於這樣的基礎來從事新的試驗。



2016 聖誕節前夕







2016年12月22日 星期四

Derek Sivers 回復 創業的堅持


Derek Sivers  一直是我很推崇的(前)創業家

2016的年尾聲,他整理了他回答的三萬多個問題給一萬多個人的內容摘要。

In 2016, I answered 30,904 emails from 11,971 people. It was practically a full-time job. These are the most common questions.

Frequently Asked Questions | Derek Sivers
https://sivers.org/faq


有一個問題,為何我的事業或讀者沒有快速的增長?
這是個很有趣的問題跟回答,回答他的過去與看法。

CD Baby 在 還沒起飛前,他連續四年每天都工作12 ~18 個小時。
他從1994 年起,也連續不停寫作了22年。

告訴我們, Keep pushing, but be patient.

Why isn’t my business or audience growing faster?

I worked on CD Baby for 12-18 hours per day, 7 days per week, for four years before it really took off.
As for an audience, I’ve been creating and posting things online for free non-stop since 1994. Yep, that’s 22 years now. And keeping in touch with everyone I met that whole time.
Keep pushing, but be patient.


2016年12月19日 星期一

[blog] 2016 年文章發文數回顧


最近每一年都又統計回顧一下blog 的發文數
2017 的發文數截至目前加上這篇應該是 78 篇
遠遠少於去年 155篇的一半阿

由於時間的抽空與多樣的改變,導致自己也越來越隱藏對自己的感情與對話了。


 



[linux] find 找出 檔案大小是0 且 檔名長度的文件 並且刪除



找出檔案大小為零 且 檔名長度是6 的檔案

find ./ -size 0 -name "??????"

接著再混搭 xargs

find ./ -size 0 -name "??????"  | xargs -p rm -rf

使用 -p 可以先看一下執行怎樣的 command

確認無誤後使用

find ./ -size 0 -name "??????"  | xargs rm -rf

2016年12月6日 星期二

[docker] how to install docker on Ubuntu 16.04 如何在 Ubuntu 16.04 安裝 Docker



如何在  Ubuntu 16.04  安裝 Docker
在 EC2 上啟用了一台新的 instance ,透過下面步驟安裝 docker 的環境


  • uname -r
    確認一下  kernel version 是在 3.10 以上,不過這個在 16.04  上預設是必然的
  • sudo apt-get update
  • sudo apt-get install apt-transport-https ca-certificates
  • sudo apt-key adv                --keyserver hkp://ha.pool.sks-keyservers.net:80                --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
  • echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
    增加 source list 並且 更新
  • sudo apt-get update
  • apt-cache policy docker-engine
    驗證一下 apt 來源是否是正確的
  • sudo apt-get update
  • sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
  • sudo apt-get update
  • sudo apt-get install docker-engine
  • sudo service docker start
  • sudo docker run hello-world
  • sudo docker ps

[influxdb] select MEASUREMENT ERR: error parsing query: found FROM, expected identifier at line 1, char 15





使用 influxdb  command line 要 select MEASUREMENT 時

ERR: error parsing query: found FROM, expected identifier at line 1, char 15
> select * from foo2.counter
ERR: error parsing query: found foo2.counter, expected identifier at line 1, char 14


原來是要加上 double quote

> select value from "foo2.counter"
name: foo2.counter
------------------
time value
1480992498000000000 2


select MEASUREMENT ERR: error parsing query: found FROM, expected identifier at line 1, char 15


[0.9.2] (regression) Error reading from measurement named "Measurement" · Issue #3467 · influxdata/influxdb
https://github.com/influxdata/influxdb/issues/3467

2016年11月21日 星期一

[mac][vim] error: There was a problem with the editor 'vi'. Please supply the message using either -m or -F option.


遇到

error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.


使用

$ git config --global core.editor

指定編輯器

2016年11月13日 星期日

[mac] mac 使用 android 的 usb 網路共用




除了使用 手機的無線基地台功能,也可以透過 usb網路共用的設定分享網路出來。



只要裝了

HoRNDIS: USB tethering driver for Mac OS X | Joshua Wise's domain
重開機後, android 手機插入電腦 開啟 usb網路共用 如果有讀取到就可以使用網路。




2016年11月11日 星期五

[哲學思想] 你為了什麼工作的呢 ? 重版出來



這幾張圖示最近在 看日劇 "重版出來" 所節錄下來的





今天整理了北京的照片,心理才想著

  • 好像時光回溯,之前回來的幾個心得
    • 他們只是比我們知道什麼時候該做什麼事情,並且好好去做
    • 很多事情要立即的去做



2016年11月9日 星期三

[python] datetime string with timezone to timestamp 轉換有時區的時間字串到時間戳



有個需求是把 時間字串轉成 epoch 的 timestamp

這個字串來說 "2016-11-07 15:47:33" UTC+8
轉換成 iso 8601 表示的話

2016-11-07T15:47:33+08:00

轉成 timestamp就是  1478504853


int((datetime.strptime(t, "%Y-%m-%d %H:%M:%S") - timedelta(hours=8)).strftime("%s")) - time.timezone

不使用其他lib的思路如下,先把 time string parse成 datetime object ,
但是因為UTC +8 跟 UTC 差了八個小時 ,所以減去 timedelta 八小時 ,就是UTC 的datetime string 。

是使用 strftime 轉成 timestamp 時,會因為環境的timezone設定有影響, 會以為這個 datetime object 是 目前的 timezone 所以,再減掉 time.timezone。
就得到最後的 timestamp。


>>> t
'2016-11-08 11:50:21'
>>> int((datetime.strptime(t, "%Y-%m-%d %H:%M:%S") - timedelta(hours=8)).strftime("%s")) - time.timezone
1478577021
>>> time.timezone
-28800



另外一個使用 pytz 的作法


import pytz
from datetime import datetime,timedelta

tp_timezone = pytz.timezone('Asia/Taipei')
tsd = datetime.strptime(t, "%Y-%m-%d %H:%M:%S").replace(tzinfo=tp_timezone)
timestamp = int(tsd.strftime("%s"))





2016年10月31日 星期一

[mac] 移除已經安裝的印表機驅動程式 remove mac printer driver



位置在 /Library/Printers/PPDs/Contents/Resources

看看要移除哪些

example

移除所有的  Fuji Xerox 驅動程式

rm -rf FX*

and

rm -rf Fuji\ Xerox\ *

[mac] install fx printer driver for mac os x 使用 fujixerox 印表機的驅動程式



使用 Fuji Xerox 的 printer ,從  web console 看起來是 ApeosPort-V C3374 。
可是裝了 mac 的 Fuji Xerox 印表機驅動程式 v3.0 (OS X) 選了對應型號也是無法使用。
https://support.apple.com/kb/DL1776?locale=zh_TW



從 air printer 自己選擇的driver 來看確實是 Fuji Xeror 的機器沒錯 但是使用不同的 driver 。





a在加入新的 printer 時 ,輸入ip後他會幫你選擇使用的driver ,這時候自行選用 fx printer driver for mac os x (下方有下載網址)




Print Driver for Mac OS X : Description : Download : Fuji Xerox

使用了這個 driver 就可以在 mac 上 使用 fuji xerox 的印表機了。






2016年10月21日 星期五

[elasticsearch] elasticsearch indexing throughput 單機每秒索引超過四萬筆資料

先講結論, elasticsearch 單機每秒可以索引超過四萬筆資料。

以前我們架設完自己的 elasticsearch cluster 會自己做一下 benchmark ,但是遇到同樣使用 elasticsearch的朋友,在描述各自的 indexing throughput 或是 query performance ,就比較難真實的評比出來。

後來有了 Rally ,幫助我們怎麼做出一致的 benchmark參考值。
elastic/rally: Macrobenchmarking framework for Elasticsearch
https://github.com/elastic/rally

根據一樣的 setting file 各自可以做出屬於自己 cluster的對照數據。
rally-tracks/track.json at master · elastic/rally-tracks
https://github.com/elastic/rally-tracks/blob/master/geonames/track.json


目前 elastic 使用了 rally 做了
Elasticsearch Nightly Benchmarks
https://elasticsearch-benchmarks.elastic.co/geonames/index.html

Elasticsearch Nightly Benchmarks
https://elasticsearch-benchmarks.elastic.co/index.html


All benchmarks are run on a bare metal machine with the following specifications:

2016年10月17日 星期一

[hadoop][EMR][hive] 自動建立 hive 的 partition , automatically partition hive external table on amazon S3



使用 AWS 上有 Hadoop  Cluster service   Apache EMR  。

Hive 的 table 有兩種,一種是 把 data 放在 hive 資料夾下,另外一種稱作 external table,也就是說,把data  放在非 hive 預設的資料夾下。

舉例來說,如果 hive的 預設資料夾在 hdfs 上的 /user/hive/warehouse 下,create table 後可以使用 load data inpath 載入檔案,資料會搬到這個資料夾下面。

但是,如果使用了其他分析工具,如 mapreduce , spark ,pig ... 分析完後,有時候是放在另外的資料夾下。如果不直接搬移過來這個資料夾,可以使用 create external table ,來讓資料存放在其他資料夾下,但是只是在 hive metastore 設定說,有這個 table的資料放在哪個資料夾下。


在 Amazon EMR 上就提供了從 s3 :// 上 讀入檔案的方式,所以,大量分析需求的時候起了一些EMR  ,把資料算完後放在 S3 上。當下次有需要大量分析時,再使用 create external table  的方式讀取放在s3上的資料。


Hive 中有個加速資料處理的方式,稱作 partition ,簡單來說就是,可以透過 partition 的條件設定,讓 Hive 需要處理的資料便少。

像是有根據時間一直增加的這種資料類型,一般來說都是要分析某個區間的資料。
如果大部分情況都是以天來做分析,就可以把 日期拿來建立 partition 欄位,使用這個機制來減少要處理的資料。


資料從外部處理完後,按造日期每天放入 S3 上的資料夾,來供 hive 使用。



CREATE EXTERNAL TABLE IF NOT EXISTS posts (
`id` int ,
`date` string ,
`pid` int ,
`country` string ,
`placement` string ,
`type` string ,
`count` double ,
`updated` timestamp
)
PARTITIONED BY (day string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'
STORED AS TEXTFILE
LOCATION 's3://mys3-table/posts';


而我在 s3上 的資料夾 naming 規則就是如此, partition 欄位其實就是個 資料夾命名規則,
"day="

s3://mys3-table/posts/day=20161016/posts_ 20161016
s3://mys3-table/posts/day=20161017/posts_ 20161017

當資料放好後,
使用 hive -e "msck repair table posts;"
就可以在 hive 內看到隸屬該 partition 的資料了。








2016年9月29日 星期四

[python] requests/utils.py", line 800, in check_header_validity "not %s" % (value, type(value)))


[python] requests/utils.py", line 800, in check_header_validity "not %s" % (value, type(value)))


$ pip freeze | grep requests
requests==2.11.1

requests 的 header 如果帶有 int 的 type 現在會出現這樣的 error

原因是

 this is the intention of this check. All header values must be passed as strings in Requests.

RFC states that headers are char strings

Is there a cross-reference link to the specification or RFC for prohibiting non-string values? According to RFC7230 §3.2, the BNF for header field values is:

 RFC 7230 其實是不接受 non-string 的 values 的


Utils.check_header_validity fails on integer values · Issue #3559 · kennethreitz/requests
https://github.com/kennethreitz/requests/issues/3559
check for headers containing return characters by nateprewitt · Pull Request #3366 · kennethreitz/requests
https://github.com/kennethreitz/requests/pull/3366