Thursday, April 9, 2020

Parse URL in SQL

I searched a lot, and I did not like anything I found. Then I saw this on sql-server-helper.com That site looks a little odd, I thought I would save this for myself, in case the site goes away, like some I used before stackoverflow.
CREATE FUNCTION [dbo].[ParseURLQueryString]
( @QueryString AS VARCHAR(MAX) )
RETURNS @QueryStringTable TABLE
( [Key] VARCHAR(100), [Value] VARCHAR(1000) )
AS
BEGIN
DECLARE @QueryStringPair VARCHAR(2000)
DECLARE @Key VARCHAR(100)
DECLARE @Value VARCHAR(1000)

WHILE LEN(@QueryString) > 0
BEGIN
SET @QueryStringPair = LEFT ( @QueryString, ISNULL(NULLIF(CHARINDEX('&', @QueryString) - 1, -1),
LEN(@QueryString)))
SET @QueryString = SUBSTRING( @QueryString, ISNULL(NULLIF(CHARINDEX('&', @QueryString), 0),
LEN(@QueryString)) + 1, LEN(@QueryString))

SET @Key = LEFT (@QueryStringPair, ISNULL(NULLIF(CHARINDEX('=', @QueryStringPair) - 1, -1),
LEN(@QueryStringPair)))
SET @Value = SUBSTRING( @QueryStringPair, ISNULL(NULLIF(CHARINDEX('=', @QueryStringPair), 0),
LEN(@QueryStringPair)) + 1, LEN(@QueryStringPair))

INSERT INTO @QueryStringTable ( [Key], [Value] )
VALUES ( @Key, @Value )
END

RETURN
END

And this is how you use it
SELECT * FROM [dbo].[ParseURLQueryString] ( 'fname=Barack&lname=Obama&addr=1600 Pennsylvania Ave NW&city=Washington&st=DC&zip=20500' )

Wednesday, February 26, 2020

WiX undefined preprocessor variable

Not sure how many people will see my small blog, but here I go, maybe it helps someone.

I recently had this WiX undefined preprocessor variable issue.

The actual variable was the same old $(var.MyProject.TargetDir)

After looking through the whole internet and not finding anything, the fix was a simple one.

The "MyProject" HAS TO BE EXACTLY THE SAME NAME as the web project that I added as a reference to the Wix project.
So if your project is called WhatewerWebAll, then you have to have something like:


You can say what you want, but the "undefined preprocessor variable $(var.MyProject.TargetDir)" message is actually not really describing the real issue, but maybe that's just me.

Wednesday, January 15, 2020

Sony Android TV Bluetooth headset issue a2dp

From what I understand after investigating this issue, this happens with multiple TV types from Sony.

I got a new TV, Sony BRAVIA, 49XG8096, 4K Ultra HD.
The TV is cool, no issues with it at all.

My plan was to connect it with a Bluetooth headset too, so I can watch a movie without wires, even if my wife is sleeping next to me.

I first bought a JBL Tune 500 headset, just because that was on stock, and could not lose time searching for anything else. The headset was working fine, connecting with anything, but I couldn't get it to connect to the TV at all.
I looked up this issue and saw that there is a list of headphones that are on an Official list from Sony. I can't say I was happy, but I went back to the store, and changed the headphones to a Sony this time, model WH-CH500B.

According to the list, it should have worked.
Well, it didn't.

I investigated some more, and I found out that this is might be a software issue, with a very easy fix.
I went to the TV's Play Store, searched for Bluetooth, and installed the first 3rd party app that I found. The app connected the Sony Headset to the Sony TV in less then 5 seconds.

After this, I can just go to the TV settings, and the WH-CH500B is listed as paired, I can easily turn it on or off.

I am thinking that the JBL might have been working too if I used an app like this.

I am not sure why Sony cannot do this themselves, but I don't care anymore.

Friday, December 15, 2017

SQL - update column with sequence number starting from 1


DECLARE @id INT;
SET @id = 0
UPDATE x SET @id = [ItemNo] = @id + 1

Thursday, October 12, 2017

Find position of object in the screen

Tested it, it works pretty nice in FF, Chrome, IE, Safari too.
function resetPosition(object, args) {
/* find the textbox object */
var tb = object._element;
/* measure textbox height */
var tbheight = tb.offsetHeight;
/* find textbox in the page */
var rect = tb.getBoundingClientRect();
var divleft = Math.floor(rect.left);
var divtop = Math.floor(rect.top + tbheight);
/* find the auto complete extender div in the page */
var ex = object._completionListElement;
/* move the ace to the right position */
if (ex)
$common.setLocation(ex, new Sys.UI.Point(divleft, divtop));
}

Monday, May 15, 2017

Whatsapp issues

Android connection issues for whatsapp, gmail, or whatever.
Go to settings - connection - more networks - mobile networks - access point names
I had to swith it from wap to net to make it work.

Monday, September 26, 2016

Wix heat command exited with code 319 (-out parameter must specify a file path)


  • The '-out' or '-o' parameter must specify a file path. File: heat.exe
  • The command " "C:\Program Files (x86)\WiX Toolset v3.7\bin\heat.exe" project "..\Web \" -gg -g1 -cg PACKAGEFILES sreg -dr DEPLOYFOLDER -out "C:\Users(...)\Server\Wix\Frags.wxs" " exited with code 319. File: C:\Users(...)\Server\Wix\Wix.wixproj


This was really not a lot of information for me to use.
What I fount out, is that Wix is throwing this error on anything. I will explain.

So this was my code:

"$(WIX)bin\heat.exe" dir "$(vm4heat)" -cg vm4heat -gg -scom -sreg -sfrag -srd -out "$(ProjectDir)\FilesFragment.wxs"

And as you can see, I have 3 different paths in my code.
The error message says that the issue is on the "out".
Well, the actual error was on the "dir".

So in case you ever get this error, don't look for wrong doing in the "out" parameter only. Check EVERY path, one by one. In my case it was an extra backslash at the end of the "dir" parameter.

Hope this helps.