跳到主要內容

發表文章

Java Process And Thread 筆記

英文很差,所以附上原文。 關係大概是這樣吧 Processes And Threads Processes (進程) 每個 Process 都可視為一個獨立運作的環境,有自己完整、私有的 Run-Time 資源,特別是每個 process 都有自己的記憶體空間。 Processes 聽起來很像 programs 或 application 的另一種說法,然而事實上一個 application 有可能是許多 processes 合作組成的。為了讓 processes 彼此互相合作,一些作業系統支援了 Inter Process Communication (IPC) resources,例如 pipes 與 sockets。IPC 不只讓不同的 processes 互相通訊,同時也支援不同系統的 pocesses 互相通訊。 大部分 JVM 實現的都是 single process。Java Application 可以創建額外的 process 透過 ProcessBuilder Object。 A process has a self-contained execution environment. A process generally has a complete, private set of basic run-time resources; in particular, each process has its own memory space. Processes are often seen as synonymous with programs or applications. However, what the user sees as a single application may in fact be a set of cooperating processes. To facilitate communication between processes, most operating systems support Inter Process Communication (IPC) resources, such as pipes and sockets. IPC is used not just for communication b...

Heroku API 設計指南

Heroku API 設計指南 總是用 TLS 使用 ETag 提供 created_at 與 updated_at 時間戳記 時間使用 ISO8601 UTC 格式, 2012-01-01T12:00:00Z 使用 Leaky Bucket 來限制 Request Rate Limit, 這個水桶理論 滿有趣的 Response 壓縮 JSON ,去掉空白,換行符號 產生 JSON 文件,並提供呼叫範例 PRMD 描述 Resource 的穩定性 Bucket 原理 參考: https://zhuanlan.zhihu.com/p/20872901 所有的流量在放行之前需要獲取一定量的token; 所有的token 存放在一個bucket(桶)當中,每1/r 秒,都會往這個bucket 當中加入一個token; bucket 有最大容量(capacity or limit),在bucket 中的token 數量等於最大容量,而且沒有token 消耗時,新的額外的token 會被拋棄。

程序員生涯巡禮

程序员职业生涯巡礼 程序员是个好职业 程序员是一个具备长久生命力的职业 程序员不一定要写一辈子程序 StuQ 程序员技能 图谱 你不是一个人在编程 专业性很重要,但也别太「专」了 没什么职业规划,往前走,就是规划

Blogger Code Syntax Highlighting with Prism

Prism Prism 是一款簡單又好看,好用的要死的 Code Syntax Highlighting 套件,輕量化,而且 plugin 又多方便套用自己擅長的的程式語言。 使用方式 安裝在 Blogger 上其實大同小異,可以參考 https://edricteo.com/adding-syntax-highlighting-to-ghost-cms-using-prism-js-cdn/ 免費的 CDN 一開始我是用 GoogleDriver 來當免費的 css 跟 js hosting,但幾次改版後,hosting 的功能就失效了。於是改用免費的 CDN 。 推薦一下 JSDELIVR,可以免費幫你把多個 js ,Collection 成一個 resource,一次引用 http://www.jsdelivr.com/projects/prism 這個 Bloger 用到的 Resource css https://cdn.jsdelivr.net/g/prism@1.6.0(plugins/ie8/prism-ie8.css+themes/prism-okaidia.css+plugins/line-numbers/prism-line-numbers.css+plugins/previewer-color/prism-previewer-color.css) css 使用方式 <link href='https://cdn.jsdelivr.net/g/prism@1.6.0(plugins/ie8/prism-ie8.css+themes/prism-okaidia.css+plugins/line-numbers/prism-line-numbers.css+plugins/previewer-color/prism-previewer-color.css)' rel='stylesheet'/> JS https://cdn.jsdelivr.net/g/prism@1.6.0(prism.js+components/prism-java.min.js+components/prism-javascript.min.js+components/prism-php-extras.min.js+...

Google Trends Hacking

給我資料 最近試著在蒐集一些看起來有點用途的資料,Google Trends 看起來是一個 “滿有價值” 的資料,是 Google 蒐集的全球趨勢資料,包含最近流行的關鍵字,關鍵字與關鍵字的比較,etc.,但 Google 並沒有提供相關的 API 介面,所以要取得資料的做法我第一個想到的是 Crawler,於是順手找了一下大神的 開源專案 ,左看右看上看下看,都沒認真看,都覺得不順手XD。 Hack Fun 剛好讀到一篇很有趣的 文章-hacking the google trends api ,文章內容提到了幾個有趣的 end-point,像這樣 http://www.google.com/trends/fetchComponent?hl=en-US&q=html5,jquery&cid=TIMESERIES_GRAPH_0&export=5&w=500&h=300 URI http://www.google.com/trends/fetchComponent hl en-US q keywords cid TIMESERIES_GRAPH_0/RISING_QUERIES_1_0/business_and_politics export 5 w width h height 還有這樣 curl 大絕招 curl --data "ajax=1&htd=20131111&pn=p1&htv=l" http://www.google.com/trends/hottrends/hotItems 還有直接把這個貼在 Browser http://hawttrends.appspot.com/api/terms/ 這邊還有大神整理的參數對照表,實在棒棒der。 http://myweb.fcu.edu.tw/~mhsung/Research/InformationSystem/JSON/JSON_24.htm Browser Dev-Tools 看完大神的示範後,發現其實有些開放的資料並不一定要特別透過 Crawler 去取得,太沒效率了。而且大部份的瀏覽器都有提供開發工具,Hacking 那些 end-point 其實滿簡單的,比如說 Chrome 的開發者工具,我以這個潮潮的頁...

Play-Framewrok 學習

Required Java 1.8 Above Play-Framework 大多看到的教學都是以 scala 為主,需要 Java 1.8 以上的版本。 SBT SBT 跟 Activator 只要選擇一種方式安裝即可,兩種都算是 CI 統一開發環境的工具。 SBT 介紹 工具 安裝SBT Activator Activator 的好處就是有美美的 UI, 常用的指令 activator ui activator list-templates 安裝 play 官網介紹了兩種方式 Install Play With SBT Install Play With Activator