<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 72, comments - 66, trackbacks - 0, articles - 0

    View cpu information command:
    1 # dmesg | grep CPU
    2 # cat /proc/cpuinfo

    you can find the following from the show :AMD Athlon(tm) 64 X2 Dual Core Processor 4000+
    It tell you :64bit cpu

    View OS version:
    # cat /proc/version
    you can see information similar to the following:
    Linux version 2.6.24-21-generic (buildd@palmer) (gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)) #1 SMP Tue Oct 21 23:43:45 UTC 2008

    View OS bit num:
    # getconf LONG_BIT
    you can see :32 or 64.


    posted @ 2009-02-26 10:42 Fingki.li 閱讀(350) | 評論 (0)編輯 收藏

         摘要: If you install im gateway plugin firstly, perhaps you did not encounter this problem.
    If you upgrade your im gateway plugin, perhaps you have been in trouble.
    Unfortunately,I encountered this problem some days ago.
    I used the openfire 3.4.5, and it contains the gateway plugins;  閱讀全文

    posted @ 2009-02-25 16:58 Fingki.li 閱讀(1789) | 評論 (0)編輯 收藏

         摘要: sudoer application Launcher
    On Ubuntu,run applications as sudo via Application Launcher  閱讀全文

    posted @ 2009-02-23 12:33 Fingki.li 閱讀(1319) | 評論 (0)編輯 收藏

    JSCalendar 日歷控件 使用樣例如下:

    <html>
    <head>
        <style type="text/css">@import url( /js/jscalendar/calendar-win2k-cold-1.css );</style>
        <script type="text/javascript" src="/js/jscalendar/calendar.js"></script>
        <script type="text/javascript" src="/js/jscalendar/i18n.jsp"></script>//不用i18n可以指定語言 如:<script type="text/javascript" src="/js/jscalendar/lang/calendar-en.js"></script>
        <script type="text/javascript" src="/js/jscalendar/calendar-setup.js"></script>
    </head>
    <body>
    <input type="text" size="10" name="fromDate" id="fromDate" maxlength="10" onchange="checkSpecific();" value=""/>
    <img src="images/icon_calendarpicker.gif" id="fromDateCal" />
    <br>
    <script type="text/javascript" >
        Calendar.setup(
        {
            inputField  : "fromDate",       // ID of the input field
            ifFormat    : "%m/%d/%Y",       // the date format
            button      : "fromDateCal",    // ID of the button
        });
    </script>
    </body>
    </html>
    上述示例代碼在jsp容器中運行完全正常。

    posted @ 2009-02-17 15:35 Fingki.li 閱讀(2724) | 評論 (10)編輯 收藏

    當(dāng)一個類實現(xiàn)了序列化接口,有時會遇到 java.io.InvalidClassException 異常出現(xiàn):
    java.io.InvalidClassException: com.test.Test; local class incompatible: stream classdesc serialVersionUID = 7981560250804078637, local class serialVersionUID = -8334405535174160822
    這是序列化兼容性所致;
    java通過一個名為UID(stream unique identifier)來控制,這個UID是隱式的,它通過類名,方法名等諸多因素經(jīng)過計算而得,理論上是一一映射的關(guān)系,也就是唯一的。如果UID不一 樣的話,就無法實現(xiàn)反序列化了,并且將會得到InvalidClassException。
    當(dāng)要人為的產(chǎn)生一個新的版本(實現(xiàn)并沒有改動),而拋棄以前的版本的話,可以通過顯式的聲名UID來實現(xiàn):
    private static final long serialVersionUID=????;//(你可以編造一個UID,但不能有重復(fù))

    對于上例我們可以在com.test.Test類中加入 :
    private static final long serialVersionUID=7981560250804078637l;
    這樣就解決了新老版本的兼容性問題。
    當(dāng)然,對于序列化還有很多問題,慢慢研究吧。

    posted @ 2009-01-13 11:46 Fingki.li 閱讀(17591) | 評論 (3)編輯 收藏

    對volatile,看到了個很清楚的解釋,摘錄下來如下:

    volatile關(guān)鍵字有什么用?
    恐怕比較一下volatile和synchronized的不同是最容易解釋清楚的。volatile是變量修飾符,而synchronized則作用于一段代碼或方法;看如下三句get代碼:

    1. inti1;              intgeti1(){returni1;}
    2. volatile inti2;              intgeti2(){returni2;}
    3.          int i3; synchronizedintgeti3(){returni3;}

      geti1()得到存儲在當(dāng)前線程中i1的數(shù)值。多個線程有多個i1變量拷貝,而且這些i1之間可以互不相同。換句話說,另一個線程可能已經(jīng)改 變了它線程內(nèi)的i1值,而這個值可以和當(dāng)前線程中的i1值不相同。事實上,Java有個思想叫“主”內(nèi)存區(qū)域,這里存放了變量目前的“準(zhǔn)確值”。每個線程 可以有它自己的變量拷貝,而這個變量拷貝值可以和“主”內(nèi)存區(qū)域里存放的不同。因此實際上存在一種可能:“主”內(nèi)存區(qū)域里的i1值是1,線程1里的i1值 是2,線程2里的i1值是3——這在線程1和線程2都改變了它們各自的i1值,而且這個改變還沒來得及傳遞給“主”內(nèi)存區(qū)域或其他線程時就會發(fā)生。
    而geti2()得到的是“主”內(nèi)存區(qū)域的i2數(shù)值。用volatile修飾后的變量不允許有不同于“主”內(nèi)存區(qū)域的變量拷貝。換句話說,一個變量經(jīng) volatile修飾后在所有線程中必須是同步的;任何線程中改變了它的值,所有其他線程立即獲取到了相同的值。理所當(dāng)然的,volatile修飾的變量 存取時比一般變量消耗的資源要多一點,因為線程有它自己的變量拷貝更為高效。
    既然volatile關(guān)鍵字已經(jīng)實現(xiàn)了線程間數(shù)據(jù)同步,又要synchronized干什么呢?呵呵,它們之間有兩點不同。首 先,synchronized獲得并釋放監(jiān)視器——如果兩個線程使用了同一個對象鎖,監(jiān)視器能強制保證代碼塊同時只被一個線程所執(zhí)行——這是眾所周知的事 實。但是,synchronized也同步內(nèi)存:事實上,synchronized在“主”內(nèi)存區(qū)域同步整個線程的內(nèi)存。因此,執(zhí)行g(shù)eti3()方法做 了如下幾步:
    1. 線程請求獲得監(jiān)視this對象的對象鎖(假設(shè)未被鎖,否則線程等待直到鎖釋放)
    2. 線程內(nèi)存的數(shù)據(jù)被消除,從“主”內(nèi)存區(qū)域中讀入(Java虛擬機能優(yōu)化此步。。。[后面的不知道怎么表達(dá),汗])
    3. 代碼塊被執(zhí)行
    4. 對于變量的任何改變現(xiàn)在可以安全地寫到“主”內(nèi)存區(qū)域中(不過geti3()方法不會改變變量值)
    5. 線程釋放監(jiān)視this對象的對象鎖
    因此volatile只是在線程內(nèi)存和“主”內(nèi)存間同步某個變量的值,而synchronized通過鎖定和解鎖某個監(jiān)視器同步所有變量的值。顯然synchronized要比volatile消耗更多資源。

    附英文原文:
    What does volatile do?

    This is probably best explained by comparing the effects that volatile and synchronized have on a method. volatile is a field modifier, while synchronized modifies code blocks and methods. So we can specify three variations of a simple accessor using those two keywords:

    1. inti1;              intgeti1(){returni1;}
    2. volatile inti2;              intgeti2(){returni2;}
    3.          int i3; synchronizedintgeti3(){returni3;}

    geti1() accesses the value currently stored in i1 in the current thread. Threads can have local copies of variables, and the data does not have to be the same as the data held in other threads. In particular, another thread may have updated i1 in it’s thread, but the value in the current thread could be different from that updated value. In fact Java has the idea of a “main” memory, and this is the memory that holds the current “correct” value for variables. Threads can have their own copy of data for variables, and the thread copy can be different from the “main” memory. So in fact, it is possible for the “main” memory to have a value of 1 for i1, for thread1 to have a value of 2 for i1 and for thread2 to have a value of 3 for i1 if thread1 and thread2 have both updated i1 but those updated value has not yet been propagated to “main” memory or other threads.

    On the other hand, geti2() effectively accesses the value of i2 from “main” memory. A volatile variable is not allowed to have a local copy of a variable that is different from the value currently held in “main” memory. Effectively, a variable declared volatile must have it’s data synchronized across all threads, so that whenever you access or update the variable in any thread, all other threads immediately see the same value. Of course, it is likely that volatile variables have a higher access and update overhead than “plain” variables, since the reason threads can have their own copy of data is for better efficiency.

    Well if volatile already synchronizes data across threads, what is synchronized for? Well there are two differences. Firstly synchronized obtains and releases locks on monitors which can force only one thread at a time to execute a code block, if both threads use the same monitor (effectively the same object lock). That’s the fairly well known aspect to synchronized. But synchronized also synchronizes memory. In fact synchronized synchronizes the whole of thread memory with “main” memory. So executing geti3() does the following:

    1. The thread acquires the lock on the monitor for object this (assuming the monitor is unlocked, otherwise the thread waits until the monitor is unlocked).
    2. The thread memory flushes all its variables, i.e. it has all of its variables effectively read from “main” memory (JVMs can use dirty sets to optimize this so that only “dirty” variables are flushed, but conceptually this is the same. See section 17.9 of the Java language specification).
    3. The code block is executed (in this case setting the return value to the current value of i3, which may have just been reset from “main” memory).
    4. (Any changes to variables would normally now be written out to “main” memory, but for geti3() we have no changes.)
    5. The thread releases the lock on the monitor for object this.

    So where volatile only synchronizes the value of one variable between thread memory and “main” memory, synchronized synchronizes the value of all variables between thread memory and “main” memory, and locks and releases a monitor to boot. Clearly synchronized is likely to have more overhead than volatile.

    摘自:http://bianbian.org/technology/java/88.html

    posted @ 2009-01-06 15:24 Fingki.li 閱讀(402) | 評論 (0)編輯 收藏

    有synthetic標(biāo)記的field和method是class內(nèi)部使用的,正常的源代碼里不會出現(xiàn)synthetic field。小穎編譯工具用的就是jad.所有反編譯工具都不能保證完全正確地反編譯class。所以你不能要求太多。
    下面我給大家介紹一下synthetic

    下面的例子是最常見的synthetic field
    class parent
    {
    public void foo()
    {
    }
    class inner
    {
    inner()
    {
    foo();
    }
    }
    }
    非static的inner class里面都會有一個this$0的字段保存它的父對象。編譯后的inner class 就像下面這樣:
    class parent$inner
    {
    synthetic parent this$0;
    parent$inner(parent this$0)
    {
    this.this$0 = this$0;
    this$0.foo();
    }
    }
    所有父對象的非私有成員都通過 this$0來訪問。

    還有許多用到synthetic的地方。比如使用了assert 關(guān)鍵字的class會有一個
    synthetic static boolean $assertionsDisabled 字段
    使用了assert的地方
    assert condition;
    在class里被編譯成
    if(!$assertionsDisabled && !condition)
    {
    throw new AssertionError();
    }

    還有,在jvm里,所有class的私有成員都不允許在其他類里訪問,包括它的inner class。在java語言里inner class是可以訪問父類的私有成員的。在class里是用如下的方法實現(xiàn)的:
    class parent
    {
    private int value = 0;
    synthetic static int access$000(parent obj)
    {
    return value;
    }
    }
    在inner class里通過access$000來訪問value字段。

    摘自:
    http://www.cjsdn.net/post/print?bid=1&id=130784

    posted @ 2009-01-06 12:24 Fingki.li 閱讀(3466) | 評論 (0)編輯 收藏

    相關(guān)資料:
    IETF : http://www.potaroo.net/ietf/idref/draft-nourse-scep/
    Java SCEP : http://www.urut.ch/scep/
    OpenSCEP : http://openscep.othello.ch/

    posted @ 2009-01-04 14:25 Fingki.li 閱讀(336) | 評論 (0)編輯 收藏

    一朋友推薦給我的文章,感覺很不錯;摘抄過來,也給同行們提個醒!

    論壇里經(jīng)常可以看到關(guān)于 35 歲程序員的生涯詢問, 他們之中有些人寫了十年代碼, 有些人則是因為對編程發(fā)生了興趣, 中途轉(zhuǎn)行, 以下四點是給那些 30 - 35 歲程序員的建議:

    * 照顧自己健康

    以前, 我認(rèn)為 "錢" 是很重要的, 俗話說的好: "錢不是萬能, 但沒有錢萬萬不能", 所以過去我的焦點都是放在收入, 但后來我發(fā)現(xiàn)有比錢更重要的東西, 那是 "家", 在你沒有結(jié)婚前, 這個家的概念是指你和父母的和諧關(guān)系, 而在結(jié)婚后, 家的概念是指如何維系一個家庭, 包括和太太還有孩子的關(guān)系。

    在 IT 這個行業(yè)里, 很多人跟自己父母的想法是有差距的, 認(rèn)為上一代保守, 食古不化, 講到很多東西沒法溝通, 另外, 我的很多朋友事業(yè)做很大, 但最后卻離婚了, 沒有孩子還好, 有孩子的要想更多, 只有家, 你才有奮斗的目標(biāo), 才有精神的支持, 否則就像電視里講的那一句, 失去了你, 得到江山又如何?

    但這個家的信念自從張國榮事件后, 又改變了我的看法, 那就是有比家更重要的東西, 那是你的 "健康", 這個健康包括生理和心理上的健康, 想想看你擁有了一個家, 但是因為沒有健康, 全家人都被拖下去了, 每天看著你痛苦的吊瓶子, 更嚴(yán)重的直接輕生, 這樣遺留給珍愛你的人只是更大的痛苦, 你會 C, C++, C#, Java... 又怎樣? 那時候你會認(rèn)為這些通通都是屁, 做人做到能夠 "吃得下飯、睡得著覺、笑得出來" 就已經(jīng)是莫大的幸福。

    35 歲會困惑的人多半是因為二十幾歲的時候就沒有做好準(zhǔn)備, 過去的已經(jīng)不可追, 現(xiàn)在要想的應(yīng)該是 45 歲怎么辦? 有人說年輕比的是學(xué)問, 中年比的是財富, 老年比的是健康, 如果你現(xiàn)在不注意自己健康, 那么很快更大的困擾就會上門了, 人生每個階段都有扮演的角色, 要學(xué)會未雨綢繆, 否則不用到 50 歲, 可能 40 歲就會開始后悔了, 健康要從飲食和運動著手, 多涉獵這方面的常識, 比搞那些過幾年就要淘汰的技術(shù)有意義多了。

    * 學(xué)會投資理財

    很多人認(rèn)為投資理財需要很多的錢, 這是不正確的, 會理財?shù)娜? 小錢可以積累到大, 不會理財?shù)娜? 大錢也會消耗到光, 投資理財首重的是風(fēng)險管理, 沒有風(fēng)險管理就像在刀口舔血一樣, 投資理財應(yīng)該要趁早磨練, 不要等到 40 歲的時候才去冒險, 因為那時候你已經(jīng)沒有本錢跌倒, 投資理財?shù)姆椒ㄓ泻芏? 并不是只有房地產(chǎn), 股票這些東西, 從節(jié)約, 儲蓄, 定存... 每一步都是學(xué)習(xí), 關(guān)鍵是你要從投資的過程里去發(fā)現(xiàn)自己, 并且了解如何正確對待甚至對付自己, 這樣你才有機會早一日達(dá)到經(jīng)濟自由, 不會提心吊膽這個那個。

    投資理財要量力而為, 不要做超過你能力所能負(fù)荷的事情, 我給程序員最好的建議是關(guān)注經(jīng)濟, 不要浮躁, 錯把投機當(dāng)投資, 這樣還不如定存來得可靠安全。

    * 經(jīng)營你的人脈

    我覺得程序員除了普遍不善理財外, 另外人際溝通也多有問題, 很多人在離開公司的剎那, 整個人感覺也都被掏空了, 而且會有一種擔(dān)憂, 以前別人跟我說話那是因為我是某某公司的員工, 現(xiàn)在不是了, 可能就沒有什么人會再鳥我了, 這就是典型的人脈經(jīng)營危機。

    人脈的經(jīng)營不是看你有沒有朋友, 而是有沒有能幫助你同時又有實力的朋友。有些人朋友很多, 但真正遇到困難, 只能精神上支持一下, 除此外, 幫不上任何忙, 這代表人脈還是太單薄, 不要總問別人能給你什么? 也要問問你能給別人什么? 懂得去欣賞別人, 而不要像患了紅眼病一樣, 漠視別人背后的辛勞的付出, 只知道妒忌表面的風(fēng)頭, 這樣, 只會將自己的路越走越窄。

    經(jīng)營自己的人脈是有秘訣的, 首先你要了解自己存在的價值, 如果沒有存在的價值, 那么經(jīng)營的人脈是空的, 這跟有存在價值卻不知道怎樣經(jīng)營人脈, 基本上差不多, 經(jīng)營人脈并不等于趨炎附勢, 而是指在得勢的時候, 就要想到落難的時刻, 待人寬厚真誠, 花無百日好, 人無千日紅, 多欣賞別人, 擇友深交, 別把時間浪費在小屁孩身上。

    * 培養(yǎng)廣泛興趣

    一個程序員如果除了 IT 以外, 一點其它的興趣也沒有, 那真的是很危險的事情, 像我現(xiàn)在年齡已經(jīng)超過 35 歲了, 很快就要 40, 但我現(xiàn)在還是每天寫代碼, 做項目已經(jīng)不是為了維生, 而是純粹興趣了, 我想我會一直寫下去, 同時開始加強自己經(jīng)營管理或財務(wù)方面的知識。你說郭安定以后玩不了電腦怎么辦? 他就去寫書, 萬一雙手廢了怎么辦? 那就去配音, 萬一聲音也啞了怎么辦? 那就重回金融市場, 讓徒子徒孫幫忙著下單, 眼球看左就買, 看右就賣, 就這么一直玩下去...

    所以人生不是只有一條路, 你得為自己想好方方面面, 而廣泛的興趣可以幫助你跳脫現(xiàn)況, 看到更多。

    以上四點不僅是 35 歲的人要注意的, 很多甚至二十幾歲的人也要開始關(guān)注, 說真的, 很多程序員看上去每個體型都不錯, 但體格都馬馬虎虎, 很多人熬個兩天夜就不行了, 不知該說什么... 一起加油吧。

    posted @ 2008-12-26 14:59 Fingki.li 閱讀(301) | 評論 (1)編輯 收藏

    Tsung,壓力測試的好工具。
    安裝過程:
    1.獲取tsung 的源碼。http://tsung.erlang-projects.org/
    2.安裝依賴 erlang(從源碼編譯 erlang 寫的程序) gnuplot perl5(如果想看 report 中的圖形,就要裝這個)
    apt-get install erlang erlang-src gnuplot perl5 我用的是Ubuntu 8 OS.
    3.編譯安裝
    ./configure
    make
    sudo make install

    安裝完成之后的 tsung 運行腳本在 /usr/bin/tsung ,在系統(tǒng) path 之中,可以直接運行。

    設(shè)置

    從 /usr/share/doc/tsung/examples 中挑一兩個例子拷貝到 ~/.tsung/tsung.xml 作為配置文件。我只需要 http 測試,所以:

    cp /usr/share/doc/tsung/examples/http_simple.xml ~/.tsung/tsung.xml

    tsung 采用了巧妙的 proxy 方式來“錄制”測試腳本。具體來說,就是建立一個本機的 http proxy 默認(rèn)使用 8090 端口,在配好 firefox 使用 localhost 8090 作為代理之后(推薦 foxyproxy 插件),所有“流經(jīng)”這個 proxy 的 http 動作都會被記錄下來,測試時可以“回放”這些步驟來產(chǎn)生請求。

    tsung rocorder
    tsung stop_recorder

    “錄制”完了,會得到一個 ~/.tsung/tsung_recorderXXXXXXXXXX.xml 文件,這就是測試時回回放的腳本。

    將這個腳本加到 tsung.xml 之中

    gedit ~/.tsung/tsung.xml

    就像這樣

    <!DOCTYPEtsungSYSTEM"/usr/share/tsung/tsung-1.0.dtd" [
     <!
    ENTITYmysession1SYSTEM"/home/yourname/.tsung/tsung_recorderXXXXXXXXXX.xml">
    ]>
    ...
    <sessions>
     
    &mysession1;
    </sessions>

    對配置稍作調(diào)整

    <monitoring>
        
    <monitorhost="localhost"type="erlang"></monitor>
     
    </monitoring>
     
    <!-- 需要配置到 localhost 無須密碼的 ssh 登錄(ssh via rsa_key),開啟了這個配置可以,獲得目標(biāo)機器的 cpu 和 ram 消耗情況 -->
     
    <load>
      
    <arrivalphasephase="1"duration="1"unit="minute">
        
    <usersinterarrival="2"unit="second"></users>
      
    </arrivalphase>
     
    </load>
     
    <!-- 第1階段1分鐘(你可以自己多搞幾個階段),其中每2秒新建一個用戶,每個用戶都會完整執(zhí)行 session 的測試腳本,最高并發(fā)約為 30 個,個人認(rèn)為這個“逐漸加壓”的方法比 ab xxxx 的“突然加壓”要慢一些,但更科學(xué)一點 -->

    運行

    準(zhǔn)備好了,加壓運行。

    tsung start

    運行完,在 ~/.tsung/log 目錄會生成一個以時間命名的目錄,進入這個目錄

    cd ~/.tsung/log/xxxxx
    /usr/lib/tsung/bin/tsung_stats.pl (有時可能是 /usr/local/lib/tsung/bin/tsung_stats.pl)

    生成 html 的壓力測試報告

    firefox report.html
    除了 http 以外 tsung 還可以壓很多東西,比如:jabber, postgreSQL 還可以寫插件來給任何你想要測試的東西加壓.

    posted @ 2008-12-01 10:43 Fingki.li 閱讀(1978) | 評論 (2)編輯 收藏

    僅列出標(biāo)題
    共8頁: 上一頁 1 2 3 4 5 6 7 8 下一頁 
    主站蜘蛛池模板: 激情小说亚洲图片| 99热在线日韩精品免费| 亚洲色偷偷综合亚洲AV伊人| 国产免费爽爽视频在线观看 | 国产在线98福利播放视频免费| 一级毛片a免费播放王色电影 | 免费的黄网站男人的天堂| 亚洲av综合av一区| 四虎影院免费视频| 中文字幕在线免费播放| 亚洲激情视频图片| 亚洲欭美日韩颜射在线二| 性xxxx视频播放免费| 国产一区二区三区免费| 亚洲国产成人久久精品大牛影视| 亚洲午夜国产精品无码| 老司机永久免费网站在线观看| 久久久99精品免费观看| 亚洲人成人网站18禁| 亚洲国产人成网站在线电影动漫| 国产成人免费一区二区三区| 美女内射无套日韩免费播放| 日日摸夜夜添夜夜免费视频| 亚洲va在线va天堂成人| 亚洲AV无码成人精品区蜜桃| 亚洲av无码成人精品区| 99久久免费国产精品特黄| 黄色网址在线免费| 色哟哟国产精品免费观看| 中文字幕在线日亚洲9| 亚洲精选在线观看| 中文字幕亚洲不卡在线亚瑟| 韩国日本好看电影免费看| 啦啦啦完整版免费视频在线观看| 未满十八私人高清免费影院| 亚洲欧美第一成人网站7777| 亚洲天堂电影在线观看| 亚洲国产综合专区电影在线| 国产亚洲精aa成人网站| 天堂亚洲免费视频| 日本媚薬痉挛在线观看免费|