橫幅廣告

2024年4月12日 星期五

[Solved] PM2: Current process list is not synchronized with saved list

I am using AWS EC2 and runing ubuntu.

I encountered a problem where pm2 showed: 'Current process list is not synchronized with the saved list. App XXX differs. Type 'pm2 save' to synchronize.

*the XXX is my app name.


In cmd, I inputted:

"sudo env PATH=$PATH:/usr/bin pm2 startup systemd -u ubuntu --hp /home/ubuntu"

then, "pm2 save" again.

"sudo reboot"


All apps in pm2 startup automatically.



Maybe "pm2 startup -u ubuntu" also works too.


2020年6月28日 星期日

could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED

https://blog.csdn.net/ghy_111/article/details/86672450


依照上面這一篇文章終於解決了

OS: Ubuntu 18.04
Keras: 2.2.5
tensorflow-gpu: 1.14.0
Graphic card: RTX 2070 SUPER and GP710 (for display out)

我的狀況:
我可以通過cudnn_samples_v7的mnistCUDNN測試,但是在python運行keras就會出現問題


想不到在Windows幾乎無痛安裝..在linux下我搞了好久,要不是Windows 10有WDDM 2.0的問題(VRAM被保留20%),我應該不會把環境換到Linux...對我而言安裝好之後Linux很穩定,但是在安裝過程中鬼問題很多,鬼問題並不是指不熟悉指令所產生的問題,而是產生很多例外的特殊狀況,導致我必須一直上網看人家的討論,而且似乎沒有完美解,必須要一個一個試到可以 :(

我只想把精力放在Deep Learning研究上阿...


keras框架(Tensorflow backend) 設置GPU按需分配:

import tensorflow as tf
from keras import backend as K
config = tf.ConfigProto()
config.gpu_options.allow_growth=True
sess = tf.Session(config=config)
K.set_session(sess)
 
不曉得這個問題是否是TF專有,說不定換到pytorch就沒問題了?

2019年11月5日 星期二

舌套: 近一個月心得

話說在購買舌套之前我真的蠻猶豫的

一,價差很大
二,網路上心得很少(中文部分,後來我才發現去英文去找相較之下比較多資訊)
三,完全不知道會不會又是一個垃圾

我個人很在意睡眠問題,從環境、溫度、睡眠床墊材質、睡姿巴拉巴拉都有在自我實驗看看是否能改進睡眠品質。

我側睡習慣已經好幾年了,因為躺著睡會打呼很大聲,自己也容易睡不好..半夜常常醒來換邊睡,對我而言,一個晚上醒來四、五次翻身後馬上睡著是正常現象。

最近發現晚上回到家都蠻累的,心想這樣下去不是辦法,我的睡眠品質大有問題,後來狠下心買舌套來試試看(我買一千多...我也不知道三百的是不是跟一千多的用起來一樣)。

我決定買舌套的原因是因為,我坐姿,將自己身體、脖子、舌頭放鬆的狀況下,用胸部呼吸就可以發出很大聲的打呼聲(用腹式呼吸就不會,不曉得是不是壓力的關係???),通常睡著之後,我呼吸會自己變成胸部呼吸。我自己認為這樣可能跟舌根往後掉或是舌根肥大壓迫到呼吸道有關係,所以我才購買舌套試試看。

以下進入心得:

開始用舌套的第一天晚上,我側睡發現口水會流出來,後來改躺著睡,睡到半夜,舌頭痛到不行,後來把舌套拔掉。

第二天早上,醒來覺得舌頭麻麻痛痛(輕微)
第二天晚上,我繼續使用舌套,我記憶中我好像一覺到天亮,早上醒來舌頭前段部分沒有知覺,舌套拔下來後過一下子開始恢復知覺,接下來整天麻麻痛痛的。

第三天晚上,也是戴到早上,但是早上醒來舌頭麻掉恢復知覺之後,覺得比昨天更麻更痛了。

第四天放棄使用,因為太痛了,且我自己覺得好像沒改善太多。

第五天應該也是放棄。

舌頭恢復之後,過幾天之後又開始嘗試使用,太太說我晚上睡覺都沒打呼的聲音。

但是因為舌頭早上醒來都有痛,所以這幾天來我都是使用斷斷續續的,等舌頭比較不痛才會戴。

大概兩、三周後,我發現好像早上起來比較舌頭麻痺的感覺比較沒那麼嚴重了,比較快恢復知覺,恢復之後,也比較不會麻跟痛整天。

到了最近幾天,我把睡覺習慣改回躺姿睡眠,先前我已經習慣側睡入睡了,突然改回來其實有點難睡,可能側睡睡姿對我而言是進入睡眠的一種儀式。後來我發現,用舌套+躺睡睡眠品質大大提升,我想主要是因為半夜沒醒來換睡姿的問題,以及口水不會因為使用舌套的關係流出來,導致我醒來。

使用舌套習慣之後,有幾個優點,

  1. 我睡面不會打呼
  2. 躺著睡不會呼吸困難醒來 (就是一種被堵住一下下,在淺眠的時候醒來)
  3. 因為改用躺睡,半夜不會有側睡的手麻、翻身問題
  4. 大概睡七個小時,精神飽滿 (我之前睡八個多小時,還是累累,不過這部分有點複雜,打呼跟我睡眠的環境都有問題,之前用天然乳膠墊對我而言會太熱)。
  5. 可以玩的時間變多了(?
  6. 精神便比較好,比較有活力去做事情
使用舌套的要點:
  1. 千萬不要拼命把舌套用真空,這樣吸力過大會很不舒服,舌頭會很痛
  2. 舌頭放進去,有吸住就好了 (我後來在amazon看到人家留言講到我才知道之前吸太緊)
  3. 盡量用躺睡,不然口水會流出來
  4. 早上醒來要拔下來的時候,不要直接硬拔,這樣舌頭會很痛
另外,我覺得...搭配鼻腔擴張器好像不錯,我自己是用Mack's Airmax,個人覺得,我幾天比較下來,有使用的話,睡眠品質【似乎】會再好一點點點點。


2018年2月2日 星期五

[QNAP] Let’s Encrypt 使用Certbot手動申請SSL Certificate

Let’s Encrypt 最近又改版了,之前的教學文章似乎已經不能使用,昨天自己摸了一下新版的Certbot認證方式,因此把方式貼上來,免得之後自己忘記,結果又要重新探索一次。

我這邊採用的是手動認證,並且在A主機上幫目標B進行認證。


我的環境是QNAP NAS上的Apache要使用HTTPS,我簡單測試一下,似乎無法直接跑Certbot,後來想想,怕NAS版本異動以後Certbot的設定就被洗掉,因此決定改採用手動認證,這樣比較麻煩,但是我確定可以解決我的問題。
*這邊還是建議如果你的環境可以auto renew的話,就不要採用我這篇的教學。

首先我先安裝一台Ubuntu在VirtualBOX上。接著在裡面安裝Certbox,步驟如下:
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot 

接著準備開始手動認證:

sudo certbot certonly --manual --preferred-challenges http
記憶中第一次會請你輸入Email ,請依照指示填寫即可,接著會輸入domain name,我這邊是連host都輸入,Certbot的範例似乎可以使用整個Domain認證(?):

接著會問你,你的IP會被拿來申請Certificate,如果你執行在手動模式(這個電腦不是你的目標伺服器),請確定這樣你OK,這邊請輸入Y(其實我不知道輸入N會怎麼樣)

接下來系統會產生認證序號,如下方圖片,請手動建立一個檔案,檔名為「p-LksOHJyo1P4dTOMmC5MkrkuNfr5UEYq9gODfKmL6s」,內容為「p-LksOHJyo1P4dTOMmC5MkrkuNfr5UEYq9gODfKmL6s.ljQb7kSPkdlQe2kscmVJXcCj7aL2CV27Y6oLTRGrlak」,這邊你必須依照實際狀況去產生。
接著把檔案上傳到你的網頁伺服器,放到以網頁伺服器根目錄出發「.well-known/acme-challenge/」裡面,一定要確保底下網址點下去是有東西的。完成後按ENTER。

完成後結果如下


接著進入/etc/letsencrypt/live/裡面就可以看到認證的網域資料夾,再進去就會看到認證檔案,
如果你跟我一樣是QNAP主機的話,進入「控制台->安全設定->安全憑證&私人金鑰」,憑證欄位貼入cert.pem檔案的內容,私人金鑰欄位貼入privkey.pem檔案內容既可。


這邊要注意一下,我有發生更新憑證之後,WEB的HTTPS PORT被改掉,並且虛擬伺服器也被停止啟用的狀況,建議大家要多檢查一下。

2018年1月30日 星期二

Windows Server 2016 & SQL Server 2017 使用IIS架網站授權費用(牌價)

今天親自打電話給微軟客服詢問授權

我們的CASE是要在Windows Server上執行IIS服務,無限制瀏覽使用者,公司內部、一般使用者皆可瀏覽;有會員系統,會員系統的認證是在網頁內進行,無須透過外部系統認證。

經詢問之後,客服表示我們必須買足CAL (Client Access License) 數量(公司人數)以及External Connector (EC)授權

與底下連結文章的說法不同,目前客服是說微軟2015有新規定,而底下文章發表日期是2014。
https://blogs.technet.microsoft.com/volume-licensing/2014/03/10/licensing-how-to-when-do-i-need-a-client-access-license-cal/

公司若有兩套Windows Server,不需要重複購買CAL,以及,SQL Server的CAL與Windows Server的CAL不同,SQL Server的貴多了。

如果網站後台是使用SQL Server,則SQL Server也須購買同等人數CAL,或者改採用CPU授權模式。

如果公司人數50人,Windows Server 2016盒裝近5萬塊,
Windows Server CAL牌價1380,1380*50 = 69,000
EC牌價約70,000

則Windows Server 2016架網站需要  50000+69000+70000 = 189,000
如果後端要用SQL Server 2017,採用CPU計價(CAL不划算),牌價約217,240 (至少要購買2 Cores)

因此總價約406,240元(這是牌價)

真不是小公司能玩的....

2017年9月28日 星期四

為文字上Highlight,但是排除HTML Tag內容,並且保持文字大小寫


(?!<[^>]*?)"+Pattern.quote(search)+"(?![^<]*?>)


text = text.replaceAll("(?!<[^>]*?)("+Pattern.quote(search)+")(?![^<]*?>)", "<span style='display:inline; background-color: yellow;'>$1</span>");

2017年3月7日 星期二

[心得] 台灣大哥大 網路漫遊預付卡 日本北海道4G無線上網吃到飽 (有網路測試圖)

我與老婆基本上都算得上重度上網族群,為了今年二月能夠跟老婆有一個高品質的北海道蜜月之旅,上網研究了很久的網路漫遊,大致上比較了幾家的優缺點,最後我們選擇了台灣大哥大網路漫遊預付卡,最後也證明了我們的選擇沒錯! 希望PO出來能夠對大家有一點幫助。

2015年4月8日 星期三

Let your PHP calls JAR of JAVA (Windows)

Set the identity of executor for Apache

Before run your php program.

You have to set the identity of executor for Apache.


  1. Go to "Service"

  2. Change the executor (use your log-in account)


Write a toy program

// Set Enviromental Variable
$JAVA_HOME = "C:\\\"Program Files\"\\Java\\\"jre1.8.0_20";
$PATH = "C:\\\"Program Files\"\\Java\\\"jre1.8.0_20\"\\bin";
putenv("JAVA_HOME=$JAVA_HOME");
putenv("PATH=$PATH");

//run your jar program
echo shell_exec("java.exe -version 2>x.txt");


Finally, execute PHP program

2014年4月7日 星期一

MySQL利用console介面匯出/匯入資料

匯出:

可以利用mysqldump來達到匯出
mysqldump -u root -p 資料庫名稱 資料表名稱 < 要存成的檔案名稱 (xx.sql)
如果是遠端的資料庫,可以加"-h IP位置"

如果遇到command denied.....when using LOCK TABLES,代表可能是因為權限不足(無法鎖定table)
可以在最後面再加上一個參數--skip-lock-tables或--skip-add-locks 
另外,可以使用 --default-character-set=UTF8 來指定編碼



匯入:
登入MySQL之後,選好資料庫(use 資料庫名稱;)
輸入source c:\xxx\ooo\xx.sql; 即可開始匯入

2013年11月19日 星期二

Don't assign an array type value to URLOPT_POSTFIELDS in curl

If you are not planing to upload a file, don't to assign an array type value to URLOPT_POSTFIELDS in curl.

Today, I got a problem about using curl to do a login action.
Something happened. The system didn't work because the first character in the password was a @ character.

See the reference: http://php.net/manual/en/function.curl-setopt.php , and please find the statement of CURLOPT_POSTFIELDS section.

You will find a statement as following:
If value is an array, the Content-Type header will be set to multipart/form-data. As of PHP 5.2.0, value must be an array if files are passed to this option with the @ prefix. As of PHP 5.5.0, the @ prefix is deprecated and files can be sent using CURLFile.

So, you/me should use String type rather than Array type assigning values to URLOPT_POSTFIELDS  if you aren't planing to upload a file.

The solution can be found in this web page: http://www.brandonchecketts.com/archives/array-versus-string-in-curlopt_postfields

Hope it also help you.

2013年10月6日 星期日

Buy a prepaid phone from SoftBank online shop


Finally, I got my phone and completed the setting.

Actually, I do not even speak Japanese.

In most situations, I used the google translator to translate SoftBank's web...


There are some conditions here for the people who would like to buy a prepaid phone.

If you would like to a prepaid phone in Japan, you have to satisfy some conditions as follows:

  1. You have your own resident card.
  2. The resident card have filled out your residence address.
  3. Find a SoftBank shop that sells prepaid phone and prepaid sim card OR buy them form SoftBank online shop. (
    1. If you want to only buy a prepaid sim card, you have already had a SoftBank Phone, which had not contracted currently.
    2. Most of the SoftBank shops do not sell the prepaid phone.
    3. Most of the SoftBank shops do not provide English service.
  4. If you are like me bought the phone from online shop, you have to carefully fill out your order information.
    1. Your residence address in the order have to identical to the address in your resident card. Any different is not allowed. If any different here, SoftBank will ask you to contact him by using a call for checking your information (some people told me they provided English in their toll-free number).
    2. You have to use a credit card for payment.
    3. You have also to upload or mail a copy of your resident card (two sides) and your passport.
  5. After you gotten your prepaid phone, you have to activate your prepaid sim card. Otherwise, the prepaid sim card will be out of service. 
    1. There is the address for activating prepaid sim card: http://online-shop.mb.softbank.jp/ols/html/manual/explanation/setting_pri.html.
    2. In the process, you have to fill out the application number, your email, and a password (4 numbers set by you)
  6. Finally, you can login SoftBank web site to register your phone.
  7. You can use your credit card to recharge: http://mb.softbank.jp/en/prepaid_service/recharge/credit_card.html 

    1. You can also check the expired time and balance in the web side. It is very important to me because I do not understand what they say in the 1400 call.



Finally, I apologize for my bad English.


2012年11月15日 星期四

Joomla redirect with message

If you want to use redirect function with a message to display message on screen, we can use as following codes:

JFactory::getApplication()->redirect(JRoute::_('PATH'), 'your message');

2012年11月7日 星期三

取得Joomla的安裝路徑

JPATH_SITE 這個constant可以讓我們取得joomla的安裝位置
ex:
echo JPATH_SITE;

c:\AppServ\www\your_joomla

2012年10月29日 星期一

Apache 預防 Range 標頭攻擊


見招拆招 改裝Apache就地抵禦DoS攻擊


Apache Log檔分割

Apache Log檔分割
在httpd.conf中搜尋 "CustomLog",將其改成

CustomLog "|bin/rotatelogs.exe logs/access%Y_%m_%d_%H_%M_%S.log 86400" common

之後的log檔會存成"access2012_10_29_00_00_00.log"的形式,以86400秒為一個檔案

2012年2月26日 星期日

GIW2012

http://conf.ncku.edu.tw/giw2012/

giw2012 in ncku

Zenbook case - GGMM case

I tried using the GGMM case for zenbook UX31. I'm luck it worked well.
The GGMM case is designed for Mac air 13" generally.
However, It not only fits for mba 13", but also fits for zenbook ux31.

本來就一直想替我的UX31買一個方便一點的保護套,例如可直接翻開的保護套

後來在Mac air上面看到GGMM的保護套,個人感覺外觀好看,形式也是我想要的。

因此在回家上網查一下UX31跟Mac air 13"的大小差異後,個人就跑去買了一個回家試試看(其實這樣真的有點賭...)

不過很幸運的!!!裝的上去,看起來應該不會有什麼問題(不過小弟我不能對這句話負責  )


請看(背景很居家~)


2012年2月20日 星期一

YUI 得知Datatable完成的方法

If you want to know that when is the datatable done, you can subscript the "postRenderEvent" event.

Juts like:
myDataTable.subscribe( 'postRenderEvent', function()
{
  //Do something
});

You can see here in more detail.

YUI 手動取得Datatable資料內容

IF you want to get datatable by a manual way, you can use the following code:


myDataTable.getRecord(0).getData("id");

  • myDataTable is your datatable name.
  • The parameter in getRecord is row number. (0 ~ the numebr of row - 1)
  • The parameter in getData is a key name. You have to specifically assign that.

2012年2月12日 星期日

以Article ID取得文章資訊的方法

$article =& JTable::getInstance("content");

$article->load(Article_ID);
echo $article->get("title");

最後會Echo出文章的Title

不過這樣做不能自動依系統定義自動產生read more...殘念