2015年9月3日 星期四

Google Cloud Platform V.S AWS



價格試算:

Amazon Web Service:

Google Cloud Platform:


IO PK:

By the numbers: How Google Compute Engine stacks up to Amazon EC2


價格PK:

Google vs. AWS Pricing: Google Cuts Are First of 2015


網路速度PK

Need for speed: Testing the networking performance of the top 4 cloud providers

Amazon EC2 vs Azure vs Rackspace Cloud vs Google C. Engine | Some tests and stats


總結:


  • Google Cloud在大優點是在台灣有機房,相比AWS東京,ping大勝
  • Google在價格上有優勢
  • AWS在產品完整度上Google目前還不能比
以新創、低需求、低成本來考慮的話,Google或許是個好選擇?



2015年6月8日 星期一

joomla 移除url中的index.php



1.系統->全站設定->網站設定->使用網址重寫(URL rewrite)選擇Yes



2.將joomla站點根目錄下的htaccess .txt文件重命名為.htaccess


2015年6月3日 星期三

[轉貼]2015 5月 android 版本市佔率


統計期間: 2015/5/26~2015/06/01

VersionCodenameAPIDistribution
2.2Froyo80.3%
2.3.3 -
2.3.7
Gingerbread105.6%
4.0.3 -
4.0.4
Ice Cream Sandwich155.1%
4.1.xJelly Bean1614.7%
4.2.x1717.5%
4.3185.2%
4.4KitKat1939.2%
5.0Lollipop2111.6%
5.1220.8%












資料來源:

2015年5月19日 星期二

linux sync指令


Linux 系統中,為了加快資料的讀取速度,寫入硬盤的資料有的時候為了效能,會寫到 filesystem buffer 中,這個 buffer 是一塊記憶體空間,如果欲寫入硬碟的資料存此 buffer 中,而系統又突然斷電的話,那資料就會流失!


  • 可以透sync 指令,將存 buffer 中的資料強制寫入disk中;


Name

sync - synchronize data on disk with memory

Synopsis

sync [--help] [--version]

Description

 sync writes any data buffered in memory out to disk. This can include (but is not limited to) modified superblocks, modified inodes, and delayed reads and writes. This must be implemented by the kernel; The sync program does nothing but exercise the sync system call.
The kernel keeps data in memory to avoid doing (relatively slow) disk reads and writes. This improves performance, but if the computer crashes, data may be lost or the file system corrupted as a result. sync ensures that everything in memory is written to disk.

sync should be called before the processor is halted in an unusual manner (e.g., before causing a kernel panic when debugging new kernel code). In general, the processor should be halted using the shutdown or reboot or halt commands, which will attempt to put the system in a quiescent state before calling sync.




  • 或是在程式中利用sync() function ;


Name

sync - commit buffer cache to disk

Synopsis

#include <unistd.h>

void sync(void);

Feature Test Macro Requirements for glibc

sync():
_BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED


Description

sync() causes all buffered modifications to file metadata and data to be written to the underlying file systems.

Errors

sync() is always successful.


資料來源:
sync(2) - Linux man page
sync(8) - Linux man page

2015年4月6日 星期一

[轉貼/筆記]JNI


JNI 是用來讓Java跟別種語言溝通的函式庫,以C/C++ 為例,分為C call Java與Java call C。


JNI整個流程(java call c 的範例

開發環境:Netbeans, Microsoft Visual Studio 2005

1.使用Netbeans新增專案,選擇Java Application


2.專案名稱:JNIFirst


3.新增Java Class檔


4.檔名:JNIHello,注意不要將JNIHello.java包在package內,不然編譯.h檔時會error。



5.撰寫JNIHello.java內的code


6.接下來要產生.h檔,要用commend line的方式下指令,若你的電腦尚未設定用cmd下java指令的 話可以參考我寫的這篇"設定java環境變數使cmd能下javac等命令";首先要先
切換到JNIHello.java檔的目錄下,下指令產生.class,再用class檔產生.h檔,指令:javac JNIHello.java
javah -jni JNIHello
(2010.1.25新增:要是有package, 輸入指令javah -jni [PACKAGE].[CLASSNAME]
,並注意要移到package的上層資料夾.)
(2010.8.30新增:修改package名稱請檢查三部分-----1.重新產生.h檔 2.修改include檔名 3.修改function名稱. )
如圖中。


7.Netbeans使用暫告一段落。開啟Microsoft Visuall Studio 2005,新增專案選
類別庫(library),
專案名稱:JNIHelloWorld。


8.將剛剛由Netbeans產生的
JNIHello.h檔copy到此Project的JNIHelloWorld目錄下。


9.將專案自動產生的
JNIHelloWord.h刪除加入我們剛copy進來的JNIHello.h檔。(當然也可以在新增專案時將名稱設為JNIHello,這樣就不用改名稱直接覆蓋即可,此處為了要說明.h檔與Project的關係故意取不同名稱。)


10.加入JNIHello.h。


11.打開JNIHello.h檔看一下紅框處,function name為Java_JNIHello_printHelloWorld,撰寫cpp檔時就要用這個function。


12.撰寫JNIHelloWorld.cpp,code如圖中。


13.因為有include"jni.h"所以要設定VC的path讓它找的到。選工具->選項。


14.選VC++目錄,include檔案,新增path。


15.設定好之後可以來產生.dll檔案了,選擇建置方案或按F7。


16.建置完成會產生JNIHelloWorld.dll,
注意檔案是產生在JNIHelloWorld Project目錄下的debug,d為小寫,不是產生在JNIHelloWorld->JNIHelloWorld->Debug;將dll複製到Netbeans的Project目錄下。


17.開Netbeans,看一下我們剛寫JNIHello.java,由於dll的檔名為JNIHelloWorld.dll,所以要
將紅框處修改為JNIHelloWorld


18.現在來建置一下看看結果是否成功,選run main project。


19.秀出Hello World!。成功囉!


JNI下的Java資料型別


JNI下的C/C++程式如果要使用Java的資料型別,型別名稱前必須要加上「j」,例如:「int」變成「jint」,「long long」變成「jlong」,「String」變成「jstring」,都是小寫字母。這裡要注意的是,如果是物件型別(非基本資料型別)的話,只有特定幾個物件可以直接加上「j」,像是「String」或是「Array」,不然的話都是「jobject」。



資料來源:

2015年4月3日 星期五

[轉貼/筆記]linux screen使用方法

screen的全名叫做(full-screen window manager),是在Linux or BSD上一個很好用的工具,可以讓你在一個terminal下開啟多重視窗執行,讓你只要靠一個putty/pietty視窗就可以同步地處理很多的事情,視窗彼此的切換又很方便迅速,有點像瀏覽器的「分頁」功能一樣。

例如說你可以開一個視窗正在compile程式,另開一個視窗開vim看code,再開第三個視窗連ftp抓一個大檔,最後再開一個視窗用偷偷telnet連BBS逛PTT這樣(最後一個上班不要亂用,視窗間可以隨時用熱鍵切換,彼此卻又運作順暢互不干擾。


screen 操作指令表

screen 參數說明
Ctrl + a 與 c建立新 screen 視窗
Ctrl + a 與 Ctrl + a切換至上一個 screen 視窗
Ctrl + a 與數字鍵 0 到 9切換至指定編號的 screen 視窗
Ctrl + a 與 n切換至下一個的 screen 視窗
Ctrl + a 與 p切換至下一個的 screen 視窗
Ctrl + a 與 w列出目前所有的 screen 視窗
Ctrl + a 與 "列出目前所有的 screen 視窗,並可用上下鍵選擇要切換的設窗
Ctrl + a 與 k關閉目前的 screen 視窗
Ctrl + a 與 d卸離 screen 工作環境
Ctrl + a 與 Esc 鍵(或Ctrl + a 與 [進入複製模式(copy mode),可用方向鍵操作捲軸,或用 / 與 ? 來搜尋,按下空白鍵開始選取要複製的內容,選取完成後再按下第二次空白鍵,即可複製,隨後使用 Ctrl + ] 可貼上複製的內容。
Ctrl + a 與 S將畫面分割成上下兩個區域
Ctrl + a 與 Q關閉分割畫面
Ctrl + a 與 Tab 鍵切換分割畫面
Ctrl + a 與 t顯示目前系統的時間與負載狀況
Ctrl + a 與 a送出 Ctrl + a
Ctrl + a 與 ?顯示說明
Ctrl + a 與 v顯示版本資訊
Ctrl + a 與 x鎖定 screen 螢幕
Ctrl + a 與 H開啟或結束 screen 紀錄功能
Ctrl + a 與 C清除 screen 視窗中的內容
Ctrl + aD 與 D強力卸離,卸離 screen 工作環境之後,直接登出
Ctrl + a 與 Ctrl + g視覺化鈴聲(visual bell)切換
Ctrl + a 與 i顯示目前 screen 視窗的資訊
Ctrl + a 與 l重繪目前 screen 視窗的內容

資料來源:


2015年3月27日 星期五

[Tool]Windows檔案總管進化版(Clover & Q-Dir)

Windows中開啟多個檔案總管視窗,在工具列上會有一疊的視窗,切換視窗時必須慢慢找,工作效率超差。

希望檔案總管視窗可以像Chorme瀏覽器一樣有分頁功能、甚至是書籤等功能!


以下是兩個看似不賴的tool官方介紹、圖片與連結

1.「Clover」:http://cn.ejie.me/#

為您的 Windows Explorer 插上翅膀!

Clover 是Windows Explorer 資源管理器的一個擴展,為其增加類似谷歌Chrome 瀏覽器的多標籤頁功能。

Q-Dir (the Quad Explorer) makes your files and folder easy to manage, as an installed or portable Windows program. Fast and easy access to your hard disks, network folders, USB-Stiks, floppy disks and other storage devices.

Q-Dir i a good file manager with an amazing Quadro-View technique.
You don't have to renounce the usual, Drag and Drop, all Views, and other functions of your system.