tag:blogger.com,1999:blog-14441555473427003082024-02-07T11:02:22.423+08:00Caton + OO + Google =?This is my record about java , C# and web applicationCchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.comBlogger327125tag:blogger.com,1999:blog-1444155547342700308.post-76624090490423168962018-02-08T22:59:00.002+08:002018-02-08T23:00:13.161+08:00心得 open source license 查詢這兩天上了 開源程式碼的課程 知道有個網頁還不錯, 可以協助定義出 open source license 下<br />
<br />
的開發限制 , 是否需要繼續OPEN 程式的義務 及相關的感染力<br />
<br />
<br />
https://tldrlegal.com/Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-70749678990030550402014-11-28T14:14:00.000+08:002014-11-28T14:14:28.243+08:00心得 icon 編輯網站提供約500多個 icon 做編輯<br />
<br />
<br />
<span style="background-color: white; color: #444444; font-family: 'Times New Roman', Times, FreeSerif, serif; font-size: 18px; line-height: 24.6400012969971px;">Flatty Shadow </span><br />
<span style="background-color: white; color: #444444; font-family: 'Times New Roman', Times, FreeSerif, serif; font-size: 18px; line-height: 24.6400012969971px;"><br /></span>
<span style="background-color: white; color: #444444; font-family: 'Times New Roman', Times, FreeSerif, serif; font-size: 18px; line-height: 24.6400012969971px;">進入 網頁</span>http://flattyshadow.com/<span style="background-color: white; color: #444444; font-family: 'Times New Roman', Times, FreeSerif, serif; font-size: 18px; line-height: 24.6400012969971px;"> 上 找到 </span><br />
<span style="background-color: white; color: #444444; font-family: 'Times New Roman', Times, FreeSerif, serif; font-size: 18px; line-height: 24.6400012969971px;">view dashborad 就可以開始使用了 , 試過可以下載成PNG 或 js,css 組成的SVG</span><br />
<span style="background-color: white; color: #444444; font-family: 'Times New Roman', Times, FreeSerif, serif; font-size: 18px; line-height: 24.6400012969971px;"><br /></span>
<span style="background-color: white; color: #444444; font-family: 'Times New Roman', Times, FreeSerif, serif; font-size: 18px; line-height: 24.6400012969971px;">參考: </span><br />
<h3 class="post-title entry-title" itemprop="name" style="background-color: white; color: #444444; font-family: 'Times New Roman', Times, FreeSerif, serif; font-size: 27px; font-stretch: normal; margin: 0.75em 0px 0px; position: relative;">
<a href="http://www.playpcesor.com/2014/11/Flatty-Shadow-Flat-icon-download-free.html">500多種扁平化陰影 ICON 自動產生器!圖示免費下載, 電腦玩物</a></h3>
<br />
<br />
<br />Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-29992986208597910052014-11-24T10:21:00.002+08:002014-11-24T10:21:32.099+08:00class.getResource 取得 class 目錄相對的資源<br />
利用 XXClass<span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">.</span><span style="background-color: white; color: #7f0055; font-family: monospace; white-space: nowrap;"><b>class</b></span><span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">.getResource</span><span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">(</span><span style="background-color: white; color: #2a00ff; font-family: monospace; white-space: nowrap;">"fileName"</span><span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">)</span><span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">; 可以取得 相對</span>XXClass <span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">目錄的檔案</span><br />
<span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;"><br /></span>
<span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">這點在設計 config 檔 來控制程式方面還蠻實用的</span><br />
<span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;"><br /></span>
<span style="font-family: monospace;"><span style="background-color: white; white-space: nowrap;">大致有兩種路徑</span></span><br />
<span style="font-family: monospace;"><span style="background-color: white; white-space: nowrap;"><br /></span></span>
<span style="background-color: white; color: #3f7f5f; font-family: monospace; white-space: nowrap;">absolute 絕對路徑</span><span style="background-color: white; font-family: monospace; white-space: nowrap;"> </span><br />
ex. XXClass<span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">.</span><span style="background-color: white; color: #7f0055; font-family: monospace; white-space: nowrap;"><b>class</b></span><span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">.getResource</span><span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">(</span><span style="background-color: white; color: #2a00ff; font-family: monospace; white-space: nowrap;">"/fileName.txt"</span><span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">)</span><span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">;</span><br />
<br />
<span style="background-color: white; color: #3f7f5f; font-family: monospace; white-space: nowrap;">relative 相對路徑</span><br />
ex .XXClass<span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">.</span><span style="background-color: white; color: #7f0055; font-family: monospace; white-space: nowrap;"><b>class</b></span><span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">.getResource</span><span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">(</span><span style="background-color: white; color: #2a00ff; font-family: monospace; white-space: nowrap;">"fileName.txt"</span><span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">)</span><span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">;</span><br />
ex. XXClass<span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">.</span><span style="background-color: white; color: #7f0055; font-family: monospace; white-space: nowrap;"><b>class</b></span><span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">.getResource</span><span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">(</span><span style="background-color: white; color: #2a00ff; font-family: monospace; white-space: nowrap;">"myConfig/fileName.txt"</span><span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">)</span><span style="background-color: white; color: black; font-family: monospace; white-space: nowrap;">;</span><br />
<span style="background-color: white; color: #3f7f5f; font-family: monospace; white-space: nowrap;"><br /></span>
<br />
參考:<br />
http://www.java2s.com/Code/JavaAPI/java.lang/ClassgetResourceStringnamerelativetotheclasslocation.htmCchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-52149320495815180982014-10-15T10:13:00.003+08:002014-10-15T10:13:51.291+08:00心得 java.net.MalformedURLException: unknown protocol: rsrc 解決方式出現狀況: 是在client 端測試 JMS 訂閱時發生,<br />
原因:是 使用 eclipse 編譯出可執行 jar ,<br />
解決方式: 直接使用 java compiler 編譯執行就可以~<br /><br />參考: <a href="https://community.oracle.com/thread/1178215?start=0">RMI - unknown protocol: rsrc</a> <br />
Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-79618289224809704612014-08-14T19:10:00.001+08:002014-08-14T19:10:24.579+08:00心得 JSP 產生 XML 會空白幾行算是困擾蠻久的問題,沒想到很好解<div>
<br /></div>
<div>
只要改一下習慣就好, 讓 jsp include 標籤 連在一起就好</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<pre style="font-family: Courier, monospace; font-size: 14px;"><% .....
%><% .....
%><% .....
%><xml>
.....
</xml></pre>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
參考 : <a href="http://www.javaworld.com.tw/jute/post/view?bid=6&id=233224">如何解决jsp<%%>带来的空行问题, Java World</a> </div>
<div>
<br /></div>
Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-88920017344847079292014-05-17T14:58:00.000+08:002015-08-12T17:44:42.828+08:00How to Set porxy, port in java access HTTPS webservice主要遇到一個問題 就是 在公司內部AP 要使用 proxy 連結 HTTPS 的 網路服務 ,<br />
<br />
<br />
之前 寫過記下的 How to Set porxy, port in java , 的方法就無法使用了,<br />
<br />
不過只要修改一下就可以了 <br />
<br />
<br />
<code>
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.setProperty("https.proxyHost","proxy.XXX.com.tw");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.setProperty("https.proxyPort","8080"); <br />
</code>
<br />
<br />
<br />
<br />
參考: <a href="http://stackoverflow.com/questions/15927079/how-to-use-httpsurlconnection-through-proxy-by-setproperty">How to use HttpsURLConnection through proxy by setProperty? , stackoverflow</a>Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-3298273936938441512013-12-18T10:23:00.002+08:002013-12-18T10:23:24.067+08:00心得 取得TOMCAT 路徑 可利用 下列語法取得Tomcat 執行路徑, catalina.base<br />
<br />
File catalinaBase = new File( System.getProperty( "catalina.base" ) ).getAbsoluteFile(); // get tomcat root<br />
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
可參考 自行 Google catalina.base</div>
<div>
<br /></div>
<div>
<br /></div>
Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-35772616517564829732013-11-06T18:16:00.000+08:002013-11-06T18:16:12.649+08:00jquery AJAX 更新 心得<br />
jquery AJAX 可能是會因為 cache 的關係 導致沒有更新,<br />
加上這行可以確保有執行<br />
<br />
<pre class="alt" style="background-color: #f0f0f0; font-family: 'Courier New'; font-size: 12px; line-height: 17px; padding: 0px; width: 574.5625px;"><span class="rem" style="color: green; margin: 0px; padding: 0px;">$.ajaxSetup({ cache: false });</span></pre>
<br />
參考:<br />
<a href="http://blog.darkthread.net/post-2009-06-03-about-jquery-ajax-cache-option.aspx">黑暗執行序 ,關於jQuery AJAX cache參數</a>Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-57354999632142284022013-11-06T18:13:00.001+08:002013-11-06T18:13:12.564+08:00jqgrid AJAX使用心得套用 AJAX 定時更新資料時 發現 jqgrid 的 table 不會變動,<br />
<br />
原來需要再增加一行 code 才能讓他更新成功<br />
<br />
<pre class="default prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 18px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">$</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">"#XXX"</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">).</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">GridUnload</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">();</span></code></pre>
<br />
參考:<br />
<a href="http://stackoverflow.com/questions/4497130/jqgrid-refresh-a-grid-after-an-ajax-file-upload">http://stackoverflow.com/questions/4497130/jqgrid-refresh-a-grid-after-an-ajax-file-upload</a><br />
<br />
<br />
<br />Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-55839353843712990872013-07-18T14:02:00.003+08:002013-07-18T14:02:41.098+08:00心得 windows 建立服務工具 ServiceEx ServiceEx 可以讓 exe 轉換成 windows 服務<br />
<br />
使用方法如下:<br />
<br />
1. 下載 ServiceEx.exe<br />
<br />
2. 建立 檔案的 ini 如<b><span style="color: #cc0000;"> mem.ini</span></b> , 下面以執行 memcached.exe 為例<br />
<br />
[ServiceEx]<br />
; ServiceExeFullPath EXE 路徑<br />
ServiceExeFullPath = "D:\msample\memcached.exe"<br />
; program arguments to be sent to executable ,選項設定 如這裡 設 10M item size , 128 m 的空間<br />
options = "-m 128 -I 10m"<br />
; can program interact with desktop [true | false] (default: true) ,是否會影響桌面,這我就不太了解<br />
desktop = false<br />
; start type (valid values: Auto Manual Disabled) (default: auto) 啟動類型<br />
Start=Auto<br />
; start the service upon installation [true | false] (default: no) 安裝後是否啟動 <br />
StartNow=false<br />
<br />
3. 在 cmd 下 執行<br />
<pre style="white-space: pre-wrap; word-wrap: break-word;">ServiceEx install <servicename></servicename></pre>
<pre style="white-space: pre-wrap; word-wrap: break-word;">
</pre>
<pre style="white-space: pre-wrap; word-wrap: break-word;">如 </pre>
<pre style="white-space: pre-wrap; word-wrap: break-word;">ServiceEx install <b><span style="color: #cc0000;">mem</span></b></pre>
<br />
<br />
4. 在 windows 下 找到 服務 ,系統管理工具/服務 確認 服務msm 是否在清單上<br />
<br />
<span style="font-family: verdana, arial; font-size: 16px;">參考:</span><br />
<span style="font-family: verdana, arial; font-size: 16px;">[1] </span><a href="http://serviceex.com/">http://serviceex.com/</a>Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-75696474636619798092013-07-18T13:45:00.003+08:002013-07-18T13:45:26.922+08:00心得- Memcached 儲存 1M 空間限制<br />
<ul>
<li>memached 限制每筆資料設定在 1M 大小, 但 1.4.2版之後 多了一個參數可以設定 到 1k 到 128M [1] </li>
</ul>
<br />
如<br />
memcached -I 10m<br />
<br />
<br />
<br />
<ul>
<li>在 window 安裝方面 可以參考下載 [2] 所提供包好的 windows exe , </li>
</ul>
<br />
<br />
不過要使用 <strong style="background-color: white; border: 0px; font-family: Verdana, Arial, sans-serif; font-size: 12px; line-height: 18.46875px; margin: 0px; padding: 0px;"><span style="color: #3d85c6;">Memcached 1.4.5</span> </strong>這個版本, 以我的經驗使用 1.4.4 版的 超過 1M 的資料儲存 服務就會終止<br />
<br />
<br />
<br />
<ul>
<li>但是 1.4.5 版 有一個問題就是不能 用 sc create 的方式建立服務,</li>
</ul>
<br />
<br />
不過還好有找到 工具 <span style="font-family: verdana, arial; font-size: 16px;"><b><span style="color: red;">ServiceEx</span></b></span><span style="font-family: verdana, arial; font-size: 16px;"><b><span style="color: red;"> </span></b>可以解決這個問題</span><br />
<br />
<br />
<br />
<br />
<ul>
<li> 此外 API 也要做設定</li>
</ul>
<br />
<br />
這裡我採用 xmemcached [3] , 在程式裡加上敘述<br />
<br />
<br />
xmemcached MemcachedClient client=new XMemcachedClient("127.0.0.1",11211);<br />
client.setTranscoder(new SerializingTranscoder(<span style="color: red;">10</span>*1024*1024)); // 10M 看大小多少這裡就要設多少<br />
<br />
<br />
<br />
<br />
參考:<br />
[1] <a href="https://code.google.com/p/memcached/wiki/ReleaseNotes142">https://code.google.com/p/memcached/wiki/ReleaseNotes142</a><br />
[2] <a href="http://blog.elijaa.org/index.php?post/2010/10/15/Memcached-for-Windows&similar">http://blog.elijaa.org/index.php?post/2010/10/15/Memcached-for-Windows&similar</a><br />
[3] <a href="https://code.google.com/p/xmemcached/">https://code.google.com/p/xmemcached/</a><br />
<br />
<br />Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-55808325994983970862013-07-17T16:25:00.000+08:002013-07-17T16:25:19.847+08:00心得 jquery 同步預設都是 非同步的,但是可以設定為同步<br />
<br />
async 屬性 設為 true 即可以<br />
<br />
如下面的程式<br />
<br />
<br />
$.ajax({<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>url:<span class="Apple-tab-span" style="white-space: pre;"> </span>"xxx.jsp",<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> async: false ,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> success: function(data){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>alert(data);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>});<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<br />
<br />
<br />
參考 : <a href="http://api.jquery.com/jQuery.ajax/">http://api.jquery.com/jQuery.ajax/</a>Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-3235203594565945442013-07-10T11:40:00.000+08:002013-07-10T11:40:02.213+08:00筆記 jsp 多國語言 使用 ResourceBundle <br />
出現錯誤 : <span style="background-color: #f7f7f7; color: #0000a0; font-family: Tahoma, Georgia; font-size: 12px;">org.apache.jasper.JasperException: Can't find bundle for base name XXX </span><span style="background-color: #f7f7f7; color: #0000a0; font-family: Tahoma, Georgia; font-size: 12px;">, locale </span><span style="background-color: #f7f7f7; color: #0000a0; font-family: Tahoma, Georgia; font-size: 12px;">XX_XX</span><br />
<br />
解決方式<br />
<br />
吧資源檔 xxx.properties 放到<br />
<br />
<span style="color: #e69138;">WEB-INF/classes </span> 下
<br />
<br />
<br />
參考 :<a href="http://www.javaworld.com.tw/jute/post/view?bid=6&id=24795&sty=1&tpg=5&age=-1"> 在 JSP 中使用 ResourceBundle , JAVA world 文章</a>Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-43922320696090038372013-06-09T22:55:00.004+08:002013-06-09T22:57:12.982+08:00Android 心得 - 隱藏 action bar 標題列似乎 在 3.0 以後的 API 都會預設 action bar 在上 面, 若要隱藏 的 話 <br />
<br />
可使用下面語法<br />
<br />
在 AndroidManifest.xml<br />
想要隱藏的 activity 中 設定這個style<br />
<br />
<br />
<pre class="prettyprint"><span class="tag"><activity span=""><span class="pln"> </span><span class="atn">android:theme</span><span class="pun">=</span><span class="atv">"@android:style/Theme.Holo.NoActionBar"</span><span class="tag">></span></activity></span></pre>
參考:
<a href="http://docs.huihoo.com/android/3.0/guide/topics/ui/actionbar.html">Using the Action Bar , android api</a>
Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-45146010181094939902013-06-02T10:21:00.002+08:002013-06-02T10:22:50.466+08:00Android 心得 - 開發解析度<br />
<br />
依據現再平台的不同分為四個尺寸<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjpQBWo6fim7la6n9KyUuULIqwYYu3zqhL061j2fkI0asSVU-h_qSLBjvbFlakIvPx934y6wbf7zYkFxPvGpX2dM1Yn9B66DZnPyy4bOK4rRSWVYKhTtX4vq_fMyqiVA6JvVaJpsoHyeU/s1600/screens-ranges.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="196" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjpQBWo6fim7la6n9KyUuULIqwYYu3zqhL061j2fkI0asSVU-h_qSLBjvbFlakIvPx934y6wbf7zYkFxPvGpX2dM1Yn9B66DZnPyy4bOK4rRSWVYKhTtX4vq_fMyqiVA6JvVaJpsoHyeU/s640/screens-ranges.png" width="640" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
在4.1的開發平台下, res 檔下依據不同size 要放入對應大小的圖片尺寸, 其中 xxHdpi 是應該是更大尺寸的size <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimW-T0zvunWbdPAQI-ey1laxqVOVjcS7bSfhWQFA-a1MtBMc66cPcq66KwrJEbBO3Wgs2nHyyII8d19THBHZ4hJIA8BlpzJm9knrlL9EI7hP-x_KHVYhDoOAyRQcjQ0-t_l3akGq_T2BU/s1600/andIMG.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimW-T0zvunWbdPAQI-ey1laxqVOVjcS7bSfhWQFA-a1MtBMc66cPcq66KwrJEbBO3Wgs2nHyyII8d19THBHZ4hJIA8BlpzJm9knrlL9EI7hP-x_KHVYhDoOAyRQcjQ0-t_l3akGq_T2BU/s640/andIMG.png" width="640" /></a></div>
<br />
<br />
此外,要加入圖片的話, 就放在那些目錄下,如 drawable-mdpi, 在 Drable 下就可以選擇了<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnrkBY0rZ0FoGL1Npf1lAqUESidwuwFP72gi4y_uuPes_wCFJuTowIYtYj23dWqdrw27xNdYd4e1mchny3lwftiYqO5tWF_eIbdihtOL1nE4RbQilAYxqdLyJnYEFsm5pWcNc5qZqapyg/s1600/andIMG2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="352" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnrkBY0rZ0FoGL1Npf1lAqUESidwuwFP72gi4y_uuPes_wCFJuTowIYtYj23dWqdrw27xNdYd4e1mchny3lwftiYqO5tWF_eIbdihtOL1nE4RbQilAYxqdLyJnYEFsm5pWcNc5qZqapyg/s640/andIMG2.png" width="640" /></a></div>
<br />
<br />
<br />
參考:<br />
http://developer.android.com/guide/practices/screens_support.html<a href="http://developer.android.com/guide/practices/screens_support.html">http://developer.android.com/guide/practices/screens_support.html</a>Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-9018693909820236592013-06-02T10:03:00.002+08:002013-06-02T10:03:28.746+08:00Android 心得 - 開發憑證過期值得注意的地方, android 的開發憑證 debuge.keystore 只有一年的時間<br />
超過時會出現: <b><span style="color: red;">Error generating final archive, ... </span></b>的錯誤<br />
<br />
解決方式<br />
<br />
在eclipse 下<br />
Window --> Preferences --> Android --> Build<br />
可以找到該檔案,刪除掉剛檔案就會自動產生了,此外專案記得 clean 一下<br />
<br />
參考:<br />
<a href="http://www.dotblogs.com.tw/nethawk/archive/2011/06/20/29197.aspx">兩個開發Android時碰到的問題</a>Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-65176382005755467932013-06-02T09:51:00.001+08:002013-06-02T09:51:38.581+08:00Android 心得 - 安裝環境
發展的現在,android APP 的開發工具算是很方便的,
就官方網站的介紹有三種方式
1. 安裝ADT(Android Developer Tools), 將eclipse 和 android 相關套件打包好的,下載後解壓縮就可以執行,熟悉eclipse 的人倒是蠻方便的
2. 自行下載SDK 安裝到現有的 eclipse 上
3. Android Studio, 在IntelliJ IDEA IDE 平台上發展開發 andorid 的工具,沒用過
參考:
http://developer.android.com/sdk/index.htmlCchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-47918686964876311892013-05-15T18:56:00.001+08:002013-05-15T18:56:11.917+08:00心得 網路服務 at winserver2008簡短的新心得,在安裝好服務之後(如 tomcat , memched ,mysql 等等 會用到遠端連線的服務)
要使遠端的電腦能夠使用的話, 要記得設定防火牆的規則,當然用exe 安裝的話通常都會詢問防火牆開啟例外的訊息
不過用指令安裝的話 就必須設定了, ex 我是在使用 memched 的服務下遇到的Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-20904693924135000832013-04-26T18:09:00.003+08:002013-04-26T18:10:41.499+08:00心得- Memcached in java<h2>
簡介</h2>
摘要官方網站的介紹<br />
<br />
<div style="border: 0px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 9px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
<br /></div>
<div style="border: 0px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; line-height: 9px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
特色有</div>
<div style="border: 0px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; line-height: 9px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
</div>
<ul>
<li><span style="line-height: 9px;">免費</span></li>
<li><span style="line-height: 9px;">open source</span></li>
<li><span style="line-height: 9px;">高效率</span></li>
<li><span style="line-height: 9px;">分散式</span></li>
<li><span style="line-height: 9px;">使用記憶體儲存</span></li>
<li><span style="line-height: 9px;">以 key value 物件的方式存取資料</span></li>
<li><span style="line-height: 9px;">安全性較低,所以建議放在防火牆後面的機器</span></li>
</ul>
<br />
<div style="border: 0px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 9px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
<br /></div>
<h2>
Server 安裝</h2>
<div style="border: 0px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
</div>
<div style="border: 0px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
<span style="color: #333333; font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 11.666666030883789px; line-height: 8.997395515441895px;">原始Lib 並不支援windows 系統, 若是使用linux 等系統的話去官方網站下載就可以</span></span></div>
<div style="border: 0px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
<span style="color: #333333; font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 11.666666030883789px; line-height: 8.997395515441895px;">要額外安裝 </span></span><span style="color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 11.666666030883789px; line-height: 8.997395515441895px;">memcached<b> for win</b></span></div>
<div style="border: 0px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
我是<b><span style="color: #38761d;">參考 [2] </span></b>的步驟</div>
<div style="border: 0px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
</div>
<div style="border: 0px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
</div>
<ul>
<li>將jar 解壓縮到資料夾如D:\Appserv\memcached</li>
<li>配置服務</li>
<ul>
<li>D:\Appserv\memcached>sc create memcached binPath= "D:\Appserv\memcached\memcached.exe -p 9999 -l 127.0.0.1 -m 128 -d runservice" DisplayName= "memcached server" start= auto depend= TCPIP</li>
<li>其中 -p 9999 是指透過 port 9999 監聽請求 (預設為 11211 ) , -l 127.0.0.1 是指伺服器指定的 IP 位址 (預設為 INDRR_ANY) , -m 128 是指 memcached 最大可用的記憶體為 128 MB (預設 64 MB) ,最後 -d runservice 就是啟動為 Windows 服務。</li>
</ul>
<li>再去工作管理員開啟服務</li>
</ul>
<br />
<br />
<div style="border: 0px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
<br /></div>
<div style="border: 0px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
</div>
<h2>
重要議題</h2>
<div>
<b><span style="color: #6aa84f;">參考[3]</span></b> ,摘要幾個重點</div>
<div>
<br /></div>
<div>
<div>
撰寫使用 memcached 程式的基本模式就是,先查看有沒有 key-value,有就把快取資料讀出來,沒有就運算結果後存到 memcached sever。這部份算是簡單的。真正困難的事情有兩件:</div>
<div>
<ul>
<li>一是<span style="color: #134f5c;"><b>清除過期的快取資料</b></span>(expire)</li>
<li>二是<span style="color: #cc0000;">Key的命名</span></li>
</ul>
</div>
</div>
<div>
<div>
兩種方式<b><span style="color: #134f5c;">清除快取資料</span></b>:</div>
<div>
一是在新增/刪除資料時,順便刪掉這個快取 key-value,這樣下次 request 來時便會重新 快取。</div>
<div>
二是在有更新的時候直接重設快取資料(Reset)。要注意的是如果您有不同的程式會直接更新資料庫(也就是不只是透過主應用程式,還有別的背景程式),就會有可能 memcachd 裡面的資料沒有被更新到,</div>
<div>
解法有 </div>
<div>
1. 清空所有資料 </div>
<div>
2. 有一隻程式可以重建 memcached 裡面的資料</div>
<div>
3. 統一用一套知道 memcached 機制的介面操作</div>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<span style="color: #cc0000;">Key的命名</span></div>
<div>
為了 Security 避免被人猜到 Key 和避免超過 255 bytes 的 key 長度限制,建議你將 Key hash 過</div>
<div>
<br /></div>
<h2>
Client API </h2>
<div>
<br /></div>
<div>
我是使用 JAVA 的API Memcached-Java-Client</div>
<div>
<br /></div>
<br />
<div>
摘錄 <span style="color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 11.666666030883789px; line-height: 8.997395515441895px;">MemcachedBench.java 的說明 並加上註釋</span></div>
<div>
<span style="color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 11.666666030883789px; line-height: 8.997395515441895px;"><br /></span></div>
<div>
<span style="color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 11.666666030883789px; line-height: 8.997395515441895px;"><br /></span></div>
<br />
<code>
<span style="color: #38761d; font-family: monospace;">/**</span><br />
<span style="color: #38761d; font-family: monospace;"> * Copyright (c) 2008 Greg Whalin</span><br />
<span style="color: #38761d; font-family: monospace;"> * All rights reserved.</span><br />
<span style="color: #38761d; font-family: monospace;"> *</span><br />
<span style="color: #38761d; font-family: monospace;"> * This library is free software; you can redistribute it and/or</span><br />
<span style="color: #38761d; font-family: monospace;"> * modify it under the terms of the BSD license</span><br />
<span style="color: #38761d; font-family: monospace;"> *</span><br />
<span style="color: #38761d; font-family: monospace;"> * This library is distributed in the hope that it will be</span><br />
<span style="color: #38761d; font-family: monospace;"> * useful, but WITHOUT ANY WARRANTY; without even the implied</span><br />
<span style="color: #38761d; font-family: monospace;"> * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR</span><br />
<span style="color: #38761d; font-family: monospace;"> * PURPOSE.</span><br />
<span style="color: #38761d; font-family: monospace;"> *</span><br />
<span style="color: #38761d; font-family: monospace;"> * You should have received a copy of the BSD License along with this</span><br />
<span style="color: #38761d; font-family: monospace;"> * library.</span><br />
<span style="color: #38761d; font-family: monospace;"> *</span><br />
<span style="color: #38761d; font-family: monospace;"> * @author Greg Whalin <greg meetup.com=""> </greg></span><br />
<span style="color: #38761d; font-family: monospace;"> */</span><br />
<span style="font-family: monospace;">package com.meetup.memcached.test;</span><br />
<span style="font-family: monospace;"><br /></span>
<span style="font-family: monospace;">import cht.batchevent.show.EventList;</span><br />
<span style="font-family: monospace;"><br /></span>
<span style="font-family: monospace;">import com.meetup.memcached.*;</span><br />
<span style="font-family: monospace;">import java.util.*;</span><br />
<span style="font-family: monospace;">import org.apache.log4j.Level;</span><br />
<span style="font-family: monospace;">import org.apache.log4j.Logger;</span><br />
<span style="font-family: monospace;">import org.apache.log4j.BasicConfigurator;</span><br />
<span style="font-family: monospace;"><br /></span>
<span style="font-family: monospace;"><br /></span>
<span style="font-family: monospace;"><br /></span>
<span style="color: #38761d; font-family: monospace;">/*</span><br />
<span style="color: #38761d; font-family: monospace;"> * </span><br />
<span style="color: #38761d; font-family: monospace;"> * </span><br />
<span style="color: #38761d; font-family: monospace;"> * </span><br />
<span style="color: #38761d; font-family: monospace;"> */</span><br />
<span style="font-family: monospace;">public class MemcachedBench2 {</span><br />
<span style="font-family: monospace;"><br /></span>
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #38761d;">// logger</span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>private static Logger log =</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Logger.getLogger( MemcachedBench2.class.getName() );</span><br />
<span style="font-family: monospace;"><br /></span>
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public static void main(String[] args) {</span><br />
<span style="font-family: monospace;"><br /></span>
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>BasicConfigurator.configure();</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>org.apache.log4j.Logger.getRootLogger().setLevel( Level.OFF );</span><br />
<span style="font-family: monospace;"><br /></span>
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>int runs = Integer.parseInt(args[0]);</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>int start = Integer.parseInt(args[1]);</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: monospace;"> </span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #38761d;">//伺服器位址清單</span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>String[] serverlist = { "127.0.0.1:9999" };</span><br />
<span style="font-family: monospace;"><br /></span>
<span style="font-family: monospace;"><br /></span>
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #38761d;">// initialize the pool for memcache servers</span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>SockIOPool pool = SockIOPool.getInstance( "test" );</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>pool.setServers(serverlist);</span><br />
<span style="font-family: monospace;"><br /></span>
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>pool.setInitConn( 100 );</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>pool.setMinConn( 100 );</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>pool.setMaxConn( 500 );</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>pool.setMaintSleep( 20 );</span><br />
<span style="font-family: monospace;"><br /></span>
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>pool.setNagle( false );</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>pool.initialize();</span><br />
<span style="font-family: monospace;"><br /></span>
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: monospace;"> </span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #38761d;">// get client instance</span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>MemcachedClient mc = new MemcachedClient( "test" ); // 要和pool 的名稱一樣</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>mc.setCompressEnable( false );</span><br />
<span style="font-family: monospace;"><br /></span>
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>String keyBase = "testKey";</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: monospace;"> </span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #38761d;">//String object = "This is a test of an object blah blah es, serialization does not seem to slow things down so much. The gzip compression is horrible horrible performance, so we only use it for very large objects. I have not done any heavy benchmarking recently";</span></span><br />
<span style="font-family: monospace;"><br /></span>
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>long begin = System.currentTimeMillis();<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>long end = System.currentTimeMillis();</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>long time = end - begin;</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: monospace;"> </span></span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: monospace;"> </span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>begin = System.currentTimeMillis();</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>for (int i = start; i < start+runs; i++) {</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>String str = (String) mc.get(keyBase + i);</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #38761d;">// 沒有資料時和資料庫要資料, 取得後放入 memcatch</span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if(str == null){<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(i+" is null ");</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>OBJ_obj = new OBJ();<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>StringBuffer _theobj = new StringBuffer();</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: monospace;">_theobj </span><span style="font-family: monospace;">= </span><span style="font-family: monospace;">_obj.getDataFromDB()</span><span style="font-family: monospace;">;</span><span class="Apple-tab-span" style="font-family: monospace; white-space: pre;"> </span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>String object =</span><span style="font-family: monospace;">_theobj</span><span style="font-family: monospace;"> </span><span style="font-family: monospace;">.toString();</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>mc.set(keyBase + i, object);<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(i+" : " + str);</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>end = System.currentTimeMillis();</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>time = end - begin;</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(runs + " gets: " + time + "ms");</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: monospace;"> </span></span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: monospace;"> </span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #38761d;">// 取得多筆</span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>String[] keys = new String[ runs ];</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>int j = 0;</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>for (int i = start; i < start+runs; i++) {</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>keys[ j ] = keyBase + i;</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>j++;</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>begin = System.currentTimeMillis();</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Map vals = mc.getMulti( keys );</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>end = System.currentTimeMillis();</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>time = end - begin;</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(runs + " getMulti: " + time + "ms");</span><br />
<span style="font-family: monospace;"><br /></span>
<span style="color: #38761d; font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>/*<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br />
<span style="color: #38761d; font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * //刪除的語法</span><br />
<span style="color: #38761d; font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * begin = System.currentTimeMillis();</span><br />
<span style="color: #38761d; font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>for (int i = start; i < start+runs; i++) {</span><br />
<span style="color: #38761d; font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>mc.delete( keyBase + i );</span><br />
<span style="color: #38761d; font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="color: #38761d; font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>end = System.currentTimeMillis();</span><br />
<span style="color: #38761d; font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>time = end - begin;</span><br />
<span style="color: #38761d; font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(runs + " deletes: " + time + "ms");*/</span><br />
<span style="font-family: monospace;"><br /></span>
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>SockIOPool.getInstance( "test" ).shutDown();</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: monospace;">}</span><br />
<br />
</code>
<div>
<span style="color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 11.666666030883789px; line-height: 8.997395515441895px;"><br /></span></div>
<div style="border: 0px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 9px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
<br /></div>
<div style="border: 0px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 9px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
參考:</div>
<div style="border: 0px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 9px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
[1] <a href="http://memcached.org/">官方網站</a></div>
<div style="border: 0px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 9px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
[2] <a href="http://www.jaceju.net/blog/archives/140/">在 Windows 上安裝 Memcached</a></div>
<div style="border: 0px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 9px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
[3] <a href="http://ihower.tw/blog/archives/1768">如何使用 memcached 做快取</a></div>
<div style="border: 0px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 9px; margin-bottom: 1.5em; padding: 0px; vertical-align: baseline;">
[4] <a href="https://github.com/gwhalin/Memcached-Java-Client">Memcached-Java-Client</a></div>
Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-32144102834325553062013-03-05T15:50:00.003+08:002013-03-05T15:50:40.212+08:00Hibernate心得2 in eclipse 資源檔位置一不小心 就配置錯誤 導致 org.apache.jasper.JasperException: /hibernate.cfg.xml not found<br />
<br />
在此紀錄一下位置<br />
<br />
<span style="background-color: white; color: #e78608; font-family: Tahoma; font-size: 12px; line-height: 18px;">------解决方法--------------------------------------------------------</span><br style="background-color: white; font-family: Tahoma; font-size: 12px; line-height: 18px;" /><span style="background-color: white; font-family: Tahoma; font-size: 12px; line-height: 18px;">没有hibernate.cfg.xml 写一个丢到classes下去 </span><br style="background-color: white; font-family: Tahoma; font-size: 12px; line-height: 18px;" /><span style="background-color: white; color: #e78608; font-family: Tahoma; font-size: 12px; line-height: 18px;">------解决方法--------------------------------------------------------</span><br style="background-color: white; font-family: Tahoma; font-size: 12px; line-height: 18px;" /><span style="background-color: white; font-family: Tahoma; font-size: 12px; line-height: 18px;">你用的hibernate.cfg.xml还是hibernate.properties </span><br style="background-color: white; font-family: Tahoma; font-size: 12px; line-height: 18px;" /><span style="background-color: white; color: #e78608; font-family: Tahoma; font-size: 12px; line-height: 18px;">------解决方法--------------------------------------------------------</span><br style="background-color: white; font-family: Tahoma; font-size: 12px; line-height: 18px;" /><span style="background-color: white; font-family: Tahoma; font-size: 12px; line-height: 18px;">没有hibernate.cfg.xml</span><br />
<br />
<br />
=====================================<br />
<br />
以下是我在 eclipse 放的成功 位置<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUYAT4SV6L6czLB-GuXR0sPxw227cxbn2fUGEpz_rswW6L7Yv5m0mS5e-81FLKGpIkRTSioXo1nG1G0QFsclj7fIMvi0DC7-su3KS6JhAC3kea4HbckvPcyaBGgPNVeMlHmVcvIVl77-8/s1600/hibernate_eclipse1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUYAT4SV6L6czLB-GuXR0sPxw227cxbn2fUGEpz_rswW6L7Yv5m0mS5e-81FLKGpIkRTSioXo1nG1G0QFsclj7fIMvi0DC7-su3KS6JhAC3kea4HbckvPcyaBGgPNVeMlHmVcvIVl77-8/s1600/hibernate_eclipse1.jpg" height="440" width="640" /></a></div>
<br />
<br />
<br />
實際部屬在Tomcat的路徑<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjodOn_k8DwDaK6qOv0nG7qLTehCBzk0brq-Fen2nnLHTpIwil8KH6Gs4gzL_CHyb1ZijkDJ0kHGUNN35McYrxORjv8zuMc4b7j1pcaqi5ENX_440x77cCit-FEVuRfOX96Zj8X7EWz734/s1600/hibernate_eclipse2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjodOn_k8DwDaK6qOv0nG7qLTehCBzk0brq-Fen2nnLHTpIwil8KH6Gs4gzL_CHyb1ZijkDJ0kHGUNN35McYrxORjv8zuMc4b7j1pcaqi5ENX_440x77cCit-FEVuRfOX96Zj8X7EWz734/s1600/hibernate_eclipse2.jpg" height="512" width="640" /></a><br />
<br />
<br />
參考來源 : <a href="http://www.myexception.cn/java%20exception/264.html">http://www.myexception.cn/java%20exception/264.html</a><br />
<br />Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-16892390805885833322013-03-01T17:30:00.001+08:002013-03-01T17:30:31.502+08:00Hibernate心得前幾天上了一下 Hibernate 的課程,在此作一個摘要,<br />
<br />
<br />
<ul>
<li>簡單的說 Hibernate 有一個好處可以當個接口,讓資料庫找到的資料直接轉成定義好得物件。</li>
<li>而資料庫的連結定義,試用組態的XML來定義的,要抽換更改比較有彈性</li>
<li>除了可以使用HQL的方式查詢,也可以利用 criteria 查詢, criteria 簡單的說定一種查詢的function 而不需使用SQL 類似的查詢語句 </li>
</ul>
<br />
<br />
<br />
<br />
Hibernate 網站 (<a href="http://www.hibernate.org/">http://www.hibernate.org/</a>)Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-6642663587987972062013-01-08T17:47:00.005+08:002013-01-08T17:47:48.733+08:00Lambda 語法根據MSDN 的定義如下[1]:<br />
<br />
<div style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; padding-bottom: 15px;">
<span class="sentence" data-guid="883014533071beefc1784d8bf9feffac" data-source="A lambda expression is an anonymous function that you can use to create delegates or expression tree types." id="mt1" xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">Lambda 運算式是可用來建立委派或運算式樹狀架構型別的匿名函式。</sentencetext> </span><span class="sentence SentenceHover" data-guid="ea26fde047b6ec9aa4fd9cdc56502191" data-source="By using lambda expressions, you can write local functions that can be passed as arguments or returned as the value of function calls." id="mt2" style="background-color: #ffffe1;" xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">使用 Lambda 運算式,您可以撰寫可當做引數或傳回做為函式呼叫之值的區域函式。</sentencetext></span> <span class="sentence" data-guid="e19a5962215ea73e69128a79661be6f6" data-source="Lambda expressions are particularly helpful for writing LINQ query expressions." id="mt3" xml:space="preserve">Lambda 運算式為撰寫 LINQ 查詢運算式中特別有用。</span></div>
<div>
<span class="sentence" data-guid="e19a5962215ea73e69128a79661be6f6" data-source="Lambda expressions are particularly helpful for writing LINQ query expressions." xml:space="preserve"><br /></span></div>
<div>
不過看了半天還是沒有感覺,想不到Python[2]的寫法反而比較好理解</div>
<div>
<span class="sentence" data-guid="e19a5962215ea73e69128a79661be6f6" data-source="Lambda expressions are particularly helpful for writing LINQ query expressions." xml:space="preserve"><br /></span></div>
<div>
<span class="sentence" data-guid="e19a5962215ea73e69128a79661be6f6" data-source="Lambda expressions are particularly helpful for writing LINQ query expressions." xml:space="preserve">其他針對不同語言也有人系新的整理[3], javascript 也蠻好讀,不過JAVA 的寫法真是好神奇</span><br />
<span class="sentence" data-guid="e19a5962215ea73e69128a79661be6f6" data-source="Lambda expressions are particularly helpful for writing LINQ query expressions." xml:space="preserve"><br /></span></div>
<div>
<span class="sentence" data-guid="e19a5962215ea73e69128a79661be6f6" data-source="Lambda expressions are particularly helpful for writing LINQ query expressions." xml:space="preserve"><br /></span></div>
<div>
<span class="sentence" data-guid="e19a5962215ea73e69128a79661be6f6" data-source="Lambda expressions are particularly helpful for writing LINQ query expressions." xml:space="preserve">參考:</span></div>
<div>
[1] MSDN , Ladbda(<a href="http://msdn.microsoft.com/zh-tw/library/bb397687.aspx">http://msdn.microsoft.com/zh-tw/library/bb397687.aspx</a>)</div>
<div>
[2] Falldog的程式戰場 , <a href="http://falldog7.blogspot.tw/2009/07/python-lambda.html">[Python] lambda簡介</a><br />
[3] 石頭閒語,<a href="http://blog.roodo.com/rocksaying/archives/12742243.html">透過 JavaScript,Ruby,PHP,C# 語言,理解 Java 的 Lambda 語法</a></div>
Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-61955671538007953902013-01-08T14:38:00.003+08:002013-01-08T14:38:34.017+08:00專貼 javascript 字串比對 由於最近有使用到 判斷字串中是否有特定文字的機制,所以紀錄一下。<br />
<br />
比如說, 有一串字" 這是測試機", 我想要判斷 是否有包含'測試' 這兩個字,在javascript 可以使用<br />
<br />
<span style="background-color: #ffd966;">String.search</span> , 若有的話 則會回傳 出現在第幾個位置,沒有的話則回傳-1<br />
<br />
當然 其他 <span style="background-color: #d9ead3;">String.indexof</span>, <span style="background-color: #d9ead3;">String.match </span>等也可以達到相同的效果<br />
<br />
<br />
<br />
或可以參考:<br />
<br />
<a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/search">https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/search</a><br />
<br />Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-21068545482244178962012-11-27T17:47:00.001+08:002012-11-27T17:54:16.538+08:00javascript 心得 regexp replace在範例中是將英文字母由小寫轉換成大寫<br />
<br />
我這裡應用是將數字不分加上標籤好套用CSS<br />
<br />
<br />
code 如下<br />
<br />
<br />
<code>
function change(text){
return "<a class='thenumber'>"+text+"</a>"; <br />
} <br />
// 強調數字部份
function ModifyStyleSubDescription(str){ <br />
//var str= "11ABC 22 DEF"; <br />
//match number in range 0-999 <br />
var _result = ""; <br />
var reg = /(\d+)/g; // 使用g 才抓的到第二組 <br />
_result = str.replace(reg,change); <br />
return _result; <br />
}
</code>
<br />
<br />
原本使用的函式,但IE8不支援....
<br />
<code>
// 強調數字部份
function ModifyStyleSubDescription(str){<br />
var _result = "";<br />
var reg = /(\d+)/; <br />
var parts = str.split(reg); <br />
for (var i = 0 ; i < parts.length ; i ++){ <br />
if(parts[i].match(reg)){<br />
_result +="<a class='thenumber'>"+parts[i]+"</a>"<br />
}else{<br />
_result +=parts[i];<br />
} <br />
} <br />
return _result;<br />
}<br />
</code>
<br />
參考:W3Cschool , <a href="http://www.w3school.com.cn/js/jsref_replace.asp">http://www.w3school.com.cn/js/jsref_replace.asp</a><br />
<br />
<br />Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0tag:blogger.com,1999:blog-1444155547342700308.post-36392911907285513122012-11-14T14:02:00.000+08:002012-11-14T14:02:05.429+08:00轉貼 java ssh jar<br />
當使用者要透過遠端SSH連接遠端機器時,若使用JAVA 的話 ,可以透過 JSch.jar 提供的API 來達成目的。<br />
<br />
實際參考的範例,可以參考[2], 或查詢 "java sftp example jsch"<br />
<br />
<br />
<br />
<br />
<br />
<br />
參考 :<br />
<br />
[1] JSch, <a href="http://www.jcraft.com/jsch/">http://www.jcraft.com/jsch/ </a><br />
[2] Java 實現SFTP實例,<span style="background-color: white; font-family: Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 25.200000762939453px;"><a href="http://www.xfok.net/2009/10/124485.html">http://www.xfok.net/2009/10/124485.html</a></span>Cchttp://www.blogger.com/profile/03754456132610972097noreply@blogger.com0