Tuesday 12 November 2013

Fix blurry Chrome on Windows 8.1

Recently my computer decided to upgrade to Windows 8.1. Microsoft decided that I should follow technological trend and not stay behind so after restart, surprise! My computer now has a cutting edge operating system and should make my days easier, and the entire world will be happy.

Curious to see what new Windows 8.1 has extra I decided to start Chrome, but then I noticed that my Chrome is blurry. I thought that my video card went crazy so I checked settings, but everything was fine. Then I applied classical Windows fix: restart my computer, but same problem. Now if that didn't fix it, nothing can be done related to Windows (from my experience a computer restart will solve 90% of my problems regarding Windows). Now I am a bit worried that I might have a virus, so I start a virus check, download anti-malware and anti-virus software but nothing, Chrome is still blurry. If there is no virus and Windows is healthy probably Chrome has a problem so I switched to Firefox. Foxy is happy, no blurry edges, nothing.

Today I got some time and by curiosity I found the solution: I deactivated Chrome's display scaling on high DPI settings and everything works fine now. That came in mind after realizing that Chrome is blurry only on my 1080p screen and not on other computers running Windows 8.1 that I have access to.

For easy of understanding I also attached a picture:

Image how to fix Chrome blurry on Windows 8.1

To deactivate scaling on high DPI go to Chrome icon on Desktop -> right click -> select Compatibility -> tick Disable display ... -> click Apply -> click OK -> restart Chrome -> be happy!

That's it.
See you next time!

Friday 7 June 2013

How To: Get the rendered HTML of a webpage with Python

Hello again!

This time I'm gonna show you how to get the rendered HTML of a webpage using Python. For this task we need only ten lines of code and to import urllib2, the library that it will help us. The rendered HTML of a webpage is the HTML that our web-browser receives from the server and renders on the screen. In simple words, this is what we see on the screen and not the code used to generate the webpage.
This HTML code I use to find specific tags into the code.

Here is the code:

def get_page_code(link):
    import urllib2                 # import the necessary library
    html = ""                      # initiate an empty string as the variable that holds the html code
    req = urllib2.Request(link)    # initiate a request
    try:
        response = urllib2.urlopen(req) # store the response in a file
        html = response.read()     # read the content of the file
        response.close()           # close the file
    except ValueError:
        return html                # if there is an error return the empty string
    return html                    # return the generated html


Keep in mind that you will get a long string as output.

Tuesday 4 June 2013

Set union of two lists in Python

Hi there!

This is my first blog post so please be patient with me. Today I started a small course about Computer Science and as programming language is using Python. For me this the first time when I use Python and I am impressed by the syntax and other features. I am coming from Java and c# but I hope I will do fine with Python to.

One of my tasks for today it was to define a function in Python that takes as input two lists a and b, it does set union on them and the result is the list a modified with the new values. I find it very easy to do, I didn't had to use any indexes or something like that, just 3 lines of code and problem solved.

Here is the code:

def union(a, b):
    for el in b:             #iterate over list b
        if el not in a:      #if element of b is not in a
            a.append(el)     #append the element to a

Now a test in console it should look like:
a = [1, 2, 4]
b = [2, 3, 6]
union(a, b)
print a
>>> [1, 2, 3, 4, 6]
print b
>>> [2, 3, 6]

That's it.