在「Enable CORS in Amazon API Gateway」這邊看到 Amazon API Gateway 支援 CORS (Cross-origin resource sharing) 了,這樣前端頁面就可以直接 call 進去使用了...
文件可以在「Enable CORS for a Method in API Gateway」這邊看到,主要就是這個頁面的設定:
看起來是個小功能,但卻影響很大... 這代表又有一大塊開發者會進去研究。
幹壞事是進步最大的原動力
在「Enable CORS in Amazon API Gateway」這邊看到 Amazon API Gateway 支援 CORS (Cross-origin resource sharing) 了,這樣前端頁面就可以直接 call 進去使用了...
文件可以在「Enable CORS for a Method in API Gateway」這邊看到,主要就是這個頁面的設定:
看起來是個小功能,但卻影響很大... 這代表又有一大塊開發者會進去研究。
在「Chrome Devtools Tips & Tricks」這邊看到介紹 Google Chrome 的 DevTools 用法說明,但讓我注意到文章最下面提到的兩個工具,其中提到了 JavaScript Errors Notifier 這個工具:
JS Error Notifier (non-“spyware” version) creates a popup each time a Javascript error is printed to the console. Unfortunately, the main version of this extension submits private “usage data” to a third-party service (see discussion in issue #28). But at any rate, this extension has helped me notice and fix several bugs.
找資料時可以發現 Hacker News 上面也有些討論:「Malware alert: JavaScript Errors Notification extension for Chrome (86k users)」。
馬上換掉...
在「#NodeJS : A quick optimization advice」這邊看到這樣的效能改善方法... 兩段程式碼,只差在註解:
效能差了 50%:
只是因為註解的長度有差,只要用 --max-inlined-source-size
調整就可以避開了:
超苦超無奈:
So when you have a function or callback that’ll be called repeatedly, try to make it under 600 characters (or your tweaked value), you’ll have a quick win !
在「Prevent Blogger from Redirecting your Blogspot Blog to Country-Specific URLs」這篇文章裡提到了 Blog 的擁有人要怎麼避免 Google 把網址導到 country-based 的網域下。
目前 Google Chrome 的使用者端可以安裝「NoCountryRedirect (NCR)」這個套件來避開這個問題,但你總不能要求每個人都裝套件...
而這篇文章則說明了如何在 Blogger 裡插入一段 javascript 避免使用 country-based domain:
<script type="text/javascript"> // Written by Amit Agarwal /* Get the full URL of the current blogger page */ var blog = document.location.href.toLowerCase(); /* Do not redirect if the domain is .com already */ if (!blog.match(/\.blogspot\.com/)) { /* Replace the country TLD with .com and ncr switch */ blog = blog.replace(/\.blogspot\..*?\//, ".blogspot.com/ncr/"); /* Redirect to the new .com URL in the current tab */ window.location.replace(blog); } // Source: http://labnol.org/?p=21031 </script>
這樣做的好處主要是來自於 url 統一,對於統計、廣告以及分享的問題會減少很多。
Node.js 在 4.0 開始啟動 LTS (Long Term Support) 計畫:「Node v4.0.0 (Stable)」。
可以參考「Node.js Long-term Support Working Group」這邊的說明。最主要的重點是生命週期,首先是每六個月就會放一次新版,跟 Ubuntu 相同,也都是四月與十月:
In parallel, we will be branching a new Stable line of releases every 6 months, one in October and one in April each year.
每個 LTS 版本將會有 18 + 12 = 30 個月的支援期:
This means that there will be overlapping LTS branches being maintained throughout the year, each receiving attention for a total of 30 months (LTS plus Maintenance).
這張圖說明了 LTS 與維護的時間線:
有個 LTS 的指標可以挑了...
在「Usability: Don't Make Me Think and a Bookmarklet」這篇文章裡作者在讀了「Don’t Make Me Think, Revisited」之後有所啟發,寫了一小段 javascript code,可以將網頁上所有文字都變成同樣長度的亂碼,藉以測試許多 usability 特性。
我把程式碼丟進 yui-compressor 後變成這樣,比較容易貼到 bookmarklet 上使用:
javascript:(function(){var a=" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";$("*:not(iframe)").contents().filter(function(){return this.nodeType==Node.TEXT_NODE&&this.nodeValue.trim()!=""}).each(function(){var c="";for(var b=0;b<this.nodeValue.trim().length;b++){c+=a.charAt(Math.floor(Math.random()*a.length))}this.nodeValue=c})})();
不過這段程式碼假定頁面上有 $
這個 object (i.e. jQuery),所以我把程式碼改成吃 jQuery
這個 object,這樣確保 jQuery.noConflict() 後的網站還是可以動:
javascript:(function(){var a=" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";jQuery("*:not(iframe)").contents().filter(function(){return this.nodeType==Node.TEXT_NODE&&this.nodeValue.trim()!=""}).each(function(){var c="";for(var b=0;b<this.nodeValue.trim().length;b++){c+=a.charAt(Math.floor(Math.random()*a.length))}this.nodeValue=c})})();
效果如下,還蠻有趣的:
在 Plurk 上的 embed thumb 功能 (我不知道怎麼稱呼比較好) 讓我沒辦法用 Ctrl 加上滑鼠左鍵一路把圖片點開,所以就想寫個 Greasemonkey script 搞定他...
所以重點是 jQuery('body').off('click', '.pictureservices, .videoservices, .ogvideo, .iframeembed, .plink'); 關掉...
— Gea-Suan Lin (@gslin) July 26, 2015
最一開始的想法是把事件幹掉 (也就是 .pictureservices, .videoservices, .ogvideo, .iframeembed, .plink
這串),所以第一版的時候是直接用 unsafeWindow.jQuery
把事件 off()
掉,但後來想一想這樣有幾個問題:
unsafeWindow.jQuery
不保證是原版的 jQuery,在 Greasemonkey 有不少權限,雖然後來有被 @grant
強化過,不過能避免還是想避免。所以就改成現在這個版本,直接在 body 上攔截,擋下對這五個 class 的 click event:「Disable Plurk multimedia thumb functuion」。
也許改寫 thumb function 本身會更好,不過先這樣吧 XD
AWS 推出了「Amazon API Gateway – Build and Run Scalable Application Backends」,使得 Scalable API 又前進了一步。
API Gateway 可以直接將 HTTP Endpoint 接上 AWS Lambda 提供服務,並且也會自動接上 CloudFront,不過 CloudFront 不可選等級,目前看起來是最低的 Class 100,所以老問題還是沒解,如果不是用 168.95.1.1
或 168.95.192.1
,我們家的 IP 會被解去 ARN (Stockholm Arlanda Airport) XD
4.|-- snuh-3201.hinet.net 0.0% 10 0.3 0.3 0.3 0.3 0.0 5.|-- tpdt-3011.hinet.net 0.0% 10 6.7 9.0 4.8 12.5 2.8 6.|-- r4101-s2.tp.hinet.net 0.0% 10 0.5 0.9 0.5 1.5 0.0 7.|-- r4001-s2.tp.hinet.net 0.0% 10 3.8 1.1 0.5 3.8 1.2 8.|-- r11-pa.us.hinet.net 0.0% 10 199.8 151.6 143.1 199.8 19.0 9.|-- las-bb1-link.telia.net 0.0% 10 140.6 142.6 140.5 159.7 6.0 10.|-- sjo-b21-link.telia.net 0.0% 10 141.6 142.1 141.5 146.1 1.2 11.|-- nyk-bb2-link.telia.net 0.0% 10 217.0 218.9 217.0 224.0 2.6 12.|-- kbn-bb4-link.telia.net 0.0% 10 305.7 305.8 305.7 306.2 0.0 13.|-- s-bb4-link.telia.net 0.0% 10 316.4 316.4 316.4 316.6 0.0 14.|-- s-b9-link.telia.net 10.0% 10 316.4 316.5 316.4 317.5 0.0 15.|-- amazon-ic-300293-s-b9.c.t 10.0% 10 311.5 311.5 311.4 311.5 0.0 16.|-- ??? 100.0 10 0.0 0.0 0.0 0.0 0.0 17.|-- ??? 100.0 10 0.0 0.0 0.0 0.0 0.0 18.|-- ??? 100.0 10 0.0 0.0 0.0 0.0 0.0 19.|-- server-54-230-96-67.arn1. 10.0% 10 311.5 311.8 311.5 313.2 0.4
除了使用提供的 url 以外 (HTTPS Endpoint),也可以接上自己的 domain (以及對應的 SSL certificate):
另外功能是產生 SDK,支援 iOS、Android 以及 JavaScript 三種版本:
這樣又簡化了不少東西...
Mozilla Developer Network (MDN) 寫了一篇關於 JavaScript 的介紹文章,算是以現在的角度來教 JavaScript:「A re-introduction to JavaScript (JS tutorial)」。
不是給完全不懂的人入門看的,而是對程式語言有了解的人看的。
文章裡面不單純只是教學,還引用了許多重要的文獻,尤其是 ECMAScript 規格書。有想要考據確認規格書怎麼定義會很方便。
而最後面還提到了 browser 上 DOM 實作時的 memory leak 問題以及解法,這對於現在 single page application 的應用也愈來愈重要了。
Google Online Security 分析了前陣子 GitHub 被 DDoS 攻擊的行為:「A Javascript-based DDoS Attack as seen by Safe Browsing」。
透過 Google 的 Safe Browsing,針對 baidu.com
這個網域的 injection 情況分析:
可以看得出來分成多個不同階段攻擊。其中 AWS 的 CloudFront 承受了不小的壓力,不過畢竟是商用水準的 CDN,沒那麼容易垮掉。後來則是攻擊 GitHub 造成影響而上了新聞。
最終還是繼續推廣 TLS,可以避免中間被 injection 攻擊:
Had the entire web already moved to encrypted traffic via TLS, such an injection attack would not have been possible.