Profile

Click to view full profile
Hi, I'm Veerapat Sriarunrungrueang, an expert in technology field, especially full stack web development and performance testing.This is my coding diary. I usually develop and keep code snippets or some tricks, and update to this diary when I have time. Nowadays, I've been giving counsel to many well-known firms in Thailand.
view more...

Thursday, February 18, 2016

Conditional Logic in PowerShell


Operator
Description
-eq
Equal to
-lt
Less than
-gt
Greater than
-ge
Greater than or Eqaul to
-le
Less than or equal to
-ne
Not equal to


perator
Description
-not
Not
!
Not
-and
And
-or
Or

Query SQL in Powershell

The following snippet will query data from SQL into DataSet format:

$ServerName = "_ServerName_"
$DatabaseName =
"_DatabaseName_"
$Query =
"SELECT * FROM Table WHERE Column = 'XXX'"
#Timeout parameters
$QueryTimeout =
120
$ConnectionTimeout =
30
#Action of connecting to the Database and executing the query and returning results if there were any.
$conn=
New-Object System.Data.SqlClient.SQLConnection
$ConnectionString =
"Server={0};Database={1};Integrated Security=True;Connect Timeout={2}" -f $ServerName,$DatabaseName,$ConnectionTimeout
$conn.
ConnectionString=$ConnectionString
$conn.
Open()
$cmd=
New-Object system.Data.SqlClient.SqlCommand($Query,$conn)
$cmd.
CommandTimeout=$QueryTimeout
$ds=
New-Object system.Data.DataSet
$da=
New-Object system.Data.SqlClient.SqlDataAdapter($cmd)
[
void]$da.fill($ds)
$conn.
Close()
$ds.
Tables

Sunday, June 14, 2015

Run Unit Test as 64 bit in Visual Studio

Sometime you cannot run unit test because it ask you to run on 64 bit. However, changing debug mode does not help and cause you do not see any unit test methods. In order to make it work, You need to go to Test Settings under Test tab then set Default Processor Architecture.

Tuesday, May 19, 2015

Archeblade Internet Server Configuration

To configure Archeblade server, do the following steps:
  1. by default Archeblade server use 3 ports starting with port 7777. For example, if the textbox in Port Num is 7777, it will use ports 7777-7779.
  2. Firewall: disabled or add Inbound Rules in Advance Firewall settings. Then, allow TDP for ports 7777-7779 and another one for UDP in the same ports.
  3. Configure your router for Port-Forwarding to receive incoming port 7777 to local port 7777 on your specific server ip address for both TCP and UDP.                      
  4. Do step 3 more for port 7778 and 7779.
  5. Done

Wednesday, March 4, 2015

Extract Text from PDF in C#

Hi, long time no see. Currently, I am working as a Consultant at Atos Thailand, so I hardly find a good timing to write an interesting post. For today, I will just paste the link for code snippet to hook up PDF content into text using C#. Take a look at http://www.codeproject.com/Articles/14170/Extract-Text-from-PDF-in-C-NET.

Wednesday, July 9, 2014

Run a set of Visual Studio load tests at once using Command Line

Normally, if you have only one load test environment and have a bunch of load tests that need to run, you need to wait for each test finished then start to run the next test manually.

In order to run them all at one time, we can use Visual Studio Command Prompt to run load tests. But we need to prepare .loadtest files for each load test run separately. It means that if you want to run 15 load tests, you need 15 of .loadtest files.

A command to execute load test has shown as follows:
mstest /TestContainer:[Load Test Name].loadtest /resultsfile:[Load Test Result Location].trx
Then, to run a next load test after another finished, create a command prompt script to run them automatically.

For example - create a loadtest.cmd then add the following lines into the script:
mstest /TestContainer:TestA.loadtest /resultsfile:C:\TestA.trx
mstest /TestContainer:TestB.loadtest /resultsfile:C:\TestB.trx
In case run a distributed load test using test controller and agents from the command-line, it need to add "/testsettings:[Test Setting Name].Testsettings" after specify result file in a command.

For more information about load test, you can take a look at http://msdn.microsoft.com/en-us/library/ms182588(v=vs.110).aspx.

Wednesday, July 2, 2014

Full restore using Windows Server Backup - Network path not found

To full restore from Network drive 1. A user that used to retrieve backup must gain full control all files and folders within that drive. 2. To gain full control, it is not only just gain full control from security tab. It must be included from Advanced menu in security tab then adding / changing an owner, full control permission for all childs, Auditing, and Effective Access to that user. 3. After completed, now, restored machine can full restore from Network drive if everything is done correctly. More information: 1. How to use Windows Server backup http://blogs.technet.com/b/dpm/archive/2011/11/01/data-protection-manager-2010-and-bare-metal-restore.aspx. 2. Resolve Network Path was not found http://blogs.technet.com/b/dpm/archive/2011/11/01/data-protection-manager-2010-and-bare-metal-restore.aspx 3. How to set IP in Command Prompt (during boot) http://www.howtogeek.com/103190/change-your-ip-address-from-the-command-prompt/http://technet.microsoft.com/en-us/library/ee441257(v=ws.10).aspx

Saturday, May 31, 2014

How to setup DLNA media server on Windows 8

You can share media stream over network using Windows Media Player. But it is not available by default. So, in order to enabling this feature, you need to open Windows Media Player and select Stream menu. Then, it will open Media streaming options. So select Turn on media streaming button. You can list which DLNA devices are available on the same network. Select the one you want to share with and then press OK. Note that you also can select specific devices can access only specific folders from your Libraries.

Rename Network in Windows 8

Take a look on:http://superuser.com/questions/550178/how-can-i-rename-a-network-in-windows-8.

Open regedit and edit the following of these registry keys:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Nla\Cache\Intranet
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\Unmanaged

Wednesday, May 7, 2014

Get video thumbnail using MediaPlayer class

Normally, in order to get a thumbnail from a video file we may use well-known software like FFMPEG. But now we can do it natively in C# using MediaPlayer class in WPF (which need to import PresentationCore.dll). We can use the following solution for both web and windows form application as described: Getting Thumbnail from Video using MediaPlayer Class in WPF.