Skip to content

Posts tagged ‘browser’

9
May

Opera’s Quick Download Feature

There’s a particular feature I’ve always liked in Opera. I’ve seen it implemented in slightly different ways within other browsers. Let’s say I wanted to download my blog’s sitemap.xml file, and I wanted to do this strictly from within the browser. When I visit the link:

http://mattrefghi.com/wordpress/sitemap.xml

My browser doesn’t download the file, it merely displays it. This happens because browsers know how to display XML, and they figure it makes more sense to show you the content – rather than initiate a download. The behavior is different with “.zip” files, for example. Browsers usually initiate a download when they are pointed to a URL that ends in “.zip”. Downloading the physical XML is therefore slightly trickier. In Opera, I can just paste that exact URL into to the Quick Download box at the top of the Downloads page. When I press ENTER, it automatically downloads the physical XML file – rather than trying to display it.

Opera's quick download feature allows me to download files without first viewing them in the browser

I’ve used this countless times over the years. The same is possible in other browsers, but it usually isn’t as quick as Opera’s implementation. For example, in Google Chrome, I’d first have to view the page, click “Control The Current Page” button, and then “Save Page As”. I would then get a” File Save” dialog, which allows me to change the name, or simply press OK to save the file.

In Google Chrome, the Save Page As feature lets you save the physical file

Certainly not as quick as Opera… and what if the XML file was massive? I’d have to wait for the browser to first display it, then I’d be able to download the physical file.

One more reason to keep Opera installed on my computer.

26
Oct

Blocking Websites with the Windows Hosts File

Sometimes I decide that I never want to re-visit a particular website ever again, and I want a way to block it indefinitely. Normally, I just learned to ignore a website simply out of self-discipline. Lately, I decided I wanted something more secure. After all, even with self-discpline, I could still accidentally visit said site from a link found on another unblocked site. I figured out a good solution: the Windows hosts file.

Windows features a special file simply called “hosts”, without an extension. This file allows users to map hostnames to IP addresses. More importantly, however, is that when Windows tries to locate nodes on any given network, it will take the hosts file into consideration. It will actually consider the hosts file prior to querying DNS server, and any mappings found within will override those in the DNS. This effectively allows us to write custom redirections that affect the entire system – this was the key to blocking the website. To demonstrate how I used this to my advantage,  here’s what the default HOSTS file looks like in Windows 7:

#def Copyright (c) 1993-2009 Microsoft Corp.

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

If I wanted to permanently block:

  • kanyewest.com
  • kanyeuniversecity.com

I would add the following entries to the file, in bold:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 kanyeuniversecity.com
127.0.0.1 www.kanyeuniversecity.com
127.0.0.1 kanyewest.com
127.0.0.1 www.kanyewest.com

By doing this, I’m telling Windows that whenever it encounters one of those domains, it should immediately resolve them to the IP 127.0.0.1, rather than querying the DNS server for the IP. The IP 127.0.0.1 is a special “loopback” IP – it pretty much points to whatever machine you are currently using. That’s how these domains are blocked – Windows will actually be told to use 127.0.0.1, which will definitely not work (since the local machine is not a web server, and is not configured to serve such content). This exact technique is used by Spybot Search & Destroy‘s Immunize feature – so when you open your HOSTS file, you might already see a bunch of entries blocked.

Notice, also,  how I added two entries per website I want to block – one with “www.”, and one without it. I considered this necessary because of the following: from the point of view of a DNS server, “www.websitenamehere.com” and “websitenamehere.com” are two completely different domains; however, in most cases, on the Internet, they tend to be configured to point to the same IP address, so we rarely see instances where they behave differently. Still, since they are different at the DNS level, both possibilities needed to be added to HOSTS file.

Ultimately, once configured, the end result is this: whenever you try to access a blocked site, you’ll get this type of error:

Error seen when attempting to visit a site that has been blocked via the Windows hosts file. This example showcases Firefox, but keep in mind that the block is system-wide. Other browsers will react similarly.

Error seen when attempting to visit a site that has been blocked via the Windows hosts file. This example showcases Firefox, but keep in mind that the block is system-wide. Other browsers will react similarly.

There you have it – a way to block websites in Windows, and a browser-independent one at that. As for the procedure for editing the HOSTS file, it differs depending on which version of Windows you are using. For Windows Vista and Windows 7, click here. For Windows XP and older versions of windows, click here. These links will simply trigger appropriate Google searches, as I don’t have articles that cover these steps yet.

5
Jul

How to Learn More About the Background Pictures Featured on Bing

When Microsoft announced their new Bing search engine, I was immediately curious about how it compared to Google. I changed Bing to my default search engine, and tried using it daily. Ultimately, I returned to Google, which always seemed to have slightly better search results – in most cases. Despite this fact, I visit Bing it at least once a day  - but not to search. I visit it daily specifically to see the new background image they are using. They change this background image every day, and each one is usually impressive. In fact, in most cases, seeing it actually makes me want to find out more about what I’m seeing.

As an example, consider the following screenshot:

Bing background for July 5th, 2009.

Bing's wallpaper for July 5th, 2009.

Great image – the type of image that makes me want to know more. This brings us to the problem, though. Bing doesn’t actually tell you anything about what you’re seeing – other than the copyright information. They do give you more information if you are using the United States version of the site – but I’m Canadian. Not only that, but they don’t have the same images on the United States version of the site. Essentially, this means I’m stuck trying to figure out what the photo is depicting, by myself. I found a pretty simple, albeit manual solution: looking at the source code of the page. The background image filename is actually prefixed with some text, in this case, “CalabriaCoast”:

http://www.bing.com/fd/hpk2/CalabriaCoast_EN-CA1974044658.jpg

Once you have that name, you’re in business – search for that text on the web, and you’ll likely find some informative pages among the top results. Worse case, if you don’t have anything useful on the first few pages, at least you have a lead to work with. In my experience, once you have that name – you have it all. That is, of course, if the picture is of something unique, rather than yesterday’s photo: “Zebras”. If you were interested in where the zebras were, you’d have to guess based on the photo alone.

Now… as for how to actually find that name – I have a pretty quick process. I’ll explain how to do it here – covering the major browsers – but keep in mind, these methods aren’t very elegant – some of them require the use of developer tools. I hope Microsoft eventually makes this easier for regular users… and while they’re at it, people that don’t live in the United States.

How to Find the Bing Background Filename Using Your Browser

Google Chrome 2

An example of how to use the Google Chrome Inspector to locate the Bing background filename.

Using Google Chrome

1) Right-click the background image.

2) Select “Inspect Element”.

A window appears with the element selected – notice on the right sidebar, you’ll see a URL that is partially cut off. Hover your mouse over this URL, and a tooltip will appear – revealing the whole thing. You can even right-click it, and copy it from there. See the screenshot.

Internet Explorer 8

1) Right-click the background image.

2) Select “Save Background As”.

A window pops up asking you to save the file. Take note of the name it is suggesting, as that is the name of the background image.

Mozilla Firefox 3.5

Using Mozilla Firefox's Page Info feature to find the Bing background filename.

Using Mozilla Firefox

1) Right-click anywhere on the Bing page.

2) Select “View Page Info”.

3) Click the “Media” tab.

You’ll see the background listed along with other images. See the screenshot.

Safari 4

1) Right-click anywhere on the Bing page, and select “View Source”.

2) Click CTRL+F, and then type in “.jpg” as the search term.

Cycle through the search results – there should only be three. You will find that one of them is actually background image URL.