Showing posts with label AJAX. Show all posts
Showing posts with label AJAX. Show all posts

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 Twitter.com 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.

Thanks.....

By Strictly Software

© 2021 Strictly Software

Monday, 15 January 2018

Quickly Grab Generated Source Code With One Click

Quickly Grab Generated Source Code With One Click


By Strictly-Software

Now that my broken arm is getting better I will be doing more code. It still hurts like mad though, the arm bone didn't even look like it belonged anywhere near the shoulder where it was dislocated.

If you want WordPress plugins then go and check out the main site which I need to do some work on. I am also thinking of building an alternative search engine to get round Google's/CIA/NSA's de-ranking and demonetisation.

I used to have a Super Search Engine years ago, that took the top 10 items from Google, BING and Yahoo, however they kept changing the source code until it all became AJAX loaded in on the fly and too hard to scrape.

I think with the push or deletion of alternative news down the rankings, and pro-establishment news gaining viewers they would never had got a year ago due to Facebook's subservience to the USA and Israeli governments. More and more people will move to new decentralised social media platforms and once that happens Facebook and Google, who are already losing out to duckduckgo.com  due to privacy concerns will lose money in their share price as well as many members.                                 

The problem is money of course and too few people click on adverts or donate out the kindness of their heart.

I think, like search.darkpolitriks.com, that has a starting page of core main #altnews websites and podcasts, I could write my own one and charge £10 for a relevant #altnews blog or channel to be added to the SERP, just so that small alternative sites have the same chance of being found in results and sites like CNN and the BBC are weeded out.

Easiest way of creating a SERP. Just ensure the site is relevant and not mainstream.

Anyway I was fixing a bug today when I realised that it was a bookmark with an http source on an https site that prevented the lock from showing.

Sometimes I don't think people realise how dangerous loading third party scripts can be.

Just loading in a CSS stylesheet could cause nightmares.

For example say your site loaded in a stylesheet from www.SomeSiteIDontControl1.com which loads in a background PNG image which in turn loads in another remote 3rd party stylesheet from www.SomeSiteIDontControl2.com.

Then one day the person in control of that site changes that 2nd image to a dangerous .js file or .exe that loads in an XSS attack.

You are so far removed from the actual cause of the problem that with minification and compression you might have no hope in finding the dangerous file.

So one day the 2nd CSS file that you are loading looks something like this:


background:url(http://www.somesiteIdontcontrol2.com/images/background.png) no-repeat 16px 0;


Then one day this site owner changes his background image to be an .js file e.g


background:url(http://www.somesiteIdontcontrol2.com/images/dodgyscript.js) no-repeat 16px 0;


And when the page loads, and after your onDOMLoad event loads in these scripts it hits your user with the JavaScript sites code.

A recursive script might be handy to run every day to check diagnostics by referencing every URL it finds in any style-sheet or JavaScript on your site.

Follow it backwards and check every other URL it finds.

Another way, if you are perfectly happy with your code is to create local versions of the files and images and keep it all on a server you control so no-one could malform the objects being loaded.

This is a bookmarklet script I wrote years ago that shows me the DOM loaded afterwards and not before.

I wanted to see what scripts and files had been added since I pressed the View Source button that shows the HTML and JS/CSS before any code is run on the page.

I use it all the time. I created a bookmarklet and added it to my bookmark bar so it's within easy reach with a URL to www.google.com and save it.

I then edit it and change the location of the JavaScript I want from www.google.com to the code so that it runs. This might not be necessary anymore but I had add a real URL in the old days.

This code basically takes a snapshot of the DOM once all 3rd party objects have modified the code, loaded videos, changed images and anything else sites like to do when onDOMLoad (not onWindowLoad, which only fires once every image and external object has been loaded.

As you are loading the code with a press of a button there is plenty of time for the onDOM onWindow and onFrame load events to fire, plus many others.


javascript:(function()%7b function htmlEscape(s)%7bs=s.replace(/&/g,'&amp;');s=s.replace(/>/g,'&gt;');s=s.replace(/</g,'&lt;');return s;%7d x=window.open(); x.document.write('<pre>' + htmlEscape('<html>\n' + document.documentElement.innerHTML + '\n</html>')); x.document.close(); %7d)();


As the HTML 5 spec still allows for href="javascript: ..... " then a link or button can run JavaScript when it really should be running external document.addEventListener events to each object needing code to fire when hit.

The code just creates a URL encoded function called htmlEscape which replaces brackets and ampersands and opens a new window writing this new code out into the document.documentElement.innerHTML.

Not hard to do but very useful.


By Strictly-Software

© 2018 Strictly-Software

Monday, 9 February 2015

Speeding up Chrome can KILL IT!

Speeding up Chrome can kill it!

By Strictly-Software

Lately I have been really disappointed with the performance of my preferred browser Chrome.

I moved from FireFox to Chrome when the amount of plugins on FireFox made it too slow to work with however this was when Chrome was a clean, fast browser. Now it has just as many plugins available to install as FireFox and the performance has deteriorated constantly over the past few versions.

I am a developer so having 20+ tabs open in my browser is not unusual however when they are all hanging for no reason with "resolving host" messages in the status bar something is wrong.

I have even removed all my plugins that I had installed and decided to leave that to FireFox if I need to test different agents, hacking and so on. However even with a simple install the performance has been crap lately!

Therefore looked up on the web for tips on speeding up Chrome and found this article:

http://digiwonk.wonderhowto.com/how-to/10-speed-hacks-thatll-make-google-chrome-blazing-fast-your-computer-0155989/

It basically tells you some tricks to speed up Chrome by modifying some settings by going to chrome://flags/ in your address bar.

There is a warning at the top of the page that says:

WARNING These experimental features may change, break or disappear at any time. We make absolutely no guarantees about what may happen if you turn one of these experiments on, and your browser may even spontaneously combust. Jokes aside, your browser may delete all your data or your security and privacy could be compromised in unexpected ways. Any experiments that you enable will be enabled for all users of this browser. Please proceed with caution. Interested in cool new Chrome features? Try our beta channel at chrome.com/beta.

So these are all "experimental" features and from the sounds of it they could even make it's security and performance worse not better. Even a few of the tweaks suggested by the article had already disappeared from the settings page.

I did what was still available and a few more tweaks after careful consideration and what happened?

Well at first some pages seemed to load quicker but then I found that:

  • Some sites without a www. sub domain wouldn't load.
  • Some pages wouldn't load at all.
  • When I came into work today even though a Chrome process was running with 0 CPU usage nothing was displayed.
I had to re-boot, and try 3 times to open Chrome before getting back to the chrome://flags/  page and restoring all the defaults. Since then everything has been okay.

So if your going to tweak be careful - it could take down your whole browser!

The best way to speed it up is to remove all the plugins and add-ons and leave that to FireFox. Turn off 3rd party cookies and any 3rd party services that involve constant lookups and try to keep it clean and simple.

It seems that with the over usage of AJAX and sites like Facebook/LinkedIn/Google+ where as you type it constantly looks up the word to see if it matches a name or contact that this "API JIZZ" as I call it has really slowed down the web.

Just by having Google+, Facebook and LinkedIn open at the same time can eat up your memory and I'm on a quad core 64 bit machine.

In my opinion there should be settings to enable you to turn off the API JIZZ and flashy features that rely on lots of JavaScript and AJAX.

It slows down your computer and is not needed most of the time. Having big database lookups on each keystroke is obviously going to use up lots of memory so it should be an option you can disable.

Anyway that's down to the developers of all these social sites who seem to love AJAX for everything. A simple submit button would do in a lot of cases!


Saturday, 24 March 2012

Logging and Suppressing JavaScript errors

Logging JavaScript errors to a file by overwriting the window.onerror method

Sometimes you may have intermittent JavaScript errors that you cannot re-produce or maybe you just want to be able to log JavaScript errors for later viewing. Or maybe you just want to suppress them so that end users don't see them.

By using the useful and also dangerous feature of being able to overwrite core JavaScript functions and objects you can utilise this to your advantage by overwriting the window.onerror method.

The window.onerror method takes 3 parameters which are:

  • message : the error message
  • url: the URL of the file that raised the error message
  • line: the line number that the error occurred on.


Therefore it is very easy to create your own window.onerror function to take these values and then make an AJAX call to a server side page which logs the JavaScript error details to a file or database or even sends an email.

Also by overwriting the window.onerror function we can suppress JavaScript errors if we chose to.

Maybe if we are debugging a script and don't want the error console constantly filled up or maybe some of our users are still using Windows 98 and use IE 4.

If we are using unobtrusive JavaScript that builds layer upon layer of functionality starting with the lowest common denominator e.g HTML, then adding JavaScript functionality if they have it, Flash if they have it and so on then we may want to just suppress these JavaScript errors in old browsers.

To suppress a JavaScript error you just need to return true.

This example uses jQuery seeing that is so popular but any AJAX library can be used. The point is that you are taking the error parameters and logging them somewhere useful.

I have used a little JavaScript wrapper object to set some system properties like a config object to define whether error logging is on or off and whether or not to suppress errors in older browsers. 

The code to define which browsers to suppress in can be left to you but I have done a simple test for document.getElementById which means browsers like IE 4 and NN4 won't get errors raised.


// Log JS errors to a file - file is overwritten each day only use when debugging a particular page/site

// Set up our global config options to decide whether to log JavaScript errors and whether or not to suppress them. A simple false/true could suffice but we might want to test for old browsers or certain features. If the browser doesn't support document.getElementById it's a pretty old browser!
GlobalSettings = {
 SystemName : "Strictly-Software",
 Version : 2.0.1,
 LogJSErrors : true,
 SuppressJSErrors : (document.getElementById) ? false : true
}

// override the onerror object
window.onerror = function(msg, url, line)
{   
 // does our global system want to log errors - this could be a Client or Serverside setting
 if (GlobalSettings.LogJSErrors)
 {  
                // using JQuery to post a GET request to a page that logs the error details
  $.get("logJSError.php", { message: msg, errorlocation: url, lineno: line } );
 }
 

 // do we still raise the error or for old browsers which might have a lot of errors do we try and supresss them? Use our global config options again.
 if(GlobalSettings.SuppressJSErrors){  
  // return true to suppress the error so its not raised to the console.
  return true;
 }else{
  // return false to raise the error to the console.
  return false;
 } 
}

Then all you need is to define your server side page logJSError.php (or whatever language you are using) to collect the error data from the request and do whatever you want with it e.g log it somewhere for later viewing.

Remember whilst being able to overwrite functions that already exist is good in certain situations like this and the Lazy Function scenario but it can also cause you severe debugging nightmares like the one I discovered when using the common addEvent naming convention for cross browser adding of events.

Therefore be careful especially when overwriting core JavaScript features but also use them to your advantage when possible.


Saturday, 1 August 2009

Using Online Translator Tools

Increasing your sites audience by targeting other languages

This is probably the best reason for investigating the various online translator tools and APIs that are available to use. If you can convert your site into other languages it will increase the number of indexed pages in the major search engines and drive users to your site. Make sure you have links to the original content so that even if the translated version is poor the user has the option of reading the article in the source language. We should remember that although most English speaking people have a poor grasp of other languages the same is not true in reverse and as English is the main business language of the world a large percentage of the world outside England and North America can speak and read English.

I have been looking into the various methods for translating content lately for my own sites and although the translators such as BabelFish and Google Translator are not perfect in their translations they are just good enough to allow someone with an understanding of that language to get the overall meaning or gist of the translated text. Although I am not 100% positive about their internal methods I would reckon they work by first translating common phrases and sentences and then revert to word to word translations. I would say this is probably good enough to cover most non-language critical sites however if I had been paid to deliver a site in Russian, French or Chinese because the sites main audience would be reading this language then I would go down the route of using professional translators rather than a free online tool. However in most cases using a free tool is fine for increasing your sites audience.

From my experience over the last few weeks I have noticed the following issues.

1. Trying to translate a whole webpage sometimes causes format issues especially with text on top of other text. For example view this Chinese translation of my unpacker tool using Yahoos Babelfish and notice the formatting issues especially the code examples and the text around the google adverts.

2. Even with a translator that doesn't cause formatting issues if you are outputting code examples even in PRE and CODE tags you will likely face issues with your code getting translated when it shouldn't be. Look at this example of the same unpacker page in Chinese using Googles translator tool and look at how the variable names have been translated.

3. Therefore I found that to translate a whole page in one go wasn't really feasible using one of these tools and I had to break it into pieces to ensure the code examples were not translated. I converted a couple of my online tools into Russian and Chinese e.g
Unpacker tool in Russian and Chinese.
HTML Encoder tool in Russian and Chinese.

Luckily I work in the same office as a lady from St Petersburg and I asked her to take a look at the Russian translation on my unpacker tool. She said that it was about 80% accurate and was the sort of language and grammar that her 10 year old daughter would write. To be honest I was expecting a lot worse and was pretty happy to hear that the main gist of the page could be understood in that language.

4. Names of people and coding terms sometimes cause issues with too literal a translation. For example the name Dean Edwards in Chinese comes back with the word Dean translated into Chinese and Edwards remains in English. This is probably due to the word Dean being construed as meaning the Dean of a college. This is obviously the main problem with word for word translations. Also slang words, curses, youth chatter or abbreviations will be very problematic to translate automatically especially as these sorts of words have a very niche audience in their own country let alone worldwide. I would probably have a hard time understanding the slang terms that kids speak today just as my elders would have with me when I was young so putting these sorts of terms on the web and asking an automated process to translate the word and keep its meaning would be a near impossible task.

5. Carrying out mass translations I found to be quite problematic as these online tools don't like you posting thousands of words to translate individually. However if you are aiming to get your content into multiple languages for SEO reasons then you need to have your translated content delivered server-side or as static HTML rather than using client side tools such as Googles Translator API or Bings new API. This obviously means either doing each page by hand in steps or trying to automate it. If you are going to crawl an online translator tool and don't want to be met by one of Googles "your query looks similar to automated requests from a computer virus or spyware application." messages then you need to be careful, not make too many requests too quickly, and change agents and IPs between requests as much as possible. Another option I thought about was to create an AJAX logger tool and then use Javascript and Googles AJAX API to make the requests to its translator object and then log the results. From what I have read there is no limit on the amount of requests you can make as long as you keep to their Terms and conditions and all you need is a Google API Key.

If you are not concerned about having copies of your original content in multiple languages for SEO purposes then offering your visitors the ability to read a page in their own language by using client side tools is a good way to go. Using Googles or Bings API you can translate your content as it loads. I have a little function that allows me to pass an array of IDs into my translator wrapper object which will then loop through the array taking each related elements innerHTML, translate it and then as the result comes back replaces the original content. With this method you can be very precise with what you translate and avoid issues such as translating code examples. Also rather than a long wait whilst the whole content is translated you achieve a ripple effect as the DOM is modified bit by bit. You can see an example of this on my football site with a test page I created which will translate from English to Spanish. Also if you are translating single words such as labels, button values and headers you are probably more likely to get a better translation and you are only requiring a word for word match.

Another online tool I have just added to my main site is a Twitter feed translator which will use Googles Translator API to translate tweets from any Twitter account from one language to another. You can use the form as is or you can directly link to it from your own site passing the name of the Twitter feed you want to translate and then the language code for the language the feed is written in and the language you want to translate it to. For example to view my Twitter feed in German you would use the following URL:


If you would like to see the code behind this form and how it links into Googles API you can read the following article about translating twitter feeds.

Now I am not suggesting that twitter feeds will be the easiest forms of text to translate especially due to the restriction on the amount of text you can use per tweet which usually leads to slang terms and abbreviations being supplied. However as a large percentage of twits (what do you call people who use twitter?) seem to use the application to share links with a short blurb about the links content its probably good enough for accessing tweets containing key #tags of interest supplied in other languages. Plus it enabled me to offer a tool that's puts to use the following features:

-Makes use of Googles AJAX API, especially the translate object.
-The user-interface is very basic with little explanatory text and I have implemented an auto translate of the main labels, buttons and text so that if the user is not English these will be translated as the DOM loads. This makes use of Googles GEOcode data which is supplied for free with their API.
-I also use this GEO data to work out the users location and if they are from the UK I will display a specific banner advert otherwise I default to a Google Advert.
-Use of ISAPI url rewriting to allow automatic translations and nice links to the page.