pretty code

2016年7月22日 星期五

grep examples

# 挑出超過 1000 ms 的資料
110.txt: 100%    800 (longest request)
111.txt: 100%   2538 (longest request)
112.txt: 100%   1209 (longest request)
113.txt: 100%   2341 (longest request)
114.txt: 100%    829 (longest request)
115.txt: 100%   2506 (longest request)
116.txt: 100%    829 (longest request)
117.txt: 100%   2372 (longest request)
118.txt: 100%    862 (longest request)
119.txt: 100%   5681 (longest request)
120.txt: 100%    803 (longest request)

ANS: grep -E "%\s{3}\S"
前面一定要加入 % ,不然就如圖片所示,有 4個空白的列也會符合。








The Apache Hints of Windows Platform

Apache 2.4.23

# Check Compiled modules
C:\Apache\bin>httpd -l
Compiled in modules:
  core.c
  mod_win32.c
  mpm_winnt.c
  http_core.c
  mod_so.c

# 記憶體調校
如果做壓力測試時,發現 httpd 的虛擬記憶體不斷的上升,此時可以調整以下參數
1. Keep Alive:
關掉 Keep Alive,或是減少 MaxKeepAliveRequests 以及減少 KeepAliveTimeout,Apache 為了保持連線,會保留記憶體而未釋放。
2. MaxConnectionsPerChild (after 2.3.9) or MaxRequestsPerChild (before 2.3.9):
Windows 的 Apache 共有 2 個 httpd.exe process,其中 1個是子進程,負責處理所有的 requests。當設置這 2 個參數後,如果達到 Max 的 Connections or Requests,母進程便會殺掉子進程,因此就能釋放原本被佔用的記憶體,此預設值為 0 表示無限制。

# AcceptPathInfo
This directive controls whether requests that contain trailing pathname information that follows an actual filename (or non-existent file in an existing directory) will be accepted or rejected.
example: /test/here.html/more
如果啟用的話,則 /more 便會視為 PATH_INFO,此預設值為 Default,處理 scripts 時 accepted,其他則 rejected。

2014年10月26日 星期日

Autosize in wxWidgets with wxDev-C++

If you want the app to change it's layout when window is maximal, you must use sizers. There are many sizers in wxWidgets, such as wxBoxSizer, wxGridSizer and wxFlexGridSizer.

When I have two vertical parts in window and I want the bottom part is fixed size, I can use wxBoxSizer and put two panels on wxBoxSizer. Here is settings about these components.

wxBoxSizer:
Orientation is wxVertical.

wxPanel1(top):
wxALIGN_TOP is true.
wxEXPAND is true.
Stretch Factor is 1.

wxPanel2(bottom):
wxALIGN_BOTTOM is true.
wxEXPAND is true.

If you set Stretch Factor, the part will be adjusted size when window is maximal.


2014年10月19日 星期日

大法官觀後感

昨天去看了電影-大法官
覺得這部電影有很多點可以在看完後好好想想
But 人生總是會有 But ...

看完電影準備去運動時
開車由建國高架往南
剛從南京上閘道後就被後面一台小車撞到
我前面因為有車要下建國
當時我的車已踩煞車
幾乎是快停止的狀態
居然也能被撞到
不知道駕駛當時在想什麼

不過最白吃的還是我本人
當時看一下以為只撞到保險桿
就叫他開車要小心點
換來一句謝謝後就離開

開到公園後
下車仔細看看
才發現左輪上方板金受損
輪圈受損
保險桿也受損
害我一整個心情不好

幸好熟悉的輪胎行晚上有營業
晚上花了 7000 換掉 4 個輪圈
輪胎因為沒事故不用換掉
不然至少還要換掉 2 個才能平衡
再加上板金
我想這次被撞沒花個一萬塊跑不掉

那位大哥
遇到我是你運氣好
請你下次好好小心開車
車上還載著家人
為什麼不更小心點

可憐我的小白


2014年10月18日 星期六

How to catch windows message in wxWidgets

1. Add define in your header file.

WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);

2. Add implement in your cpp file.

WXLRESULT XXX::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
    switch(message)
    {
        case WM_KEY:
            break;
        default:
            break;
    }  
 
    return ZZZ::MSWWindowProc(message, wParam, lParam);
 }

XXX is your class name and ZZZ is the base class that you derive.

3. You can catch the windows message what you want now.

2014年10月10日 星期五

Update wxWidgets' libs in wxDev-C++

Because the wxWidgets's version is 2.9.3 in wxDev-C++, I want to use the new version, this is the steps how to do:

My wxDev-C++'s installing path is "C:\wxDev-Cpp".

1. Download the wxWidget's source and unzip to C:\wxWidgets.
2. Open cmd window and type "set path=C:\wxDev-Cpp\MinGW32\bin". Then "cd wxWidgets\build\msw".
3. Type "mingw32-make -f makefile.gcc UNICODE=1 SHARED=0 BUILD=release MONOLITHIC=1".
4. After compiling it, copy "C:\wxWidgets\lib\gcc_lib\*.a" to C:\wxDev-Cpp\lib\wx\gcc_lib".
5. Replace "C:\wxDev-Cpp\include\common" from "C:\wxWidgets\include".
6. Copy "C:\wxWidgets\lib\gcc_lib\mswu\wx\setup.h" to "C:\wxDev-Cpp\include\common\wx".
7. Change wxWidgets's version in wxDev-C++ -> Tools -> Compiler Options -> Version info.
8. Before you compile old project, remember to del all *.o in "project\Objects\MingW".
9. Enjoy it.

2014年8月15日 星期五

Ubuntu 啟動相關檔案

/etc/init.d/xxxxx
啟動 script 放置處

/etc/rcx.d/
啟動 level 對應的服務 script, 由系統產生

為了避免影響其他服務
開機想要自動執行的
可以寫在 /etc/rc.local