Monday, May 25, 2020

No reimporting of module in Python script

Chances are you have been working with imported modules in python. And you usually import the modules from the very top of the script file.

What happen when you import same module twice or more?

The simple answer in nothing! In python when you import a module and you try to import it again in the same instance of a script it won't work!

That is why when you work with modules such as these listed below, it is easy to get confused that the modules work only the first time you ran them.

  • import __hello__
  • import this
  • import antigravity

You will only see the result of their import once.


import __hello__: will print the famous "Hello World!" as an output.




import this: will print the 'Zen of Python'




import antigravity: will open a browser link to python antigravity xkcdwebcomic.




If you try to run any of the above for the second time, none will work.


Obviouly, I don't see any reason why you will reimport a module. But if you do it for whatever reason, then the second import won't work.

Saturday, May 23, 2020

Fixed - Blog broken due to 'SyntaxHighlighter' Error 522

Few days ago, I noticed my blogger.com blog will load forever when you tried to access it.

The so many things started to flow in my mind. Could it be someone hacked my blog? Could it Google's blogger server isn't responding? Or what?

All my preliminary thoughts and checks didn't yield positive result.

Then a new idea pop in my mind to check the developer console whether I would lucky to find clue to what broke my blog. Behold, I saw some errors on about 8 lines pointing to same Javascript file which is not accessible. This Javascript file was from the 'Syntax Highlighter' plugin.



Just in case if you don't know, 'Syntax Highlighter' is a Javascript plugin that adds code highlighting within blog post. It was developed by Alex Gorbatchev.

I remembered, few years ago I added it to allow me highlight code snippets within my blog posts.

At the moment, the server that host the 'Syntax Highlighter' plugin is down with Error 522 which indicates that Cloudflare is unable to reach the origin web server and the request times out.




How I fixed it

I just accessed the theme settings and comment out the lines that reference the 'Syntax Highlighter' plugin.

Go to Theme >> Edit HTML and remove or comment out that has to do with 'Syntax Highlighter'. Note that the CSS and JS files are hosted on alexgorbatchev.com which is currently offline.



Viola! The error is gone and blog is back to live!



That is it!