2017年1月16日 星期一

讓 Facebook 分享取得資訊的網頁設定

當使用者在 Facebook (FB) 分享連結時,FB 會依連結取得適當的資訊,如圖片、Title、簡介內容等。FB 有指定提供訊息的方式,假如網頁有提供對應的資訊,則會顯示該資訊。假如沒有提供這些資訊,則 FB 會自行判斷挑選,常常會挑到不具代表性的圖。

下面的連結是相關的討論
http://stackoverflow.com/questions/1138460/how-does-facebook-sharer-select-images-and-other-metadata-when-sharing-my-url

除錯的網站,需以 FB 帳號登入才可使用。
 https://developers.facebook.com/tools/debug

FB 需要下面的 metadata,假若找不到,則自行推導。

<head>
    <meta property="og:url" content="http://www.test.com/" />
    <meta property="og:title" content="Prepaid Phone Cards, low rates for International calls with Lucky Prepay" />
    <meta property="og:description" content="Cheap prepaid Phone Cards. Low rates for international calls anywhere in the world." />

    <meta property="og:image" content="http://www.test.com/img/fb-logo.png" />
   <meta property="og:image:width"  content="110" />
  <meta property="og:image:height" content="110" />

</head>

2017年1月14日 星期六

小測 Google 的雲端硬碟

實測 copy 4GB 的檔案
內部,NAS 複製到自己的電腦,時間 00:01:20,不到 1分半鐘。
再由自己的電腦上傳到 Google 的雲端硬碟,時間 00:01:21.68,也是不到 1分半鐘。
上傳到 Google 的雲端硬碟,僅慢了幾秒鐘。
因為是一手按滑鼠按鍵,一手點按手機,實際差多少,就不知道了。但也只能說,Google 大神,實在太恐怖了。

2017年1月6日 星期五

gcin-2.8.4 -- 對 QT5 的支援

在 Gentoo 的 overlay,只有 gcin-2.8.3 的 ebuild,還沒有 gcin-2.8.4 的 ebuild。就自行下載 2.8.3 的版本,直接改成 2.8.4 的版本。在上一篇,已處理了在 gtk 應用程式,輸入框一直黏在左上角的問題。

PS. 目前,已升級至 gcin-2.8.5,所以,此處的資訊,對於 gcin-2.8.4  可能都是沒用的了。

在 USE flag 包含 qt4 時,會編譯失敗,只要將 ebuild 中的 DEPEND,qt4 的部分改成
 qt4? ( dev-qt/qtcore:4 dev-qt/qtgui:4 )

另外,在 DEPEND,加上 qt5? ( dev-qt/qtcore:5 dev-qt/qtgui:5 ),以及在 IUSE 加上 qt5,即會多了 qt5 的 USE flag。
再來,要將 qt5-im/Makefile 中的 Qt5PlatformSupport 移除,以及將 qt5-im/gcin-qt5.h 中的 IID 版本,改成 org.qt-project.Qt.QPlatformInputContextFactoryInterface.5.1

Qt5PlatformSupport 移除後,在有 qt5 的 USE flag 之下,可以順利編譯,但仍無法在 QT5 應用程式中,如 kate,輸入中文。

在未修正 IID 時,使用 「qtplugininfo /usr/lib64/qt5/plugins/platforminputcontexts/libgcinplatforminputcontextplugin.so」 的指令,顯示下列結果
IID "org.qt-project.Qt.QPlatformInputContextFactoryInterface" Qt 5.6.2 (debug)
User Data: {
    "Keys": [
        "gcin"
    ]
}


依上述所講的,修正 IID 之後,使用 「qtplugininfo /usr/lib64/qt5/plugins/platforminputcontexts/libgcinplatforminputcontextplugin.so」 的指令,顯示下列結果

IID "org.qt-project.Qt.QPlatformInputContextFactoryInterface.5.1" Qt 5.6.2 (debug)
User Data: {
    "Keys": [
        "gcin"
    ]
}


安裝之後,重新登入,在 kate 下,即可切換中文和輸入中文了。

ebuild 測試步驟摘要
  • 修改後,執行 ebuild gcin-2.8.5.ebuild digest,重新建立 Manifest
  • ebuild gcin-2.8.5.ebuild clean,清除暫存檔
  • ebuild gcin-2.8.5.ebuild prepare,執行 src_prepare() 的部分
  • ebuild gcin-2.8.5.ebuild configure,執行 src_configure() 的部分
  • ebuild gcin-2.8.5.ebuild compile,執行 src_compile() 的部分
  • ebuild gcin-2.8.5.ebuild install,執行 src_install() 的部分
  • ebuild gcin-2.8.5.ebuild qmerge,移除舊版本,安裝新的版本
參考連結
http://hyperrate.com/thread.php?tid=32359 
http://hyperrate.com/thread.php?tid=32406

http://hyperrate.com/thread.php?tid=32772#32772

2017 年 10 月

噢,gcc 升級後,gcin 在加上 qt5 的支援,又不行編譯了,出現
/usr/include/qt5/QtCore/qcompilerdetection.h:562:6: 錯誤:#error Qt requires a C++11 compiler and yours does not seem to be that.
 #    error Qt requires a C++11 compiler and yours does not seem to be that.
/usr/include/qt5/QtCore/qbasicatomic.h:61:4: 錯誤:#error "Qt requires C++11 support"
 #  error "Qt requires C++11 support"

這裡有一篇關於 C++11 support 的討論,只能有空再看了

現在只好在 kde 的應用程式下,不要用中文輸入啦
其他參考
https://forums.gentoo.org/viewtopic-t-1065532-start-0.html

2017-11-09 補記

QT 5 要求 C++11 support,而 gcc 預設是 C++98,因而在加上 qt5 的 use flag 時,gcin 無法成功安裝。因此,KDE 的應用程式,如 kate 也就無法輸入中文。找了一陣子的解答,忍受到今天,終於修改安裝成功。 
在發生編譯錯誤後,指令測試
# cd /var/tmp/portage/app-i18n/gcin-2.8.5/work/gcin-2.8.5/qt5-im

加上 --std=c++11 的選項,可以成功編譯
gcc -g  --std=c++11 -O -I../im-client -I/usr/include/X11 `pkg-config Qt5Core Qt5Gui  QtDBus --cflags` -I`pkg-config --variable=includedir Qt5Gui`/QtGui/`pkg-config --modversion Qt5Gui`/QtGui -Wall -D_REENTRANT -DUNIX=1 -fPIC  -DQT5 -DQT_SHARED -DQT_IMMODULE -DPIC -DDEBUG="00" -MM *.cpp > .depend

改成 --std=c++98,出現 "Qt requires C++11 support" 的錯誤
gcc -g  --std=c++98 -O -I../im-client -I/usr/include/X11 `pkg-config Qt5Core Qt5Gui  QtDBus --cflags` -I`pkg-config --variable=includedir Qt5Gui`/QtGui/`pkg-config --modversion Qt5Gui`/QtGui -Wall -D_REENTRANT -DUNIX=1 -fPIC  -DQT5 -DQT_SHARED -DQT_IMMODULE -DPIC -DDEBUG="00" -MM *.cpp > .depend

修改  gcin-2.8.5.ebuild,在 src_prepare() 段落中,加入  append-cxxflags -std=c++11 並沒有用。只好直接用 sed 在 qt5-im/Makefile 的 CXXFLAGS 加上 --std=c++11 的選項。程式片段如下
    # Qt5 requires C++11 support
    if use qt5 ; then
        sed -i 's/CXXFLAGS=/&-std=c++11 /' \
                "${S}"/qt5-im/Makefile \
                || die 'sed failed'
    fi

升級 Qt 5.9.4 問題處理 (2018-03-24)

升級至 Qt 5.9.4 之後,gcin 又不能用了。重新安裝,在 compile 時,會出現找不到 qtguiglobal_p.h 和 qglobal_p.h 的錯誤。

compile 時,是用 pkg-config Qt5Core Qt5Gui  QtDBus --cflags 取得 include 的資訊,其取得的結果如下
-DQT_SHARED -I/usr/include/qt5/QtGui -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/include/qt5 -I/usr/include/qt4 -I/usr/include/qt4/QtDBus -I/usr/include/qt4 -I/usr/include/qt4/QtXml -I/usr/include/qt4 -I/usr/include/qt4/QtCore

但實際上,這兩個檔是在這目錄下
$ find /usr/include -name qglobal_p.h
/usr/include/qt5/QtCore/5.9.4/QtCore/private/qglobal_p.h
$ find /usr/include -name qtguiglobal_p.h
/usr/include/qt5/QtGui/5.9.4/QtGui/private/qtguiglobal_p.h

因此,按上述手動執行各階段動作,在 compile 之前,修改 /gcin-2.8.5/qt5-im/Makefile,加上兩個 include 的目錄,成功安裝。
INCS=-I../im-client -I/usr/include/X11 `pkg-config Qt5Core Qt5Gui  QtDBus --cflags` -I/usr/include/qt5/QtGui/5.9.4 -I/usr/include/qt5/QtCore/5.9.4

不想改 ebuild 檔,也許,那天上游會作出修正。

升級 Gcin 2.8.6 (2018-06-16)

感謝 Edward Liu,升級到 Gcin 2.8.6,完全不需要做任何修改,即可安裝成功。

2017年1月3日 星期二

gcin 問題解決 -- 輸入窗黏在視窗左上解

蠻奇怪的,在家裡,輸入中文時,就是會黏在應用程式的左上角,而辦公室的是正常的。
歸納問題,這些程式都是 gtk+ 的程式。除了 Gnome 自己的應用程式,如 gedit 為 gtk3 的外,其他的都是 gtk2。

先收集辦公室的相關資料
設定檔 ~/.config/xfce4/xinitrc 的內容
#!/bin/sh
#
# Settings for gcin.
#
export LANG=zh_TW.UTF-8
export LC_ALL=zh_TW.UTF-8
export GTK_IM_MODULE=gcin
export XMODIFIERS="@im=gcin"
#exec gcin &

使用的是 gcin 2.8.4。

# lsof | grep -i immo
gedit     ....   /usr/lib64/gtk-3.0/3.0.0/immodules/im-xim.so  
xfce4-ter ....   /usr/lib64/gtk-2.0/immodules/im-gcin.so
leafpad   ....   /usr/lib64/gtk-2.0/immodules/im-gcin.so

從上面的列表,可以看到 gtk2 的應用程式,使用 im-gcin.so。而 gtk3 的應用程式 gedit,則是用 im-xim.so。

執行 gtk-query-immodules-3.0 --update-cache,會將  input method modules for GTK+ 寫入 libdir/gtk-3.0/3.0.0/immodules.cache,其中 libdir 為 /usr/lib64 及 /usr/lib。

例如 /usr/lib/gtk-3.0/3.0.0/immodules.cache 中,會有下列資料
"/usr/lib64/gtk-3.0/immodules/im-gcin.so" 
"gcin" "gcin Input Method" "gcin" "/usr/share/locale" "zh:ja" 

/usr/lib/gtk-2.0/2.10.0/immodules.cache 中,會有下列資料
"/usr/lib64/gtk-2.0/immodules/im-gcin.so" 
"gcin" "gcin Input Method" "gcin" "/usr/share/locale" "zh:ja" 


可以看到,gedit 已改成用 im-gcin.so。
gedit     ....   /gtk-3.0/immodules/im-gcin.so

2016年12月28日 星期三

MediaElement.js 的使用

HTML5 media player 的挑選,首先,考量相容性。
MediaElement.js 最佳,在 IE8,判斷為 flash 模式,正常播放。
但在 Vivaldi 下,判斷為 native 模式,假如 libffmpeg.so 不支援 H.264,則無法播放。在其支援 H.264 後,則可以播放。我的電腦上的 Vivaldi 在播放影片,都沒聲音,原因不明。

Video.js 和 Plyr,受歡迎度很高,但在 IE8,整個版面都跑了,不能播放。

關於指定開始時間的作法,參考
http://stackoverflow.com/questions/7605930/how-to-set-start-time-offset-using-setcurrenttime

2016年12月23日 星期五

使用 Server 2008 Core

安裝 Server 200 Core,使用不到 10 GB 的空間。

使用 sconfig 設定電腦
參考: https://technet.microsoft.com/en-us/library/ff476070.aspx

Five Ways to Manage Server Core
http://windowsitpro.com/windows-server-2008/five-ways-manage-server-core

 Admin”s Guide to Server Core Commands
http://blogs.msmvps.com/ad/blog/2008/09/18/admin-s-guide-to-server-core-commands/

安裝 IIS,大小寫有差
c:\> start /w pkgmgr /iu:IIS-WebServerRole

或者,參考 Install PHP and FastCGI Support on Server Core
https://www.iis.net/learn/application-frameworks/install-and-configure-php-on-iis/install-php-and-fastcgi-support-on-server-core

c:\> start /w ocsetup IIS-WebServerRole
安裝 FASTCGI
c:\> start /w ocsetup IIS-CGI

管理工作
http://blog.yam.com/fingersworld/article/46683953

關閉防火牆指令
[netsh advfirewall set allprofiles state off]
參考: http://www.techrepublic.com/blog/the-enterprise-cloud/disabling-the-firewall-in-windows-server-2008-core-edition/

To enable remote administration from Windows Vista/Windows 2008; Write the command in the Windows shell:
 "Cscript %windir%\system32\SCRegEdit.wsf /ar 0" and press the "Enter" button.


連線網路磁碟
net use x: \\10.161.86.15\nas_bak
中斷
net use /delete x:

使用 Total Commander,就可以自由的 copy 檔案了。

2016年12月21日 星期三

在網頁中預覽文件

在原來的網站上,是用 Zoomify (http://www.zoomify.com/support.htm) 來達成文件預覽的功能。但是,其必須先將文件轉成圖檔。

後來看到 pdf.js 能夠提供 pdf 的預覽。 然後,又找到 viewerjs 能夠提供內嵌在網頁中預覽的功能。viewerjs 支援 pdf 和 odf 的文件,那就先將 office 的文件轉成 pdf 吧。

doc => pdf
http://mydailyjava.blogspot.tw/2013/05/converting-microsoft-doc-or-docx-files.html
http://www.thoughtasylum.com/blog/2012/12/20/vbscript-to-convert-microsoft-office-files-word-excel-powerp.html

以下是一個使用 pdf.js 來預覽 pdf 的網頁
http://docplayer.net/12992566-Altos-r380-f3-faq-frequently-asked-questions.html



其中,內嵌 iframe 如下
<iframe width="100%" height="700" frameborder="0"
    allowfullscreen=""
    src="/docview/28/12992566/"
    scrolling="no" 

    style="border-bottom: 2px solid #eee; border-top: 0px;" pages="86" 
    k_dim="70" 
    id="player_frame"
></iframe>

iframe 的 src,單獨顯示如下

http://docplayer.net/docview/28/12992566

問題與討論
https://www.bountysource.com/teams/kogmbh/issues?tracker_ids=386958

網誌存檔