Friday, 6 August 2021

Fix for Wifi Adapter not working - no WiFi

A WiFi Fix Without Rebooting PC

By Strictly Software

I just woke up again on my laptop at 5am, and the keyboard had all changed, I noticed as I went onto YouTube to post a video onto Twitter about the US Government wanting to spy on everyone's text messages and stop any that contain mis-information. 

Now if the US does it then you can be sure the UK GOV will follow as we are already halfway down that slippery wedge towards dystopia. The UK is already becoming a police state using COVID as the cover to implement draconian laws as everyone is worrying about this or that variant and whether or not to get a vaccine just to get a passport that will control your social life, and allow total monitoring of your activities by the Government. 

You can watch the video below about the invasion of US citizens privacy here. What happens in the US usually comes to the UK soon after but when it comes to mass surveillance the NSA like to use GCHQ to test their Prism algorithms and mass home population surveillance techniques out on 1st before using it back home. 

Why? Well because we don't have a real written down constitution or Bill of Rights that protect citizen freedoms is the main reason. The 2nd is our constant desire to be bed buddies with the US, in our "Special Relationship", and keep them sweet by being useful to them, hoping for a share in their data gathering techniques.

I noticed the keyboard change when I went to put a hash tag in and got a | pipe instead and the " quotes were an @ sign. So I did the quick fix I outlined from the other night > "Quick Fix To Keyboard Layout Change"

However I was trying to tweet this out from YouTube to Twitter. Twitters site was up, and I kept pressing "Tweet" but it kept responding with a "There is a problem, try again" message after 20 seconds of non activity.

It was obviously using AJAX as the page didn't refresh, but a quick ping to came back with no server response. It was then I noticed that somehow my WiFi had gone, saying my connection to my router was weak.

Sites that use AJAX for everything, especially posting, should really be able to tell if you are online or not as the reason for a post not appearing

Rather than freaking out someone as the site is still on the screen, and most of the API is in JavaScript so you can still hit buttons and get the impression you are online. There must be a load of ways that after 3 failed post attempts or even 1, that an AJAX API could tell you that you were no longer online in a message.

A method that when you press the button sees if you can remotely access a site that is always up, for instance, would be easy. Then the error message could notify you that you are offline. If they just did a FORM submission when posting Tweets instead of using AJAX you would instantly know anyway from the "No Internet Access" page your web browser would bring up.

So once I had found out that I could not PING Twitter, I checked my Wi-Fi status and it said I had a weak connection to my router. 

Now before I did the keyboard fix, I was online and everything was okay, so I don't know if somehow that quick hot key fix could somehow cause your Wi-Fi adapter to fail, but the two actions seem causally linked. 

So I went to the built in Windows "Troubleshoot Problems" wizard you get when you click on your WiFi symbol in your Desk Tray to run a diagnostic test that clears the DNS, resets your router and adapter and then tries to ping an outside site to see if you have Internet connectivity restored again or a problem accessing the Internet.

I was getting back 3 error messages saying I was offline, my RealTek Wi-Fi adapter was not working, and a default Wi-Fi adapter message, The wizards cure for the problem was to use Ethernet cables but I am not linking loads of cables together just to get round this simple problem.

Usually at first I just try to turn Flight Mode on/off and see if that changes the number of Wi-Fi routers that appear in my list

If it doesn't and I turn Wi-Fi on/off and that still doesn't show my router then one way to fix it is to just log out and log back in again - or reboot if you want to.

However a quicker fix I have found to this commonly occurring RealTek (HP) laptop Wi-Fi adapter problem is to first go to the Device Manager app, under the Windows key, bottom left corner.

I then just go to the Network Adapters section and a load will pop up, if the RealTek Wireless LAN is out of action, usually a red cross will appear next to it. 

In this screenshot I had already fixed it so I wasn't going to try and break it again on purpose just to get a real screenshot. However a red cross next to the adapter having problems is usually the sign you need to double click that adapter and open the menu for it.

I usually try both the "Update Driver Software" and "Scan for hardware changes" options to see which one fixes it but usually one does. It is a lot easier than having to save all your work, remember which files were open, and reboot your laptop.

After fixing the adapter in Device Manager I always run another diagnostic test to ensure there is no other problems but usually my Wi-Fi is instantly restored as the router comes back online and the adapter connects to it.

I always finish off with a quick ping to the site I was on to ensure even though I am online they are too but you can easily skip this step.

And hey ho, I am back online, not banned from Twitter which was on of my 1st thoughts when they couldn't post a Tweet and give me an "offline" status error message. 

However that is the problem with sites that are full of API Jizz, they use it so much they cannot even show you the simplest message at times when all you need to know is that you are offline.

I hope the fix for the keyboard change is not related to the Wi-Fi adapter change but it could be somehow, it's just odd how I was online with a wrong keyboard layout, then I did the quick fix to reset it and then became offline. 

If anyone knows any reason the two might be connected please let me know.


By Strictly Software

© 2021 Strictly Software

Saturday, 24 July 2021

Do Not Be Scared!!!

Main Site And Tools Still Running For Now

By Strictly-Software

Just to let you know that the main site with all the tools such as the:

  • Best JavaScript HTML Encoder & Decoder available, handles double encoding, numeric or entity.
  • Depacking packed code, even if it's been packed multiple times and reformatting it to a readable state.
  • My top WordPress Strictly-AutoTags plugin (Free/Professional), which gives you automated #SEO, deep-linking, and automatic tagging of important words with no 3rd party lookups. No need to check a list of names, if John Smith carries out a wicked crime tonight that is in articles you post automatically then it will find the word and bold it to aid SEO.
  • My top WordPress Strictly-TweetBot plugin, that allows you to tweet to multiple accounts, only if certain words are found in an article OR NOT, using different hash tags made up from either #posttags #categories or #default tags. The professional version has a way of caching the page first before Tweeting so that you are not overwhelmed by any Twitter Rush when you Tweet. Timers can be placed between each Tweet out as well.
  • Lots of free scripts and code that fix holes in frameworks like jQuery.
  • SQL Performance scripts and tuning procedures.
  • Plus lots lots more....
Is still working and you CAN STILL ACCESS IT......

All that has happened is that I can no longer can access the server, due to new security on the site that hosts it. They have added an extra layer of security in which sends an email out to an address I have no access to requesting the code they sent out to be entered on their site to get in. Therefore I cannot get into the servers site, to then use their Java applet to get into the server to add my ever changing IPv4 address to the firewall.

Therefore when you try and go to you will probably see some sort of warning message from your browser like the one shown in the picture below. It will say the site is not secure and hackers maybe trying to steal your data - that is rubbish. 

All that has happened is that due to not being able to renew my SSL certificate, the site is no longer https, no-one is trying to steal your data. I just have not been able to put an SSL on my webserver.

So ignore the message, hit "Advanced", then you should see a "Proceed To Site" link underneath, click that and you can still access the site for now.

Here are two examples, one from Brave/Chrome, the other Opera.

Chrome trying to block access to the site

Opera trying to block access, click the bottom link to get to the site

So no-one is trying to hack you or steal your information, just go to "Advanced" and then click the "Proceed to" link.

All I would suggest is if you are going to buy one of my top WordPress plugins that you do NOT use a PUBLIC WIFI SPOT. 

Do it at home, use a VPN if you can, but do NOT do it at as you are walking down the street being connected and re-connected to various BT public WIFI hotspots

I am sure 99% of them are safe as the users have no technical knowledge to set up their own DNS server and take you somewhere else other than my site, but just to be safe do it at HOME or on a PRIVATE network.

Hope this helps anyone trying to get to the main site.

By Strictly-Software

© 2021 Strictly-Software

Wednesday, 21 July 2021

Making A Super Trim Function

Using Regular Expressions To Make a SuperTrim() Function

By Strictly-Software

How many times has there been when you have two bits of text that you have extracted from various websites, or feeds or even databases and tried to compare them but they would not match?

I know I wrote a little example of when two different ASCII space characters are used within SQL the other day and how to check and remove them to make a match but what about all the various ways you can HTML Encode spaces like     and   plus others that make up a CrLF or just a Cr or Lf, a bit like the VbCrLf constant for a carriage return and line feed, either using Environment.NewLine or constants that hold values for \r \n and also maybe a tab \t.

All these are spaces that need removing and with a special function that uses regular expressions they can all easily be removed .

I use this function in MS SQL with a CLR C# UDF as well as Extending C# projects with a new SuperTrim() method like so:

public static string SuperTrim(this string value)
    string newval = "";

    // match each type of space from start of input up to a word character that may or may not have spaces in between
    // e.g a sentence like Hello There John and then removes the same space characters to the right to the end of sentence.
    string re = @"(^(?: | | |\s|\t|\r|\n)+?)(\w+[\s\S]+?\w+)((?: | | |\s|\t|\r|\n)+?$)";
    Regex regex = new Regex(re, RegexOptions.Compiled | RegexOptions.IgnoreCase);

    newval = regex.Replace(value, ""); // replace each space HTML char with nothing

    return newval;

It is pretty easy enough to create yourself a test page in HTML using JavaScript with a couple of textarea input boxes for the test value containing encoded spaces a button to run a JS function that runs the regex as seen in the C# example and then outputs the result in another box. 

The regular expression is interchangeable between languages, that's what I love about Regular Expressions, they can be tested and played about with on a simple HTML page with JavaScript and then one the expression works you can easily move it into whatever language you are working in e.g C# or PHP.

For example this encoded text:

      Rob Reid       

Then after running the regular expression or string newValue = EncodedValue.SuperTrim() method in C# or JavaScript you should get this value with no encoded characters left.
Rob Reid

I find extending whatever language I am writing in to include a SuperTrim() function very handy. If you were handling URL's you might want to remove %20 and the + sign, you can always add more or less into the expression depending on your needs of course like values for nulls or \v for vertical tabs depending on the content you are handling.

By Strictly-Software

© 2021 Strictly-Software

Thursday, 10 June 2021

Fallen asleep at your laptop and now the keyboard has changed letters?

Fixing Keyboard Letter Changes

By Strictly-Software

If you anything like me then you may often move from room to room just to check on a program's running status or to run a query and then the next thing you know it's 3 hours later and you find that you have been asleep at your desk.

You go to start writing something, maybe a Facebook post with a hash tag but when you hit the hash # key you find that a back slash comes up \ or maybe you go to write an email and when you hit the at sign @ you find that double " quotes come up instead.

The first thing that usually crosses your mind is that the geographic location has changed from UK to US and you delve into Control Panel only to find that everything is still UK based, keyboard layout, special characters, time, the lot.

Well something you should try, and I never knew this until it happened to me tonight was that a common cause of this problem is to have accidentally hit both the SHIFT KEY and the ALT key at the same time.

Try it, go into Notepad or Editplus or any editor, and hit both those keys at the same time then hit @ or " or # etc and see what letter actually appears.

It's an easy fix, but if you don't know the solution and think that it's buried away somewhere in the Control Panel Location Settings somewhere then you could waste a lot of time scratching your head and wondering what went wrong.

So if you ever fall asleep at your desk / laptop like I often do and wake to find the keyboard is all messed up then try the simple fix first, it might save you a lot of time!

By Strictly-Software

© 2021 Strictly-Software

Monday, 7 June 2021

A little piece of SQL and a Regular Expression that saves me a hell of time

Betting, SQL and Regular Expressions

By Strictly-Software

Following on from the previous post, now that I am a professional trader on Betfair, or rather a bettor with some good luck, I managed to pick the 33/1 winner of the Derby out on Saturday somehow, I am always working on my code and my Automatic betting BOT which can TRADE for me on the Betfair Exchange.

However as I also run a Facebook page where I post up free tips from myself, and international tipster friend and other "pro" tipsters > I have to work on my social media quite a lot.

One of the things I had to do every night was get up at 12am to set my BOT running to import the days race cards, runners, prices and related statistics that help my systems pick out horses to bet on, and therefore to post up to tip.

However one of the most annoying jobs I found myself repeating was every night having to go to and the daily race card page, copying out UK and Irish races, reformatting it and then adding it in to one of the 1st posts of the day.

Now I have tweaked the import process so I can import races from tomorrow, or 2 days away whenever I like rather than waiting until midnight just to get the current days races. I can now insert race cards for days ahead whenever I like and just concentrate on the betting and tipping. Running the BOT just to get up to date prices etc.

The post would always start like this....

Monday's racing comes from Gowran Park, Leicester, Lingfield Park, Listowel, Pontefract and Windsor.

Which means re-ordering the copied text into alphabetically listed race courses, adding in the day of the week and of course changing the last course name so it doesn't precede a comma but the word "and x" and have a full stop after it.

Not much work you might think to yourself. Well no not really, fun with refreshing pages that don't have data and are stuck in some cyclical mode, but it can take up to 20 minutes.

Therefore today I wrote a small piece of SQL that can work on any days data already imported to format this sentence correctly. I could have done it without a regular expression but then where would the fun be in that?

So here is the code:
DECLARE @Courses varchar(255),@Message varchar(255), @day varchar(15), @racedate date, @Days int
SELECT	@Days = 0 -- how many days into the future do you want data for - put 0 for today
SELECT  @Racedate = CAST(DATEADD(DAY,@Days,GETDATE()) as DATE) -- convert GETDATE() (todays datetime) into a DATE format
SELECT  @Day = DATENAME(weekday, @Racedate) -- get the current weekday for the date above
SELECT	@Courses = COALESCE(@Courses + ', ',' ') +  CourseName -- build up a CSV of courses
FROM	RACES as ra with (nolock)
JOIN	COURSES as c with (nolock)
	ON	ra.CourseFK=c.CoursePK
WHERE	Abandoned=0
	AND Racedate = @Racedate
GROUP BY CourseName
ORDER BY CourseName 
-- get the last course in the list, I could have used a UDF with comma counting but that would mean replicating the above code, easier in a regex
SELECT @Courses = [dbo].[udf_SQLRegExReplace]('(^[\s\S]+?)(?:, ([^,$]+?$))',@Courses,'$1 and $2')
SELECT @Message = @Day + '''s racing comes from ' + LTRIM(@Courses) + '.'
SELECT @Message

If you want to know what the regular expression below does:
SELECT @Courses = [dbo].[udf_SQLRegExReplace]('(^[\s\S]+?)(?:, ([^,$]+?$))',@Courses,'$1 and $2')

Then watch out for hopefully a soon coming Amazon book I am writing on getting started with regular expressions I know there are loads out there but for me personally I learn by doing things not reading things and this is what customer type the book is aimed at

It gets you writing regular expressions straight away and then working out what they do rather than just listing all the possible flags, identifiers and other boring stuff that a lot of reference books contain.

If you have a quicker RegEx for doing the changing of the last word etc then please post it in the comment section. I am always willing to look at other ways of doing things.

If you are into betting then always check out my facebook page for UK, Irish, French and International tips

By Strictly-Software

© 2021 Strictly-Software

Sunday, 25 April 2021

Solving an issue where you cannot tell the difference between the two conflicting words

Weird Issue - Two Names That Look The Same But Aren't

By Strictly-software 

I have a table of Jockeys that returns me all jockeys from a RACE_RUNNERS table but I had a problem which was I kept getting one jockey returned twice in the output. 

I couldn't work out why this would be, and only for one jockey, and jumped straight to collations. The column collation is set to DB default and when I do a compare using the same collation on each value they still don't match. e.g

-- Column in dbo.RACE_RUNNERS table is 

SELECT CONVERT (varchar, SERVERPROPERTY('collation')) AS 'Server Collation'; 

DB Collation = SQL_Latin1_General_CP1_CI_AS

FROM	dbo.RACE_RUNNERS as run with (nolock)
JOIN	dbo.RACES as r with (nolock)
    ON	r.RacePK = run.RaceFK
WHERE	Jockey IN('Mr P W Mullins','Mr P W Mullins')
	AND Racedatetime > '2021-JAN-01'		
GROUP BY Jockey 
ORDER BY Jockey COLLATE SQL_Latin1_General_CP1_CI_AS

Returns two records for the jockey that look alike
Mr W P Mullins
Mr W P Mullins

-- do some basic comparison tests with each value

IF LTRIM(RTRIM('Mr P W Mullins')) = LTRIM(RTRIM('Mr P W Mullins'))


IF LTRIM(RTRIM('Mr P W Mullins')) COLLATE SQL_Latin1_General_CP1_CI_AS = LTRIM(RTRIM('Mr P W Mullins')) COLLATE SQL_Latin1_General_CP1_CI_AS


So I was slightly confused and thinking about deleting the 2nd record for MR P W MULLINS from the table or changing his name first to the MR P W NULLINS with most results. 

Then it dawned on me. Importing data often leads to characters that you cannot see the difference in but in SQL will appear different. So I did a simple test by removing all spaces in the IF statement comparison e.g
IF 'MrPWMullins' = 'MrPWMullins'

-- And the result was
So I just checked each space character in the two words with ASCII() function and found that the last space between W and Mullins was different from each other.
-- match the space between W and Mullins as it seems to be different
SELECT ASCII(' ') -- CHAR 160 another type of SPACE


Outputting both character numbers with CHAR in a select statement just gave me two columns of spaces. No way to tell the difference by sight, and it only occurred on one jockey for some reason. 

Therefore I did an update on the main RACE_RUNNERS table to replace any CHAR(160) with CHAR(32) for this jockey and might have to put it in the main stored proc that either saves jockeys into the RACE_RUNNER table or just the stat proc.

WHERE	JOCKEY = 'Mr P W Mullins'
Hey presto one instance of the name in the table. A tricky issue that I thought was down to collation but it wasn't. 

The collations of table columns and the DB were the same and doing matches with a specified collation didn't solve the issue. 

Therefore you have to think out of the box and go back to basics and just think what could be different. In this case it was the spaces. Removing them from both words created a MATCH result therefore I knew one space was a different character to the other. 

Here is a link to an ASCII chart if you should ever want to see what character CHAR(N) returns >

Problem solved. 

By Strictly-Software

© 2021 By Strictly-Software

Wednesday, 18 March 2020

MS SQL Collation Issues

Fixing MS SQL Collation Differences

By Strictly-Software

With the quiet due to the COVID19 virus scare, and all major sporting events being cancelled for the foreseen future, I decided now would be a good time to get my old Automatic Betting BOT back up and working.

It used to run on a dedicated Windows 2003 server and MS SQL 2012 database before being outsourced to a French hosting company, OVH, which doesn't allow HTTP connections to online betting sites, basically making it useless. A decision that wasn't mine in anyway, but basically stopped my BOT from working.

It used to run as a Windows Service using Betfair's Exchange API to automatically create betting systems and then place bets based on systems with a rolling ROI > 5% over the last 30 and 100 days.

I am trying to get the BOT working on a local laptop and therefore it had already been backed up, the files FTP'd down to my laptop and restored in a local MS SQL Express database. 

However it seems that I had some issues when I previously attempted this some time ago as the database now had a different collation, a number of tables were now empty and had been scripted across without indexes and there was a collation difference between many columns and the new DB collation.

Just changing the Databases collation over isn't a simple act on it's own if numerous table column collations are different as well, especially those used in Indexes or Primary Keys as those references need to be removed before the collation can be changed.

A simple fix when it's only a small issue with one column might be to just edit the SQL where the issue arises and use a COLLATE statement so that any WHERE clause or JOIN uses the same collation e.g

SELECT  MemberID, MemberName
WHERE MemberName COLLATE SQL_Latin1_General_CP1_CI_AI = @Name

However when you have a large database and the issue is that half your tables are one collation, the other another, and you need to decide which to move to, and then it becomes more difficult.

My new Database was using the newer SQL_Latin1_General_CP1_CI_AI collation whilst a subset of the tables were still using the older collation from the servers copy of the database Latin1_General_CI_AS.

Therefore finding out which columns and tables were using this collation was the first task and can easily be done with a system view with some SQL like so:

-- find out table name and columns using the collation Latin1_General_CI_AS
SELECT table_name, column_name, collation_name
FROM information_schema.columns
WHERE collation_name = 'Latin1_General_CI_AS'
ORDER BY table_name, column_name

From this I could see that the majority of my tables were using the older collation Latin1_General_CI_AS and that it would be easier to change the database collation to this, then the table collation.

However as there were very few indexes or keys I decided to do the reverse and use the newer collation SQL_Latin1_General_CP1_CI_AI, and change all columns using the LATIN to this new version.

However as I want to show you what to do if you need to change your MS SQL database and columns over to a new collation just imagine I am doing the opposite e.g I am changing my whole system from SQL_Latin1_General_CP1_CI_AI to Latin1_General_CI_AS.

If you did want to change the database collation after it had been created it is not as simple as just opening the databases property window and selecting a new collation OR just running the following query to ALTER the database. Just read the error message I was getting when attempting this.

USE master;

COLLATE Latin1_General_CI_AS ;

Msg 5030, Level 16, State 5, Line 18
The database could not be exclusively locked to perform the operation.

Msg 5072, Level 16, State 1, Line 18
ALTER DATABASE failed. The default collation of database 'MyDatabase' cannot be set to Latin1_General_CI_AS.

Apparently this locking issue is due to the fact that SSMS opens a second connection for Intellisense.

Therefore the correct way to do this, even if you are the only person using the database, as I was, is to put it into single user mode, carry out the ALTER statement, then put it back in multi user mode. #

This query does that.




Once the database has been changed to the right collation you will need to change all the tables with columns using the differing collation. However any columns being used in Indexes or Keys will need to have their references removed first. Luckily for me I didn't have many indexes at this point.

However I still needed to script out any Indexes and Key Constraints I had and save them into an SQL file so that they could easily be re-created afterwards.

I then dropped all the Indexes and Keys that needed to be removed and then ran the following piece of SQL which outputs a load of ALTER TABLE statements.

You may find like I did, that you actually need to add a COLLATE statement into the WHERE clause to get it to work without erroring as the system tables themselves may have a different collation than the one you are wanting to search for.

SELECT 'ALTER TABLE ' + quotename( + '.' + quotename( + 
       ' ALTER COLUMN ' + quotename( + ' ' + type_name(c.system_type_id) 
   WHEN c.max_length = -1 THEN '(max)'
   WHEN type_name(c.system_type_id)  = 'nvarchar' THEN '('+CONVERT(varchar(5),c.max_length/2)+')'
   ELSE '('+CONVERT(varchar(5),c.max_length)+')'   
  END + CASE WHEN c.[precision] = 0 THEN ' COLLATE '+c.collation_name   + ' ' ELSE ' ' END + LTRIM(IIF(c.is_nullable = 1, '', 'NOT ') + 'NULL ' )
FROM  sys.objects o
JOIN  sys.columns c ON o.object_id = c.object_id
JOIN  sys.schemas s ON o.schema_id = s.schema_id
WHERE o.type = 'U' 
  AND c.collation_name <> 'Latin1_General_CP1_CI_AI' -- the collation you want to change from
ORDER BY o.[name]

You should get a load of SQL statements that can be run in a new query window to change all your columns.

It is best to run the previous SQL outputting to a textual window so that the output can easily be copied and pasted.

ALTER TABLE [dbo].[CANCEL_KILLED] ALTER COLUMN [RecordDetails] nvarchar(max) COLLATE Latin1_General_CI_AS

Once you have run all these ALTER statements your whole database should be the collation that you require.

You can then take your copy of the Indexes and Keys that you created earlier, and run them to recreate any missing Indexes and Constraints. You should then be able to remove any quick fix WHERE clauses COLLATE statements that you may have used as a quick fix.

Collation differences are a right pain to resolve but if you do everything in order, and keep saved records of ALTER and CREATE statements that you need along the way it can be something fixed without too much work.

There are some large scripts to automate the process of dropping and re-creating objects if you want to use them however I cannot test to the reliability of these as I chose to do everything bit by bit, checking and researching along the way.

By Strictly-Software