Friday, March 27, 2020

SQL Server - SMSS - Solution to .bak file not visible in any other directory in SSMS

Try to restore a database in SQL Server 2012 R2 (but this does not matter), and ran into same old issue of not being able to find a SQL Server backup (.bak) in a directory, that was not the default (C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup) directory for back-up files. 

In my example, the .bak file was in C:\build

Of course it's a permissions on the file right? 
So launch SQL Server Configuration Manager (SSCM) to get the account that SLQ Server is running under and copy the Account Name.
In this case, copy Account Name which is  "NT Service\MSSQL$SQLENT2012"
Adding the service account is not as straightforward.

  1. Log into the server. (The change must be made on the actual server, not through a network share.)
  2. Change the Locations to the local server name, not an Active Directory account. 
  3. Paste in NT Service\MSSQL$SQLENT2012 in the name box. (Do not click Check Names)
  4. Click OK. You will then see a list of the matching service accounts. Select MSSQLSERVER, and click OK to accept the selection.

  5. Which then looks like the following when done. Success right?

  6. Open the directory in SQL Server Management Studio (SSMS) what blank ?

  7. What if I just copy the file to default directory C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup

  8. Check permission of this file in default. They are the same!

  9. Then it dawned on me,  the directory C:\build does not have any permissions assigned to "NT Service\MSSQL$SQLENT2012".


    It's a file and FOLDER permission issue. All solutions I have seen on Stack Overflow/Exchange forget the fact if you have a existing folder you have to apply the service account of SQL Server (use SSCM to find) to each FOLDER in the full path.

    So you have to the cascade the account user and set permissions down each directory ;) as well.

Thursday, March 26, 2020

WordPress Some URL parameters are empty on POST or GET

How to fix empty URL Parameters on Post or Get in WordPress

Parsing URL parameters in WordPress and they are appearing empty it's most likely an issue with your .htaccess file.

Start with default WordPress .htaccess file from

Add the following line  RewriteRule "/users/([0-9]+)/?" "/users?page=$1" [QSA]

# BEGIN WordPress

RewriteEngine On
RewriteBase /

RewriteRule "/users/([0-9]+)/?" "/users?page=$1" [QSA]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

The key to this fix is the QSA flags, see below for full explaination. 

Understand Apache RewriteRule Flags -


When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined.
Consider the following rule:
RewriteRule "/users/([0-9]+)/?" "/users?page=$1" [QSA]
With the [QSA] flag, a request for /users/123/?fullprofile=true will be mapped to /users?page=123&fullprofile=true
Without the [QSA] flag, that same request will be mapped to /users/123/?fullprofile=true - that is, the existing query string will be discarded.

Friday, March 20, 2020

Linux maintains bugs

In many operating systems, there are two parts - the userland (user space) and kernel space. In Linux, the userland is GNU. Applications reside in the userland while the Linux kernel (and most drivers) reside in the kernel space. GNU is an open-source userland that contains many applications and utilities. The GNU Project is a programming collaboration for the GNU userland and related GNU software. 

As this post* points out, these two can get out of sync very quickly and you have breaking dependencies, which restrict kernel bugs from being fixed.


On Linux, because the kernel and the rest of the operating system are not developed in tandem, this means updating or fixing a kernel struct would almost guarantee to break a downstream application. The only to prevent this would be to conduct regular massively coordinated updates to system utilities when the kernel changes, and properly version applications for specific kernel releases. Quite a herculean endeavor. This also explains why systemtap, one of Linux’s many answers to dtrace(1), does not work on Ubuntu.
Also, Linux can never have an equivalent of a lib80211(3) because there is no single standard library set. Even for the standard C library set, Linux has Glibc, uClibC, Dietlibc, Bionic and Musl. Rather than guessing the underlying C library implementation or falling into “dependency hell“, applications default to the most low-level implementation or their requested functionality. Some tools, such as ifconfig(8), resort to just reading from the /proc filesystem.
Linux’s solution to this problem was to create a policy of never breaking userland applications. This means userland interfaces to the Linux kernel never change under any circumstances, even if they malfunction and have known bugs. That is worth reiterating. Linux maintains known bugs – and actively refuses to fix them. In fact, if you attempt to fix them, Linus will curse at you, as manifest by this email (see below).

In Linus Torvalds own words -
SubjectRe: [Regression w/ patch] Media commit causes user space to misbahave (was: Re: Linux 3.8-rc1)
It's a bug alright - in the kernel. How long have you been a maintainer? And you *still* haven't learnt the first rule of kernel maintenance? If a change results in user programs breaking, it's a bug in the kernel. We never EVER blame the user programs. How hard can this be to understand?

Thursday, March 19, 2020

Wordpress - Searching all concatenated (extra) metadata fields requires bigger group_concat_max_len setting

Sometimes in Wordpress you have to extend a search to extra meta fields, but under the hood it's a little more complicated. One way is to concatenate all user fields into 1 long string to efficiently search. 

But if you're not careful, and depending on the number of additional fields added this will fail.

SET SESSION group_concat_max_len = 1048576;
    t1.user_nicename, ' ', t1.user_email, 
    ' ', t1.user_url, ' ', t1.display_name
  ) as WPUsersFields 
  wp_users as t1

Here's how to extend the mySQL group_concat_max_len size so that Concat can search all the bytes in the concatenated fields, in this case WPUsersFields. 

1048576 represents 1Mb of searchable text

This is useful if you have a huge user profile that you have to search. Below $wpdb will execute 2 mySQL statements at the same time.

Here's the code

 global $wpdb;
        $wpdb->query('SET SESSION group_concat_max_len = 1048576;'); //
 $SQL = "SELECT DISTINCT t1.ID AS ID, CONCAT(  t1.user_nicename, ' ', t1.user_email,   ' ', t1.user_url, ' ', t1.display_name ) as WPUsersFields FROM wp_users as t1";

 $result = $wpdb->get_results($SQL);

Thursday, March 12, 2020

How to remove problem, stuck or hidden software window using a free Microsoft tool

Here's how to remove problem or stuck software that does not appear in the "Add remove programs" window using a free Microsoft tool.

Microsoft has officially created tool to fix issues with software that does not appear and is blocked or difficult to remove. 

That tool is called the "Program Install and Uninstall" troubleshooter available here.

Or click Download to get the troubleshooter now.

If you see the File Download box when you start downloading, select Run or Open.
  1. In the Downloads folder, you see a file called
  2. Right-click and "Send to" choose Desktop - to create a shortcut on Desktop to run again.
  3. Double click to run.
  4. You'll have an option to troubleshoot install or uninstall software

  5. Choosing Uninstalling, you see a list of programs to uninstall including hidden ones. Select and hit Next button.

  6. Choose Yes try uninstall.

    (Try other fixes leads you to
    Control Panel->All Control Panel Items->Troubleshooting->Additional Information).

  7. Wait screen, this make take some time 15mins so far

  8. Detection Additional problems, 10 mins later

  9. Done. Program removed.

What it fixes

The troubleshooter helps fix problems that:
  • Corrupt registry keys on 64-bit operating systems.
  • Corrupt registry keys that control the update data.
  • Prevent new programs from being installed.
  • Prevent existing programs from being completely uninstalled or updated.
  • Block you from uninstalling a program through Add or Remove Programs (or Programs and Features) in Control Panel.
  • For example, solves uninstalling Microsoft Security Essentials but look for "Microsoft Security Client" to remove
If you're trying to remove malware, you can use Windows Security (or another antivirus tool), or you can use the Windows Malicious Software Removal tool.

Friday, March 6, 2020

Visual Studio (VS) Code - How to view Tabs (tab characters) in a file

To view Tab characters in a current file in VS Code, as in image above.
  1. Choose View->Render Whitespace 

Tab character by default are replaced by 4 spaces in Visual Studio Code. 

To make VS Code use Tabs instead of default spaces.
  1. Choose File->Preference->Settings.
  2. Search for "Tab" and a list options will include Insert Space and others
  3. Uncheck Insert Space

  4. Check your file, Tab character will be displayed as →   (right arrow).
Note for some files this maybe overwritten by Detect Indentation setting. Unchecked to disable.

Related Posts

Visual Studio (VS) Code - How to View Control Characters SOH, STX, ETX, etc

Thursday, March 5, 2020

Visual Studio (VS) Code - How to View Control Characters SOH, STX, ETX, etc

1. Firstly to view control characters in Visual Studio Code 1.41.1, choose View→Render Control Characters→Render Whitespace (shows Tabs also), as in image below. 

2. Copy all the text in the below Cached Result window, starting with line 'List of Unicode Control Characters'.

This list begins with the first letter character in ASCII, which in Unicode format is expressed as \u0000 (hex value 00) and is referred to as null character. 

3. Paste this list into Visual Studio Code, to give you an example of how control characters will appear.

4. Match \u0001 to 01 in the Hex column in the tables below, to identify control character.
Visual Studio Code 1.41.1 renders control characters that will that will match Acronym  column the Standard ASCII Control Characters table below such as SOHSTXETXEOTBS, etc. 
For values greater than \u007F which are represented in the Unicode Control Characters table, renderd control characters do not match Acronym  column.
Warning: BOM markers (special control characters at start of file are NOT shown), but indicated by file encoding type. PHP files do not work with "UTF-8 with BOM" encoded files! 

Tab Character Replacement in VS Code

Tab character below (line 10) in image has been replaced by 4 spaces, as per Visual Studio Code 1.41.1 settings. Choose File->Preference->Settings.

If you deselect this, as in image below, then Tab (\u0009) character is displayed as →   (right arrow).

Quick Tip \u0001 is equal to 01 hex or acronym (SOHin the Hex column the table below.

Standard ASCII Control Characters
Hex Acronym Name C Description
00 NUL Null \0 Originally used to allow gaps to be left on paper tape for edits. Later used for padding after a code that might take a terminal some time to process (e.g. a carriage return or line feed on a printing terminal). Now often used as a string terminator, especially in the programming language C.
01 SOH Start of Heading First character of a message header. In Hadoop, it is often used as a field separator.
02 STX Start of Text First character of message text, and may be used to terminate the message heading.
03 ETX End of Text Often used as a "break" character (Ctrl-C) to interrupt or terminate a program or process.
04 EOT End of Transmission Often used on Unix to indicate end-of-file on a terminal.
05 ENQ Enquiry Signal intended to trigger a response at the receiving end, to see if it is still present.
06 ACK Acknowledge Response to an ENQ, or an indication of successful receipt of a message.
07 BEL Bell, Alert \a Originally used to sound a bell on the terminal. Later used for a beep on systems that didn't have a physical bell. May also quickly turn on and off inverse video (a visual bell).
08 BS Backspace \b Move the cursor one position leftwards. On input, this may delete the character to the left of the cursor. On output, where in early computer technology a character once printed could not be erased, the backspace was sometimes used to generate accented characters in ASCII. For example, à could be produced using the three character sequence a BS ` (or, using the characters’ hex values, 0x61 0x08 0x60). This usage is now deprecated and generally not supported. To provide disambiguation between the two potential uses of backspace, the cancel character control code was made part of the standard C1 control set.
09 HT Character Tabulation, Horizontal Tabulation \t Position to the next character tab stop.
0A LF Line Feed \n On typewritersprinters, and some terminal emulators, moves the cursor down one row without affecting its column position. On Unix, used to mark end-of-line. In DOSWindows, and various network standards, LF is used following CR as part of the end-of-line mark.
0B VT Line Tabulation, Vertical Tabulation \v Position the form at the next line tab stop.
0C FF Form Feed \f On printers, load the next page. Treated as whitespace in many programming languages, and may be used to separate logical divisions in code. In some terminal emulators, it clears the screen. It still appears in some common plain text files as a page break character, such as the RFCs published by IETF.
0D CR Carriage Return \r Originally used to move the cursor to column zero while staying on the same line. On classic Mac OS (pre-Mac OS X), as well as in earlier systems such as the Apple II and Commodore 64, used to mark end-of-line. In DOSWindows, and various network standards, it is used preceding LF as part of the end-of-line mark. The Enter or Return key on a keyboard will send this character, but it may be converted to a different end-of-line sequence by a terminal program.
0E SO Shift Out Switch to an alternative character set.
0F SI Shift In Return to regular character set after Shift Out.
10 DLE Data Link Escape Cause the following octets to be interpreted as raw data, not as control codes or graphic characters. Returning to normal usage would be implementation dependent.
11 DC1 Device Control One (XON) These four control codes are reserved for device control, with the interpretation dependent upon the device to which they were connected. DC1 and DC2 were intended primarily to indicate activating a device while DC3 and DC4 were intended primarily to indicate pausing or turning off a device. DC1 and DC3 (known also as XON and XOFF respectively in this usage) originated as the "start and stop remote paper-tape-reader" functions in ASCII Telex networks. This teleprinter usage became the de facto standard for software flow control.[6]
12 DC2 Device Control Two
13 DC3 Device Control Three (XOFF)
14 DC4 Device Control Four
15 NAK Negative Acknowledge Sent by a station as a negative response to the station with which the connection has been set up. In binary synchronous communication protocol, the NAK is used to indicate that an error was detected in the previously received block and that the receiver is ready to accept retransmission of that block. In multipoint systems, the NAK is used as the not-ready reply to a poll.
16 SYN Synchronous Idle Used in synchronous transmission systems to provide a signal from which synchronous correction may be achieved between data terminal equipment, particularly when no other character is being transmitted.
17 ETB End of Transmission Block Indicates the end of a transmission block of data when data are divided into such blocks for transmission purposes.
18 CAN Cancel Indicates that the data preceding it are in error or are to be disregarded.
19 EM End of medium Intended as means of indicating on paper or magnetic tapes that the end of the usable portion of the tape had been reached.
1A SUB Substitute Originally intended for use as a transmission control character to indicate that garbled or invalid characters had been received. It has often been put to use for other purposes when the in-band signaling of errors it provides is unneeded, especially where robust methods of error detection and correction are used, or where errors are expected to be rare enough to make using the character for other purposes advisable. In DOSWindows and other CP/M derivatives, it is used to indicate the end of file, both when typing on the terminal, and sometimes in text files stored on disk.
1B ESC Escape \e[b] The Esc key on the keyboard will cause this character to be sent on most systems. It can be used in software user interfaces to exit from a screen, menu, or mode, or in device-control protocols (e.g., printers and terminals) to signal that what follows is a special command sequence rather than normal text. In systems based on ISO/IEC 2022, even if another set of C0 control codes are used, this octet is required to always represent the escape character.
1C FS File Separator Can be used as delimiters to mark fields of data structures. If used for hierarchical levels, US is the lowest level (dividing plain-text data items), while RS, GS, and FS are of increasing level to divide groups made up of items of the level beneath it.
1D GS Group Separator
1E RS Record Separator
1F US Unit Separator
Unicode Control Characters
Hex Acro Name Description
7F DEL Delete Character In computing, the delete character (sometimes also called rubout) is the last character in the ASCII repertoire, with the code 127 (decimal). Not a graphic character but a control character, it is denoted as ^? in caret notation and has a graphic representation of ␡ in Unicode (as all ASCII control characters have graphic representations).A key marked Backspace ← that sends the Backspace character is by far the most common on modern terminals and emulators. Due to the "backspace" key sending Delete on many terminals, keys marked "Delete" typically do not send the character, instead sending an Escape sequence similar to the arrow keys.[6]
80 PAD Padding Character Not part of ISO/IEC 6429 (ECMA-48). In early drafts of ISO 10646, was used as part of a proposed mechanism to encode non-ASCII characters. This use was removed in later drafts.[2][7] Is nonetheless used by the internal-use two-byte fixed-length form of the ISO-2022-based Extended Unix Code (EUC) for left-padding single byte characters in code sets 1 and 3, whereas NUL serves the same function for code sets 0 and 2. This is not done in the usual "packed" EUC format.[8]
81 HOP High Octet Preset Not part of ISO/IEC 6429 (ECMA-48). In early drafts of ISO 10646, was intended as a means of introducing a sequence of ISO 2022 compliant multiple byte characters with the same first byte without repeating said first byte, thus reducing length; this behaviour was never part of a standard or published implementation. Its name was nonetheless retained as a RFC 1345 standard code-point name.[2][7]
82 BPH Break Permitted Here Follows a graphic character where a line break is permitted. Roughly equivalent to a soft hyphen except that the means for indicating a line break is not necessarily a hyphen. Not part of the first edition of ISO/IEC 6429.[9] See also zero-width space.
83 NBH No Break Here Follows the graphic character that is not to be broken. Not part of the first edition of ISO/IEC 6429.[9] See also word joiner.
84 IND Index Move the active position one line down, to eliminate ambiguity about the meaning of LF. Deprecated in 1988 and withdrawn in 1992 from ISO/IEC 6429 (1986 and 1991 respectively for ECMA-48).
85 NEL Next Line Equivalent to CR+LF. Used to mark end-of-line on some IBM mainframes.
86 SSA Start of Selected Area Used by block-oriented terminals.
87 ESA End of Selected Area
88 HTS Character Tabulation Set
Horizontal Tabulation Set
Causes a character tabulation stop to be set at the active position.
89 HTJ Character Tabulation With Justification
Horizontal Tabulation With Justification
Similar to Character Tabulation, except that instead of spaces or lines being placed after the preceding characters until the next tab stop is reached, the spaces or lines are placed preceding the active field so that preceding graphic character is placed just before the next tab stop.
8A VTS Line Tabulation Set
Vertical Tabulation Set
Causes a line tabulation stop to be set at the active position.
8B PLD Partial Line Forward
Partial Line Down
Used to produce subscripts and superscripts in ISO/IEC 6429, e.g., in a printer.
Subscripts use PLD text PLU while superscripts use PLU text PLD.
8C PLU Partial Line Backward
Partial Line Up
8D RI Reverse Line Feed
Reverse Index
8E SS2 Single-Shift 2 Next character invokes a graphic character from the G2 or G3 graphic sets respectively. In systems that conform to ISO/IEC 4873 (ECMA-43), even if a C1 set other than the default is used, these two octets may only be used for this purpose.
8F SS3 Single-Shift 3
90 DCS Device Control String Followed by a string of printable characters (0x20 through 0x7E) and format effectors (0x08 through 0x0D), terminated by ST (0x9C).
91 PU1 Private Use 1 Reserved for a function without standardized meaning for private use as required, subject to the prior agreement of the sender and the recipient of the data.
92 PU2 Private Use 2
93 STS Set Transmit State
94 CCH Cancel character Destructive backspace, intended to eliminate ambiguity about meaning of BS.
95 MW Message Waiting
96 SPA Start of Protected Area Used by block-oriented terminals.
97 EPA End of Protected Area
98 SOS Start of String Followed by a control string terminated by ST (0x9C) that may contain any character except SOS or ST. Not part of the first edition of ISO/IEC 6429.[9]
99 SGCI Single Graphic Character Introducer Not part of ISO/IEC 6429. In early drafts of ISO 10646, was used to encode a single multiple-byte character without switching out of a HOP mode. In later drafts, this facility was removed, the name was nonetheless retained as a RFC 1345 standard code-point name.[2][7]
9A SCI Single Character Introducer To be followed by a single printable character (0x20 through 0x7E) or format effector (0x08 through 0x0D). The intent was to provide a means by which a control function or a graphic character that would be available regardless of which graphic or control sets were in use could be defined. Definitions of what the following byte would invoke was never implemented in an international standard. Not part of the first edition of ISO/IEC 6429.[9]
9B CSI Control Sequence Introducer Used to introduce control sequences that take parameters.
9C ST String Terminator
9D OSC Operating System Command Followed by a string of printable characters (0x20 through 0x7E) and format effectors (0x08 through 0x0D), terminated by ST (0x9C). These three control codes were intended for use to allow in-band signaling of protocol information, but are rarely used for that purpose.
9E PM Privacy Message
9F APC Application Program Command