2016/1/4

是時候考慮 新自然輸入法--going10 的存廢

從自然輸入法8開始,我就是一直他的愛好者,推出10,我當然也更新、升級、購買
升級之後,一直有個功能,頗多抱怨,就是輸出碼,何時能只要選擇「簡/正」,其他對我來說,都是不必要的功能

甚至,10推出的免費版,只有「簡/正」輸出,但是專業版,完全沒有更新
從2013年,我就發信詢問:
回覆是:
A.我們已將此建議提供給相關單位,並考慮列出未來改進的項目之中
B.因自然輸入9版與新自然輸入法程式架構不同




甚至前段時間,發生了AVG將自然輸入法判斷為病毒,造成整個WINDOWS完全沒有回應
關鍵字:「自然輸入法 AVG」
6/21發生此問題,官網留言還會出現磁碟空間不足
win8+avg2015,今天一直把自然輸入法當作病毒,不移除自然輸入法還會讓所有程式無法回應
到貴公司官網留言,還竟然丟出.net錯誤:磁碟空間不足
難道貴公司的軟體確定被攻擊當作木馬了?


最近,再度發信詢問,到今天(2016/1/4)為止,自然輸入法還沒有回應



結論:能換就換,實在沒必要再去花錢支持這家廠商
http://hyperrate.com/?eid=215  gcin
https://github.com/chewing/windows-chewing-tsf/ 酷音輸入法

2017/03/02更新:
原本手機就有使用超注音,現在也推出windows版本,可以推薦:
超注音電腦版出爐---超注音-for-windows

2015/12/18

EF framework LIKE Hibernate SaveOrUpdate()


 from:
http://stackoverflow.com/questions/7552433/what-is-the-equivalent-for-hibenate-saveorupdate-in-entity-framework
果然是stackflow,馬上找到

There is no equivalent. You really have to write it like:
using (DataContext context = new DataContext())
{
    context.Task.Attach(task);
    if (task.ID == 0)
    {
         context.ObjectStateManager.ChangeObjectState(task, System.Data.EntityState.Added);
    }
    else
    {
         context.ObjectStateManager.ChangeObjectState(task, System.Data.EntityState.Modified);
    }

    context.SaveChanges();
 }

2015/12/9

jsp頁面的頭部空白行


From:http://www.111cn.net/jsp/Java/55593.htm
           http://kirby86a.pixnet.net/blog/post/111632383-%E8%A8%AD%E5%AE%9Atomcat-7%EF%BC%8C%E5%8E%BB%E9%99%A4%E7%B7%A8%E8%AD%AF%E5%BE%8C%E7%9A%84jsp%E4%B8%8A%E6%96%B9%E7%94%A2%E7%94%9F%E5%A4%A7%E9%87%8F%E7%9A%84
原因是網頁上方宣告,
例如:
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
若是在宣告使用其他taglib或引入其他方法,那麼空白行就會更多,

方案一:
<%out.clear();%>
缺點:
後面的部分都要緊跟向前縮進不推,
主要是自己也還是暫用一行空白不推薦

方案二:
<%@ page trimDirectiveWhitespaces="true" %>

方案三: in web.xml
<jsp-config>
  <jsp-property-group>
    <url-pattern>*.jsp</url-pattern>
    <trim-directive-whitespaces>true</trim-directive-whitespaces>
  </jsp-property-group>
</jsp-config>


方案四:
如果Tomcat是 Tomcat5.x版本,即JSP2.0和Servlet2.4的規範
web.xml:
<servlet>
         <servlet-name>jsp</servlet-name>
         <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
        <init-param>
             <param-name>trimSpaces</param-name>
             <param-value>true</param-value>
         </init-param>
         <load-on-startup>3</load-on-startup>
     </servlet>

2015/10/26

redmine with apache on centos7


from:http://www.redmine.org/projects/redmine/wiki/install_Redmine_25x_on_Centos_65_complete
yum -y install nano zip unzip libyaml-devel zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel gcc ruby-devel gcc-c++ make postgresql-devel ImageMagick-devel sqlite-devel perl-LDAP mod_perl perl-Digest-SHA
 

 
 

from:http://blog.maxkit.com.tw/2014/11/centos-6-redmine.html
在/etc/httpd/conf.d/加上redmine.conf,並編輯redmine.conf加入以下的設定。
vi /etc/httpd/conf.d/redmine.conf

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-4.0.53/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
    PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-4.0.53
    PassengerDefaultRuby /usr/bin/ruby
</IfModule>

RailsBaseURI /redmine
<Directory /var/www/redmine/public>
    # This relaxes Apache security settings.
    AllowOverride all
    Options -MultiViews
</Directory>
在DocumentRoot的路徑下加上redmine的symbolic link
ln -s /var/www/redmine/public /var/www/html/redmine
這個設定過程很重要,因為 redmine 官方只提供了以 virtual host 的方式跟 apache 整合,但我們希望用 http://localhost/redmine/ 的網址方式,連結 redmine,努力兩天後,得到上面的解決方案。

之後就是selinux的問題了,tail /var/log/audit/audit.log |audit2allow -M redmine1.pp
PS:因為執行過長,找到解決方法
http://tech.farend.jp/blog/2015/04/21/redmine-selinux/

インストール

“SELinuxを無効にする”の項は無視し、SELinuxをPermissiveモード(監視はするがアクセス制御はしない)にします。







1
setenforce 0
以降、最新版インストールガイド に従い、Redmineを構築します。

SELinuxの有効化と権限の付与

Redmineを構築し終えたら、以下のコマンドを実行します。







1
2
chcon -R -t httpd_sys_content_t /var/www/redmine/
setsebool -P httpd_unified on
Redmineのルートフォルダに対して「httpd_tというラベル付けがされたファイルから読み出される権限」を適用し、httpdによるファイルへの書き込み許可を設定しています。
最後に、SELinuxをEnforcingモードに戻します。







1
setenforce 1
以上です。
還有一個方式,沒有測試能否執行(還是要執行下面指令,為了結合LDAP驗證)
http://qiita.com/duloxetine/items/9a7285fd709e30ad9a62
# grep PassengerAgent /var/log/audit/audit.log | audit2allow -M passengeragent
# semodule -i passengeragent.pp
# grep ruby /var/log/audit/audit.log | audit2allow -M ruby
# semodule -i ruby.pp
# grep utils.rb:108 /var/log/audit/audit.log | audit2allow -M utils
# semodule -i utils.pp
因為LDAP帶來的資料有中文(或者輸入資料有中文問題),需要使用utf-8編碼,但是會遇到index太長的問題
原因:http://samyubw.blog.51cto.com/978243/223773
 得出的結論是:對於創建innodb的組合索引,如果各個列中的長度不超過767,則不再計算所有列的總長度,如果有超過767的,則給出報警,索引最後 創建成功,但是對於超過767字節的列取前綴索引;對於innodb的單列索引,超過767的,給出warning,最終索引創建成功,取前綴索引(取前 255字節)
解決方式:http://se-suganuma.blogspot.tw/2014/02/ruby-redmine-unicorninstallalminium.html
# vi /etc/my.cnf
# for Redmine
innodb_file_format = Barracuda
innodb_file_per_table = 1
innodb_large_prefix
# /etc/rc.d/init.d/mysqld restart
# vi config/initializers/adapt_utf8mb.rb
ActiveSupport.on_load :active_record do
  module ActiveRecord::ConnectionAdapters
    class AbstractMysqlAdapter
      def create_table_with_innodb_row_format(table_name, options = {})
        table_options = options.reverse_merge(:options => 'ENGINE=InnoDB ROW_FORMAT=DYNAMIC')
        create_table_without_innodb_row_format(table_name, table_options) do |td|
          yield td if block_given?
        end
      end
      alias_method_chain :create_table, :innodb_row_format
    end
  end
end
Try Again
# RAILS_ENV=production bundle exec rake db:migrate
無事完了。


加上GIT
http://redmine-git-hosting.io/get_started/
其中建立使用者git ,redmine改成apache
# Install dependencies (On Debian/Ubuntu)
root# apt-get install build-essential libssh2-1 libssh2-1-dev cmake libgpg-error-dev

# Install dependencies (On Fedora/CentoS/RedHat)
root# yum groupinstall "Development Tools"
root# yum install libssh2 libssh2-devel cmake libgpg-error-devel
# Switch user
root# su - redmine

# First git clone Bootstrap Kit
redmine$ cd REDMINE_ROOT/plugins
redmine$ git clone https://github.com/jbox-web/redmine_bootstrap_kit.git
redmine$ cd redmine_bootstrap_kit/
redmine$ git checkout 0.2.3

# Then Redmine Git Hosting plugin
redmine$ cd REDMINE_ROOT/plugins
redmine$ git clone https://github.com/jbox-web/redmine_git_hosting.git
redmine$ cd redmine_git_hosting/
redmine$ git checkout 1.1.4

# Install gems and migrate database
redmine$ cd REDMINE_ROOT
redmine$ bundle install --without development test
redmine$ bundle exec rake redmine:plugins:migrate RAILS_ENV=production NAME=redmine_git_hosting
.........
(從該來源網站按步驟)實施就可以正常安裝
第一次建立時,請下:
git init --bare
將git server初始化
至於管制方式,關鍵字:ssh ldap

或者vi /etc/password
將git由bin/bash變成bin/git-shell,原因:
出于安全的考虑,我们最好限制用户只能进行git push/pull,但无法登陆。这可以使用git-shell来完成。

會出現錯誤訊息: hint: ~/git-shell-commands should exist and have read and execute access

錯誤訊息參考:
http://nick.txtcc.com/index.php/linux/1116
  •  cp -Rf /usr/local/share/git-XXXX/contrib/git-shell-commands .
  •  # 再來改變權限
  •  chown -R git: git-shell-commands/
  •  chmod +x git-shell-commands/help
  •  chmod +x git-shell-commands/list


PS:selinux 再補充
https://mbrownnyc.wordpress.com/technology-solutions/rhodecode-and-redmine/part-4-redmine-on-apache/
其中PassengerTempDir:
The passenger_temp_dir option (Nginx) and the PassengerTempDir option (Apache) have been replaced by two config options. On Nginx they are passenger_instance_registry_dir and passenger_data_buffer_dir. On Apache they are PassengerInstanceRegistryDir and PassengerDataBufferDir. On Apache, PassengerUploadBufferDir has been replaced by PassengerDataBufferDir.
測試結果:殘念.....XD  not working..

redmine建立好,設定好,還是一直告知你empty:
http://redmine-git-hosting.io/troubleshooting/

My repository seems empty but I’m sure it is not!


A git clone of the repository gives me files!
root$ su - redmine
redmine$ cd REDMINE_ROOT
redmine$ bundle exec rake redmine_git_hosting:fetch_changesets RAILS_ENV=production




2015/10/21

cacti with SELinux


From:
http://docs.cacti.net/manual:087:1_installation.1_install_unix.8_selinux

SELinux Settings

SELinux setting greatly depend on which exact setup you are running. E.g. when installing Cacti into /var/www/html/cacti (which is the default installation location), the web server httpd usually has the required permissions to execute as required. But when e.g. installing into a private directory, e.g. ~/mycacti, you will have to provide specific SELinux settings.

Global SELinux Settings

This is an excerpt from my personal settings when installing into private directory. Any or all of them may be obsolete, when using the default location. Use -P option to make the change permanent

/usr/sbin/setsebool -P httpd_read_user_content=1
/usr/sbin/setsebool -P httpd_tty_comm=1
/usr/sbin/setsebool -P httpd_can_network_connect=1
/usr/sbin/setsebool -P httpd_builtin_scripting=1
/usr/sbin/setsebool -P httpd_enable_homedirs=1
/usr/sbin/setsebool -P httpd_enable_cgi=1

SELinux Settings for Plugins

BOOST

In case you are using BOOST server network setup, it was reported that
/usr/sbin/setsebool -P httpd_can_network_connect=1
 
 
 chcon -R -t httpd_sys_content_t /usr/share/cacti/
<==這句最重要 
 

mantis on CentOS 7 with AD


FROM:
http://eggchang.pixnet.net/blog/post/42099440-%E5%9C%A8-centos-7-%E4%B8%8A%E9%9D%A2%E5%AE%89%E8%A3%9D-mantis-%28microsoft-ad-%E8%AA%8D%E8%AD%89%29
http://eggchang.pixnet.net/blog/post/36649739-mantis-%2B-dokuwiki-%2B-subversion-%2B-active-directory---part-1


# 安裝 Mariadb (替代 MySQL 的 Database)
yum -y install mariadb mariadb-server mariadb-libs
# 安裝 Apache Web Server
yum -y install httpd mod_dav_svn
# 安裝 PHP
yum -y install php php-bcmath php-cli php-common php-enchant php-gd php-intl php-ldap php-mbstring php-mysql php-pdo php-pear php-process php-pspell php-recode php-soap php-xml php-xmlrpc rrdtool-php uuid-php php-pecl-memcache​ php-devel
# 安裝中文字型 (讓統計圖表可以正常顯示中文)
mkdir /usr/share/fonts/truetype
wget http://www.study-area.org/apt/firefly-font/fireflysung-1.3.0.tar.gz
tar xvzf fireflysung-1.3.0.tar.gz
cp fireflysung-1.3.0/fireflysung.ttf /usr/share/fonts/truetype/arial.ttf



# 提高 File Upload 檔案大小的上限到20MB
# vi /etc/php.ini
# 修改 upload_max_filesize = 20M
# 修改 max_file_uploads = 20
# 修改 post_max_size = 20M
# 修改 max_execution_time = 60
# 修改 memory_limit = 512M
# 修改 date.timezone 參數, 改為 date.timezone = 'Asia/Taipei'

=====================================
# 設定 SELinux
chcon -R -t httpd_sys_rw_content_t /var/www/html/mantis
setsebool -P httpd_can_sendmail on
setsebool -P httpd_can_network_connect on
chcon -R --reference /var/www/html/mantis /usr/share/fonts

PS:解決
SYSTEM WARNING: 'opendir(/var/www/html/mantis/plugins/): failed to open dir: Permission denied' in
=====================================
#mv admin admin-old
PS:web提示安全性問題

 使用ADsiedit來找AD資訊,後來改用ldp.exe查資料
ldp.exe-->connect -->BIND-->Account /Password-->Copy DN
將DN資訊修改到下面去
# 設定透過 AD/LDAP 認證與帳號
$g_login_method = LDAP;
$g_ldap_server = 'ldap://192.168.1.8/'; # Microsoft AD Domain Controller
#$g_ldap_port = 3268; # for AD Global Catalog Server (GC)
$g_ldap_root_dn = 'OU=XXXXXX,DC=axman,DC=com,DC=tw'; # 看 Users 是放在哪個位置
$g_ldap_bind_dn = 'Domain\UserNAME'; # 用來連接並查詢 AD 的帳號, 給一般 User 即可
$g_ldap_bind_passwd = 'PASSWORD';
$g_use_ldap_email = ON; # 用 AD 帳號的 Mail 作為 Mantis 裡面的 Mail
$g_ldap_uid_field = 'sAMAccountName';
$g_ldap_realname_field = 'cn'; # 以 AD 帳號的 CN 屬性做為顯示名稱
$g_use_ldap_realname = ON; # 用 AD 帳號的顯示名稱 (CN) 顯示在 Mantis 上
$g_ldap_organization = '';
$g_ldap_protocol_version = 3;
$g_allow_signup = OFF; # 設定不可申請帳號 (用AD/LDAP帳號登入就自動建立帳號, 因此不須申請)
$g_send_reset_password = OFF; # 設定不可以重設 Password (因為 Password 是 AD/LDAP 在控制, Mantis 不能修改)


# 設定傳送郵件的方式與寄件人

$g_administrator_email  = 'Mantis@axman.com.tw';
$g_webmaster_email      = 'mis@axman.com.tw';
$g_from_email      = 'Mantis@axman.com.tw'; # Mantis 以誰的名義寄信 (From)
$g_return_path_email    = 'Mantis@axman.com.tw';
$g_phpMailer_method = 2;
$g_smtp_host = '192.168.1.248'; # SMTP 的位置
$g_smtp_username = ''; # 若 SMTP 需要登入, 則於此設定登入 SMTP 的帳號
$g_smtp_password = ''; # 若 SMTP 需要登入, 則於此設定登入 SMTP 的密碼
$g_enable_email_notification = ON;
$g_log_destination = 'file:/var/www/html/mantis/log/mail.log'; # 寄信後留個紀錄
$g_log_level = LOG_EMAIL_RECIPIENT;

    # 檔案上傳設定

$g_allow_file_upload = ON; # 允許上傳檔案
$g_max_file_size = 20000000; # 設定上傳檔案的大小限制 (最大20M), 除此之外, 前面章節的 php.ini 亦需有相對應的設定
$g_file_upload_max_num = 10; # 最多可同時上傳10個檔案
$g_file_upload_method = DATABASE; # 上傳檔案放置的位置為資料庫. 若想放在 File System, 則設為 DISK
$g_absolute_path_default_upload_folder = '/var/www/html/mantis/attachment'; # 上傳檔案的目錄, $g_file_upload_method = DISK 時需要設定
$g_preview_attachments_inline_max_size = 5120000; # 超過 512KB 的圖形檔不允許預覽

# 打開 Time Tracking 功能 (負責解決 Issue 的人可以輸入處理 Issue 所耗的工時)

$g_time_tracking_with_billing = ON;
$g_time_tracking_enabled = ON;
$g_time_tracking_stopwatch = ON;
$g_time_tracking_view_threshold = DEVELOPER;
$g_time_tracking_edit_threshold = DEVELOPER;
$g_time_tracking_reporting_threshold = MANAGER;
$g_time_tracking_without_note = OFF;

# 其他設定

#$g_path = 'http://webproject.axman.com.tw/mantis/'; # 網址
$g_max_failed_login_count = 5; # 登入失敗最多五次, 超過鎖帳 (Mantis 的帳號)
$g_show_version = OFF; # 不要顯示 Mantis 版本 (網路安全考慮)
$g_default_language = 'english'; # 新建立的使用者預設語系 (若要改為中文則設定為 'chinese_traditional')
$g_window_title = ' <顯示在瀏覽器上方的文字>'; # 瀏覽器標題顯示的文字
$g_show_realname = ON; # 顯示使用者的顯示名稱 (預設是顯示登入帳號, 通常是一串難記的號碼)
$g_short_date_format = 'Y/m/d'; # 短日期格式
$g_normal_date_format = 'Y/m/d H:i'; # 一般日期格式
$g_complete_date_format = 'Y/m/d H:i'; # 長日期格式
$g_default_language     = 'chinese_traditional';  ##預設繁體中文

注意一點:
只要用 Windows Domain 的帳號與密碼登入, Mantis 會自動建立新的使用者, 並賦予 Reporter 的權限, 因此不需要 Administrator 再手動建立. 惟若有專案的需要比較高的機密, 則該專案應該設定為 "非公開", 並明確指定哪些帳號才有權限, 以避免任意的 Domain User 登入後都可以看到所有專案的內容



手機QQ禁用NFC

一圖解千言萬語 應用程式權限:透過NFC起動