2018年11月27日 星期二

PHP develop on Win10, Domain Name Resolve Problem

When I use Bitnami WAMP on the Win10, I found out  that one connection consumes about 1.0x second. So below code needs about 4 seconds. Even when I use command line interface(CLI) to execute  it, such as php.exe or mysql.exe.

This is domain name resolve problem.

To Solve this problem you can replace "localhost" to "127.0.0.1".


$dbh = new PDO('mysql:host=localhost;dbname=dbname', 'user', 'pass');
$dbh = null;
$dbh = new PDO('mysql:host=localhost;dbname=dbname', 'user', 'pass');
$dbh = null;
$dbh = new PDO('mysql:host=localhost;dbname=dbname', 'user', 'pass');
$dbh = null;
$dbh = @new mysqli('localhost','dbname','pass','dbname');
$dbh->close();


Refer:
https://stackoverflow.com/questions/9800577/why-is-constructing-pdo-connection-slow

開發時PHP關閉暫存, OPCache.enable=0


OPCache 是 PHP 加速存取的功能,有用到的技術之一是暫存技術。


在開發時發現改完PHP源碼,但是網頁不能馬上看到修改結果,大約30秒到1分鐘才看得到修改後結果。原來是 bitnami WAMP 裡有開 opcache 功能。

開發PHP時關掉暫存快取功能,
file: php.ini
[opcache]
zend_extension=php_opcache.dll
; Determines if Zend OPCache is enabled
opcache.enable=0

References:
https://www.astralweb.com.tw/speed-up-your-magento-what-is-opcache/
https://www.ithome.com.tw/news/101602

2018年10月28日 星期日

Google Chrome Extensions : MinerBlock

隨著資訊發達,虛擬貨幣可以無中生有,不知道為什麼就是有人相信而使用它,只要有利可圖,當一堆人被哄騙了而相信就被使用了,他們完全不計後果代價。

有些網頁網站會在裡面暗藏 Javascript ,借用網頁瀏覽者的裝置效能(例如:CPU資源)來挖礦,還大言不慚地說並不會佔用太多瀏覽者的效能,而根是把所有的裝置效能都吃掉了,就為了「挖擴」,所以進這個網頁後就會發現電腦突然越跑越慢。

當遇到這個情形時,可以考慮使用有過濾 Javascript 的瀏覽器(例如:防毒軟體公司出品的Avast Secure Browser)或擴充功能(Google Chrome Extensions:搜尋 minerBlock 類似功能、或是 uBlock Plus Adblocker 還有過濾廣告功能),當進入有奇怪 Javascript 的網站時,就會先過濾掉,還使用者安靜的瀏覽環境。

2018年7月24日 星期二

DC user use the old profiles

local\oldacc

DC\newacc

1. 將舊 Profiles 的 ntuser.dat 的權限多加入網域帳號可完全控制。

先用網域帳號登入,再登出

用本機管理者權限開 regedit.exe ,選 HKEY_USERS , 再選 「檔案」=>「載入登錄區」,載入舊 Profiles 的 ntuser.dat。

2. 設定網域帳號的Profile資料夾路徑為舊Profiles資料夾路徑

找出修改:

電腦\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\{SID}

待測試。

2018年4月30日 星期一

[MSSQL] Create a request certification for MSSQL

產生需求憑證給MSSQL’s SSL:

;—————– request.inf —————–
[Version]
Signature="$Windows NT$"
[NewRequest]
Subject = "CN=FQDN" ; replace with the FQDN of the DC
KeySpec = 1
KeyLength = 2048
; Can be 1024, 2048, 4096, 8192, or 16384.
; Larger key sizes are more secure, but have
; a greater impact on performance.
Exportable = FALSE
MachineKeySet = TRUE
SMIME = False
PrivateKeyArchive = FALSE
UserProtected = FALSE
UseExistingKeySet = FALSE
ProviderName = "Microsoft RSA SChannel Cryptographic Provider"
ProviderType = 12
RequestType = PKCS10
KeyUsage = 0xa0
[EnhancedKeyUsageExtension]
OID=1.3.6.1.5.5.7.3.1 ; this is for Server Authentication
;———————————————–
[Extensions]
    2.5.29.17 = "{text}"
    _continue_ = "DNS=name1&"
    _continue_ = "DNS=name2"

;—————– END Of request.inf —————–

c:\>certreq –new request.inf output_file_for_CAtoSign.req

Then you can sign this .req, and import it to server that generates it. And you can find out this certificate for MSSQL SSL Encryption.

2018年4月24日 星期二

Sophos AutoUpdate Failed and to change Connection Address in iconn.cfg

Sophos On Platform WIN_81_SVR_X64 (Windows 2012 Standard R2)

C:\ProgramData\Sophos\AutoUpdate\Config

C:\ProgramData\Sophos\AutoUpdate\Config\iconn.cfg  -  This file contains the configuration of AutoUpdate in respect of the update locations and accounts used.

Looks like

;****************************************************************************
;
; iconn.cfg
;
; Please do not edit this text file.
;
;****************************************************************************

[PPI.WebConfig_Primary]
AllowLocalConfig = 0
AutoDialTimeout =
LocalPath =
DownloadGranularity =
ConnectionAddress = http://{ADDR}/sophos/CIDs/S000/SAVSCFXP/
UserName = xxx
UserPassword = xxx
ConnectionType = HTTP
UseSophos = 0
UseHttps = 0
UseDelta = 0
AutoDial = 0
BandwidthLimit = 0

[PPI.ProxyConfig_Primary]
AllowLocalConfig = 0
ProxyPortNumber = 0
ProxyType = 0

[PPI.WebConfig_Secondary]
AllowLocalConfig = 0
AutoDialTimeout =
LocalPath =
DownloadGranularity =
ConnectionAddress = http://es-web.sophos.com/update/
UseSophos = 1
UseHttps = 0
UseDelta = 0
PortNumber =
UserName = xxx
UserPassword = xxx
ConnectionType = HTTP
AutoDial = 0
BandwidthLimit = 0

[PPI.ProxyConfig_Secondary]
AllowLocalConfig = 0
ProxyPortNumber = 0
ProxyType = 0

Refer:

https://community.sophos.com/kb/en-us/36262

2018年3月18日 星期日

[C#] Telerik RadComboBox 注意事項 problem

當設定 RadComboBox MaxLength=n時,但在 CodeBehide 或是 ASP.NET RadComboBoxItem Text 多加一些前置文字,但Value不會超過MaxLength,Text字數大於MaxLength會導致表單送(POST)不出去。

如有此需求,這最好是改用 ItemTemplate 另外設計新介面,較為恰當。

2018年3月15日 星期四

[C#] SqlDataSource 不允許從資料類型 sql_variant 隱含轉換到 uniqueidentifier。請使用 CONVERT 函數來執行查詢。

在VS2010 Design介面設定SqlDataSource時,勾選從系統產生的預防資料同步修改時,產生的衝突 ASP.NET 代碼,當資料庫欄位為 uniqueidentifier 時,ASP.NET代碼產生:

<asp:Parameter Name="original_gid" Type="Object" />

此會造成

System.Data.SqlClient.SqlException    不允許從資料類型 sql_variant 隱含轉換到 uniqueidentifier。請使用 CONVERT 函數來執行查詢。

此時要把 Type="Object" 刪除,改成如下:

<asp:Parameter Name="original_gid" />

Refer:

http://www.blueshop.com.tw/board/FUM20041006161839LRJ/BRD200710311108001NI.html

https://dotblogs.com.tw/mis2000lab/archive/2010/11/03/uniqueidentifier_sqldatasource.aspx