Author Archives: Taufiq

AutoHotkey: How to Define 2 Alphabet Keys as Hotkey

AutoHotkey allows user to define a custom combination of two keys (except joystick buttons) by using ampersand (&) between them. As for example:

a & b::MsgBox Hello!!!

Hold down <a> key then press <b> key to trigger the message box.

But by using this way, key <a> will become a prefix key. In other words, it will causes key <a> to lose its original function when it is pressed, i.e. “a” will not appear in text box. To avoid this behaviour, one of the way is to apply the tilde prefix (~) to the key.

For example:

~a & b::MsgBox Hello!!!

Using tilde in front of keys will maintain the native function of the keys used. However, Special hotkeys that are substitutes for alt-tab always ignore the tilde prefix.

 

Source:

Comparison of ReadAllText vs ReadLine vs ReadBlock vs ReadAllLines

When using ReadAllText method to read a log file with a size of 21.83MB, it takes between  7 seconds (for powerful CPU) to 12 seconds (for weak CPU).

 

SOLUTION SOLVED?
  1. I’ve used all possible method for loading .log/.txt extension file type into TextBox in VB.Net, eg. ReadLine, ReadAllLines, ReadAllText, ReadToEnd, but all methods result are the same. But the time load for the .log file is not actually long when execute in my laptop
  2. I think we should just stick with the current code because every solution that i found on the internet using the same all methods that i just mentioned. Probably will take much more longer time if want to solve this problem.
Failed
StreamReader.ReadLine

Source:

Dim file As New FileInfo("path\to\file")

Using reader As StreamReader = file.OpenText()
    While Not reader.EndOfStream
        Dim nextLine As String = reader.ReadLine()
        ProcessLine(nextLine)
    End While
End Using

 

NO

This method generates error maybe because the memory usage increase overtime due to many lines data read
I’m not sure what cause the error but the detail can be found here:
https://docs.microsoft.com/en-us/dotnet/framework/debug-trace-profile/contextswitchdeadlock-mda

Or maybe because i don’t actually know the correct way to use this method

StreamReader.ReadBlock

Source:

Const MAX_BYTES As Integer = 1048576 * 5 '=10 MB 
Dim bytesRead(MAX_BYTES) As Char
Dim numBytesRead As Integer
Dim currentPos As Integer = 0
Dim strFileName As String
Dim strm As System.IO.Stream
Dim TextLine As String
Dim FileDetail As IO.FileInfo

OpenFileDialogMain.ShowDialog()
strm = OpenFileDialogMain.OpenFile()
strFileName = OpenFileDialogMain.FileName.ToString()
  
Using reader As System.IO.TextReader = _
System.IO.File.OpenText(strFileName)
  numBytesRead = _
reader.ReadBlock(bytesRead, currentPos, MAX_BYTES)
  TextLine = reader.ReadLine()
End Using

txtEditor.Text = New String(bytesRead)
txtEditor.Text += TextLine
txtEditor.Text = txtEditor.Text & vbCrLf & Now

 

NO

This method can be used to fetch .log file but a bit slower than ReadAllText() method.

Completion time to load the log file into textbox is approximately 11-12 seconds

File.ReadAllLines

Source:

NO

This method opens a text file, reads all lines of the file into a string array, and then closes the file.

To load the string array into the textbox will use the same method as ReadLine() which is using Looping

 

Test Methodology

 

TEST DELL-E6410 MSI
StreamReader.Readline

How long does it take for Control Panel to load the log file
“X:\Support\Support Cases\264 (I19-2460-MACRO-ASP)\2020_1_14.log”, File size: 21.83MB

No result because of error No result because of error
StreamReader.ReadBlock

How long does it take for Control Panel to load the log file “X:\Support\Support Cases\264 (I19-2460-MACRO-ASP)\2020_1_14.log”, File size: 21.83MB

11-12 seconds 11-12 seconds
File.ReadAllLines

How long does it take for Control Panel to load the log file “X:\Support\Support Cases\264 (I19-2460-MACRO-ASP)\2020_1_14.log”, File size: 21.83MB

No result because of error No result because of error
What is the CPU? Intel(R) Core(TM) i5 CPU M560 @ 2.67GHz Intel(R) Core(TM) i5-4200 CPU @ 2.50GHz
What is the RAM? 4.00 GB (3.43 usable) 8.00 GB

Conclusion: stick with ReadAllText method to read a log file.

Fail to Get MOBITEK S80 to Work in USB port in VirtualBox

This method mentioned in https://www.wintips.org/how-to-setup-usb-on-virtualbox-guest-oracle/  was used to test the USB driver of MOBITEK S80 3G Modem in the virtual machine (Windows Server 2012 64-bit)

After installing Extension Pack in VirtualBox, USB 2.0 and USB 3.0 shown in the USB list

When virtual machine was started, the “Sierra Wireless” device was shown in the list:-

The COM PORT (COM6) appeared in “Device Manager”:-

However, in Hyper Terminal the “AT-OK” test could not be performed because it seems like the Hyper Terminal only catch the physical COM PORT of the MOBITEK S80, but the connection is not actually established with the modem. Nothing can be typed in Hyper Terminal to test the connection.


 

The same problem happens in Linux Mint running in VirtualBox

  • VirtualBox version: 6.1
  • OS in virtual machine: Linux Mint 17 ‘Qiana’ Cinnamon 64-bit

Mobitek S80 that attached to Linux Mint running in VirtualBox can be detected when running the “dmesg | grep tty” command in Linux Mint’s Terminal

But each interface from “ttyUSB0” until “ttyUSB4” which MobitekS80 is attached to cannot be tested with AT command in CuteCom. CuteCom will be frozen when the AT command was entered.

List of Problems with Facebook Page

Problem: If the the post with video attached is edited, even though I did not remove the video, the video will be automatically removed.

Solution: none.


Problem:

  1. The default administrator account has problem with uploading video

    and accessing “Video library”
  2. The above 2 errors occurred when used in:-
    1. Opera browser Version:68.0.3618.125 in Asus laptop
    2. Chrome browser Version 83.0.4103.61 (Official Build) (64-bit) in Asus laptop
    3. Chrome browser Version 81.0.4044.138 (Official Build) (32-bit) in  Dell-E6410 laptop
    4. IE 11 in Asus laptop

 

Solution: add another FB account as “Administrator” and able to solve the above roblem — able to access “Video library” and successfully upload video.

 


(T, please add here …)

How to Automatically Fill-In “Laporan Harian COVID-19”

Note: the report as been moved from http://survey.dosh.gov.my/laporanhariancovid19/ to https://notification.miti.gov.my, we have revised the script to automatically filled in the new report at this new post …

Quick Guide

  1. Install AutoHotkey (AHK).
  2. Select the script “DOSH v. 1.0-demo.ahk”.
  3. Run the script by double clicking on “DOSH v. 1.0-demo.ahk” file.
  4. Go to “Laporan Harian COVID-19”  at http://survey.dosh.gov.my/laporanhariancovid19/
  5. Run the hotkey according to its page number. For example:
    • on page 1, press <CTRL> then <1>, all fields on that page will be automatically filled;
    • on page 2, press <CTRL> then <2>, all fields on that page will be automatically filled;
    • on page 5 (last page), press <CTRL> then <5>, all fields on that page will be automatically filled;
  6. Finally, manually click “Hantar” to submit the report. Refer to video below for a demonstration …

Continue reading

How to Configure TLS 1.2 in Windows Server

  1. Open Windows PowerShell and copy below command into it
    # Create Keys for TLS 1.2 if not exist
    
    new-item -path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols" -Name "TLS 1.2"
    
    new-item -path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2" -Name "Server"
    
    new-item -path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2" -Name "Client"
    
    new-itemproperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" -Name "Enabled" -Value 1
    
    new-itemproperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" -Name "DisabledByDefault" -Value 0
    
    new-itemproperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server" -Name "Enabled" -Value 1
    
    new-itemproperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server" -Name "DisabledByDefault" -Value 0
  2. Reboot server
  3. To check whether TLS 1.2 is configured, open Registry Editor and go to this path:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols

    in this picture, it shows that Windows has “SSL 2.0” and “TLS 1.2” security protocol installed.

(OBSOLETE) Control Panel for MobiGATE SMS Engine — Enterprise Edition version 2.6 is Released

List of  Fixes in Version 2.6

  • Engine cannot start because service is still stopping (after “Stop” button is clicked). CP shows “Stopped” but in fact service is showing “Stopping”;
  • Engine cannot stop because service is still starting (after “Start” button is clicked). CP shows “Started” bt in fact service is showing “Starting”;
  • “Modem Status” is tab “Modem 9 to 16” is not showing colours, it is showing “5” or “0” instead. Happens in MS SQL Server only (does not happen in MySQL);
  • Error message when connecting the “modem.state” table – “Location: CheckModemStatusVersion2_MSSQL Error message: Login failed. The login is from an untrusted domain and cannot be used with Windows authentication”;
  • Error message when connecting the “modem.state” table – “Location: CheckModemStatusVersion2_MSSQL Error message: Login failed. The login is from an untrusted domain and cannot be used with Integrated authentication”;
  • Conversion from string “” to type ‘Double’ is not valid. Caused by null or empty value in “Modem_State.Status”;
  • After stop monitoring, modem ID 9 to 16 still showing modem status.By right, there should be no colour status and should be all grey colour;
  • Set the application to run as administrator automatically.

 

Download

Existing customers of MobiGATE with valid warranty period or with valid annual support programme could download version 2.6 from here … (https://www.mobitek.my/download/MOBITEK%20MOBIGATE/Setup%20–%20Control%20Panel%20v.%202.6.zip)

 

More Information

 

Comparison Between Role of db_owner with Roles of db_datareader & db_datawriter in MS SQL Server

  1. db_owner role should only be given to the administrator who responsible for the database because this role can DROP the database
  2. db_datareader and db_datawriter is the minimum access that should be given to normal user to do the basic SELECT, UPDATE, INSERT and DELETE operation to the database
db_owner
db_datareader
db_datawriter
  1. Can perform all configuration and maintenance activities on the database, and can also drop the database in SQL Server
  2. Normal users should not be a member of this role.
  3. Some applications might require their user account to be a member of this role.
  1. Members of the db_datareader fixed database role can read all data from  all user tables.
  2. The db_datareader role gives implicit access to SELECT against all tables and views in a database.
  1. Members of the db_datawriter fixed database role can add, delete, or change data in all user tables.
  2. The db_datawriter role gives implicit access to INSERT, UPDATE, and DELETE against all tables and views in a database.

Source:

  1. https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/database-level-roles?view=sql-server-ver15
  2. https://www.mssqltips.com/sqlservertip/1900/understanding-sql-server-fixed-database-roles/

How to Configure MS SQL Server Express to Use Windows Authentication

  1. Create an user account on the computer that act as a server, the username and password must used exactly like the account used in client computer
  2. In SQL Server Management Studio:
    • Expand “Security” -> expand “Logins” -> “New Login
    • Click “General” -> select “Windows authentication” -> click “Search”
    • Type the account name that has been created on server computer, click “Check Names
    • Alternatively you can do this step by clicking “Advanced” button -> “Find Now” -> find the account name in the search results -> click “OK

    • Click “Server Roles” -> check for sysadmin
    • Click “User Mapping” -> choose database -> check for db_datareader and db_datawriter

Note: You do not need to enter the password as SQL Server will ask Windows to validate the user password. (source: https://www.virtual-dba.com/differences-windows-sql-server-authentication/)

How to View the Log of MS SQL Server Express to Check for Login Status

  1. You can choose what type of login activity that you want the SQL Server to log. By default, SQL Server will log the “Failed logins only” activity only. To choose the login activity, right-click at your “Server <instance name>” -> “Properties”. In Server Properties, click “Security” and choose the activity in Login auditing area:
    • None
    • Failed logins only
    • Successful logins only
    • Both failed and successful logins
  2. To view the MS SQL Server log files, expand “Management” -> expand “SQL Server Logs“, click any log date that you want to view:
  3. All the login activities can be viewed in the Log file summary area: