顯示具有 OpenSource 標籤的文章。 顯示所有文章
顯示具有 OpenSource 標籤的文章。 顯示所有文章

2019年2月21日 星期四

CefSharp3 Multi Thread Add listen AddressChanged Event

原來使用的套件 Awesomium.NET 因為太久沒更新對於BootStrap4的支援已經跟不上了,所以選擇的替代方案是CefSharp3這個Open Source Core。

不意外的CefSharp3也是Chrome Base的可是導入在WIN AP上有完整的範例,版控更新上於GitHub也能看出他的活躍,總之這是要補紀錄在multi Thread增加EVENT的備忘,免得過段時間又忘記怎麼做。

首先增加要listen的FUNC
/// <summary>
/// 設定新分頁的url address變更的監聽
/// </summary>
private void setNewTab_addressCheangeEvent() {
            var control = GetCurrentTabControl();
            if (control != null)
            {
                control.Browser.AddressChanged += new EventHandler<AddressChangedEventArgs>(web_Auto_AddressChanged);
            }
}
//這個是把網址寫到指定的區域內
 private void web_Auto_AddressChanged(object sender, AddressChangedEventArgs e){
            SetTxt_Url(e.Address);
}

private delegate void str_Delegate(string str);
private void SetTxt_Url(string str) {
            if (InvokeRequired) {
                Invoke(new str_Delegate(SetTxt_Url), str);
                return;
            }
            TSL_url.Text = str;
}
接著於browserTabControl.TabPages.Add(tabPage); 之後加上 setNewTab_addressCheangeEvent();就會在每次新增的Tab都會去加入這EVENT的Listen。

這是以AddressChanged 觸發時的範例,其他的以此類推即可。

補充: 有趣的文章
JS處理修改URL但不跳轉的方法,在WEB POS接地氣上面來說對我幫助很大,節錄ing
var stateObj = { foo"bar" };
history.pushState(stateObj, """controler/function/variable");

2016年7月20日 星期三

WordPress 的 WP-Mail-SMTP設定

針對Contact Form 7需要所以得開通SMTP服務。

1. WordPress安裝WP MAIL SMTP 的PlugIn,用搜尋外掛即可找到。

2. WIN SERVER安裝hmailserver並完成相關安全性設定,參考此篇... 避免被當跳板所以SMTP認證都得開啟,同時關閉外部至外部郵件的路由。

3. 自WordPress設定項找到EMail進入,設定參考此篇... 原則上這樣就行了,不過測試信一直失敗,顯示權限不足~

補充:
(1). vim /etc/selinux/config 將 SELINUX=disabled ,不過關掉有些冒險...但是習慣透過IPtables來管理所以沒差。

(2). 調整Code ... 實測影響不大!

第一步:找到 wp-includes/pluggable.php 這個文件,將 262 行的 
    $phpmailer->IsMail(); 
    改為 
    $phpmailer->IsSMTP(); 

第二步:修改 wp-includes/class-phpmailer.php 這個文件裡的 SMTP 參數 
    var $Host = "smtp.server.com"; 
    var $SMTPAuth = true; 
    var $Username = "mail address"; 
    var $Password = "security";

(3) 將密碼的明碼顯示改掉,把smtp_pass的 type="text" 換成 type="password" 即可
 vim wp-content/plugins/wp-mail-smtp/wp_mail_smtp.php

2016年5月24日 星期二

Jenkins + TortoiseSVN + RYNC 機制

Jenkins 很方便,公司使用SVN不是GIT所以跟在保哥課程提到的方式不一樣,當然環境也是相異的(保哥是以MSBuild環境介紹),在LAMP中套用也沒有太多相異點,以此做個紀錄...

PS. 在Azure基本型A0安裝Jenkins貌似會自己Shutdown,改成A1後就正常了~很傻眼但正常就好,不曉得是1/4 CPU關係還是750M記憶體太少,總之改了很多地方都沒改善,機器等級提升就FIX囉。

Installation

wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -

sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'

sudo apt-get update

sudo apt-get install jenkins

Upgrade

sudo apt-get update

sudo apt-get install jenkins

Plugin

Once installed like this, you can update to the later version of Jenkins (when it comes out) by running the following commands:

install Subversion Plug-in

Authorized

sudo su jenkins -s /bin/bash

ssh-keygen -t rsa

 scp /var/lib/jenkins/.ssh/id_rsa.pub account@remoteServer:jenkins.pub

 cat /home/account/jenkins.pub >> /root/.ssh/authorized_keys

 chmod 600 /root/.ssh/authorized_keys

TEST

rsync -vzucPrl --delete-after -e ssh /SourcePath/ account@remoteServerIP:/TargetPath/

最近的雲端主機認證改成pem檔,所以rsync指令得改改如下,好處是上述的Authorized的程序可以免了
:

rsync -vzucPrl -e "ssh -i 'remoteserver.pem' -o 'StrictHostKeyChecking=no'" /SourcePath/ account@remoteServerIP:/TargetPath/

補充: 執行後發現若檔案存在但變更資料是少量的RSYNC會跳過該檔,所以加上-c做checksum雖然會比較慢但總比沒更新到好,畢竟FIX Bug有時候改的只是幾個BYTE而已。

2016年5月6日 星期五

OrangeHRM 3.1.1 Upgrade to 3.3.2 備忘

1. 下載3.3.2的SourceCode並安裝...
2. 修改 config_databases.yml.php 設定原3.1.1的DB
3. 執行底下的SQL

如果有變更資料夾路徑時,需調整 Catch中的
1. config_factories.yml.php
2. config_autoload.yml.php

2016年4月26日 星期二

FreePBX 12 + Asterisk 13 安裝備忘

sudo -i
apt-get update && apt-get upgrade -y

apt-get install -y build-essential linux-headers-`uname -r` openssh-server apache2 mysql-server mysql-client bison flex php5 php5-curl php5-cli php5-mysql php-pear php5-gd curl sox libncurses5-dev libssl-dev libmysqlclient-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool autoconf git unixodbc-dev uuid uuid-dev libasound2-dev libogg-dev libvorbis-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp0-dev libspandsp-dev libmyodbc

pear install Console_Getopt

A.         Install iksemel



cd /usr/src
wget https://iksemel.googlecode.com/files/iksemel-1.4.tar.gz
tar xf iksemel-1.4.tar.gz
rm iksemel-1.4.tar.gz
cd iksemel-*
./configure
或使用
./configure --with-libgnutls-prefix=/usr
make
make install



B.          Download Asterisk source files.



cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
wget -O jansson.tar.gz https://github.com/akheron/jansson/archive/v2.7.tar.gz
wget http://www.pjsip.org/release/2.4/pjproject-2.4.tar.bz2



Compile and install pjproject


cd /usr/src
tar -xjvf pjproject-2.4.tar.bz2
rm -f pjproject-2.4.tar.bz2
cd pjproject-2.4
CFLAGS='-DPJ_HAS_IPV6=1'./configure --enable-shared --disable-sound --disable-resample --disable-video --disable-opencore-amr
make dep
make
make install



Compile and install libsrtp


cd /usr/src/
wget http://srtp.sourceforge.net/srtp-1.4.2.tgz
tar zxvf srtp-1.4.2.tgz
cd
srtp
autoconf
./configure
make
make
install
cp
/usr/local/lib/libsrtp.a /lib



C.         Compile and Install jansson



cd /usr/src
tar vxfz jansson.tar.gz
rm -f jansson.tar.gz
cd jansson-*
autoreconf -i
./configure
make
make install



D.        Compile and install Asterisk



cd /usr/src
tar xvfz asterisk-13-current.tar.gz
rm -f asterisk-13-current.tar.gz
cd asterisk-*
contrib/scripts/install_prereq install
./configure -with-crypto -with-ssl -with-srtp=/usr/local/lib
contrib/scripts/get_mp3_source.sh
make menuselect
make
make install
make config
ldconfig
update-rc.d -f asterisk remove
chkconfig asterisk on
apt-get install sysv-rc-conf
sysv-rc-conf asterisk on



# mkdir /etc/asterisk/keys
# cd /usr/src/asterisk-13.7.2/contrib/scripts
# ./ast_tls_cert -C sipim.tibtrade.net -O "tibtrade" -d /etc/asterisk/keys

Next, we generate a client certificate for our SIP device.
# ./ast_tls_cert -m client -c /etc/asterisk/keys/ca.crt -k /etc/asterisk/keys/ca.key -C sipim.tibtrade.net -O "tibtrade" -d /etc/asterisk/keys -o malcolm

Install Asterisk Soundfiles.
The 'make install' above installs a standard low-quality base sound file by default. This is suitable if you are on a small, underpowered system (such as a Rasberry Pi), but on a larger system you should install higher quality soundfiles.  Note that this installs the (8khz) 'wav' soundfiles and G722 (High Definition 'Wideband') audio.


cd /var/lib/asterisk/sounds
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-wav-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz
tar xvf asterisk-core-sounds-en-wav-current.tar.gz
rm -f asterisk-core-sounds-en-wav-current.tar.gz
tar xfz asterisk-extra-sounds-en-wav-current.tar.gz
rm -f asterisk-extra-sounds-en-wav-current.tar.gz
# Wideband Audio download
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-g722-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g722-current.tar.gz
tar xfz asterisk-extra-sounds-en-g722-current.tar.gz
rm -f asterisk-extra-sounds-en-g722-current.tar.gz
tar xfz asterisk-core-sounds-en-g722-current.tar.gz
rm -f asterisk-core-sounds-en-g722-current.tar.gz



Install and Configure FreePBX

A.       Create the Asterisk user and set base file permissions.


useradd -m asterisk
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib/asterisk
rm -rf /var/www/html



B.         A few small modifications to Apache.



sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php5/apache2/php.ini
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
service apache2 restart



C.         Configure ODBC

Edit /etc/odbcinst.ini and add the following. Note that this command assumes you are installing to a new machine, and that the file is empty. If this is not a freshly installed machine, please manually verify the contents of the file, rather than just copying and pasting the lines below. The 'EOF' does no go in the file, it simply signals to the 'cat' command that you have finished pasting.


cat >> /etc/odbcinst.ini << EOF
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1
EOF


You may need to verify these paths, if you're not on a x86_64 machine. You can use the command `find / -name libmyodbc.so` to verify the location
Edit or create /etc/odbc.ini and add the following section. Note that, again, this command assumes you are installing to a new machine, and the file is empty. Please manually verify the contents of the files if this is not the case.


cat >> /etc/odbc.ini << EOF
[MySQL-asteriskcdrdb]
Description=MySQL connection to 'asteriskcdrdb' database
driver=MySQL
server=localhost
database=asteriskcdrdb
Port=3306
Socket=/var/run/mysqld/mysqld.sock
option=3 
EOF


D.        Download and install FreePBX.



cd /usr/src
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-13.0-latest.tgz
tar vxfz freepbx-13.0-latest.tgz
rm -f freepbx-13.0-latest.tgz
cd freepbx
chmod +x /usr/sbin/fwconsole
./start_asterisk start
./install -n

2016年4月14日 星期四

Redmine 啟動背景執行 Shell Script

最近VirtualPC再Windows重啟後透過排程設定背景執行,所以往常Redmine手動啟動變得沒有途徑可以輸入,寫入vc.local啟動命令列方式看來也殘念了,找到以下這腳本目前運作OK~~

#!/bin/bash # Modify it to your configuration DIR=/var/www/html/redmine/ # Start Redmine in daemon mode. start(){ cd $DIR ruby script/rails server webrick -e production -d > log/redmine.log } # Stop Redmine daemon stop(){ RUBYPID=`ps aux | grep "rails" | grep -v grep | awk '{print $2}'` if [ "x$RUBYPID" != "x" ]; then kill -2 $RUBYPID fi } # Check if Redmine is running status(){ RUBYPID=`ps aux | grep "rails" | grep -v grep | awk '{print $2}'` if [ "x$RUBYPID" = "x" ]; then echo "* Redmine is not running" else echo "* Redmine is running" fi
}

case "$1" in
  start)
    start
    status
    ;;
  stop)
    stop
    sleep 2
    status
    ;;
  status)
    status
    ;;
  restart|force-reload)
    stop
    start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|force-reload|status}"
    exit 1
esac