Skip to content

Posts from the ‘Technology’ Category

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.

25
Sep

Reducing E-mail Spam by Eliminating Public Listings

I’ve been using Gmail as my e-mail service provider for a few years now, and due to their excellent spam filters, I’ve been able to ignore the continuous stream of junk mail hitting my mailbox every day. Despite their efficiency at identifying and hiding spam e-mails, I remain genuinely concerned about keeping my e-mail address hidden from the public view.  E-mails that are publicly available are easy targets for spambots, which are automated programs that scour the Internet for e-mail addresses. Once “harvested”, these addresses are sent junk mail, spam.

Sometimes, however, it is desirable to have an e-mail address visible to the public – to do so, a special approach should be taken to protect it from spambots. For example, you can use services like reCAPTCHA Mailhide, which challenges viewers with a CAPTCHA before it displays the full e-mail address.

Curious about whether or not my e-mail was “out there”, I decided to look into it. Below, I explain how you would go about checking for public references to your e-mail address, and how future slips could be prevented.

Google Your E-mail Address

Try searching for the e-mail address using Google. Search engines scour the Internet for web pages, rather than just specific elements in the page (like e-mail addresses). They do so through programs called crawlers, sometimes referred to as spiders. If they have indexed a webpage that has your e-mail address mentioned, you’ll be able to find it in the engine’s search results. The important fact here is this: if you can find it using a search engine, you can safely assume that a spambot would be similarly capable. It is therefore important to remove any references to your e-mail address – in doing so, you’ll be making it a little bit harder for spammers to target your address.

To do so, try launching a Google search for your e-mail address, using this format:

“you@youremailprovider.com”

The double-quotes will tell Google to look for that exact string, which will limit the number of false positive search results that are returned. If you get no results with the double quotes, try removing them.

After running the search, if you spot search results that actually have made your e-mail address publicly visible, you’ll need to try and remove them. In my case, when I did this, all the hits were sites that I could log into, and then remove my address. If you’re lucky, it’ll be that simple. Otherwise, you might have to contact the site owner to get it removed.

Question How Websites Use Your E-mail

To avoid getting into potentially complicated situations, it is worthwhile to spend some time determining how websites intend to use your e-mail. An e-mail is almost always requested when registering, but the uses vary. It could, for example, just be used to contact you to activate your account. Or, it could be used for a multitude of things, including as a publicly viewable piece of information. Take the time to check FAQs, site forums, or even contact the site owners if there are doubts – this could prevent an increase in spam received.

Sometimes, however, it isn’t as straight-forward as them displaying your e-mail address- sometimes certain sites will indirectly expose your address. I’ll give you an example… consider Google Profiles. By default, the URL that points to your profile looks something like this:

http://www.google.com/profiles/114973454253911341512

You can, however, choose to have your username appear at the end, like this:

http://www.google.com/profiles/youruseraccount

This is naturally better for search engine optimization, and it also allows you to memorize your profile link – but it introduces a flaw as well. Looking at that URL, I know that the e-mail address “youruseraccount@gmail.com” exists. It has to, that’s how Google accounts work – they are based on an e-mail address, so there is no doubt about what the username portion is. If I know that, then I can deduce that there must be a spambot out there that is smart enough to exploit the same flaw. Even if no spambots are currently exploiting this, I’m pretty sure one eventually will. Thankfully, though, Google has explained the feature very well on the settings page – reducing the likelyhood that someone would enable it unknowingly:

To make it easier for people to find your profile, you can customize your URL with your Google email username. (Note this can make your Google email address publicly discoverable.)

14
Aug

Converting Formatted Text from the Clipboard to Plain Text

Usually when I copy text from web pages, I really don’t want the formatting from the webpage to be kept. I  just want to have the text in the simplest format possible, and then I can set my own styles. Unfortunately, this isn’t normally how it works. Typically, when copying from a web page in a browser, it may also copy any tables, images, and styles that are applied to or mixed with the text. This does depend on where you are pasting the text, though. In my case, I use Microsoft Word most of the time. Word supports a lot of web page elements, meaning they will likely appear in the Word document.

Consider the following text:

This is some example text. You’ll notice that numerous styles are appliedwarning

Here are some bullet points:

  • One
  • Two
  • Three
    • Three Part 1
    • Three Part 2
  • Four

If I wanted to copy that text to Microsoft Word, here is what I’d see:

pastedtoword

Word is pretty good at keeping the formatting mostly intact; however, sometimes, this isn't desired.

The formatting is mostly intact. What if you didn’t want that? What if you just wanted plain text, and you wanted to choose your own styles from scratch? There is one way to do it from within Word (click the wordbutton1 button for these options), but I’ll show you how to do it without such a  feature. To achieve this, I paste the text into Notepad. Yes, Notepad – the simple text editor provided by Windows. Here’s what the text will look like, once pasted:

Notepad will remove formatting from any text you paste into it.

Notice how the image is gone, and all the styles are removed? Now you can copy this text instead, and paste it in Word:

pastedtowordplaintext

No more formatting!

No more styles, bullets, or image. You can now style it exactly as you want, without having to start off with the same formatting as the web page. This isn’t, perfect, though – you may have to make corrections to the plain text copy in Notepad, as the removal of the formatting sometimes leaves the text with improper indentation.

I’ve used this little trick in a few different scenarios. Here’s an example: Sometimes I include a quote from a website in my e-mails. The default format for my e-mails is rich text, but when I include something from another source, I really don’t care about formatting – I’ll set my own formatting to suit my e-mail. If I just copy paste the quote into my e-mail, it will include the formatting – this usually ruins the look of my e-mail. To prevent this, what I do first is use Notepad to destroy the formatting, and then paste the plain-text version into my e-mail.

8
Aug

Enabling Theme Support in Windows Server 2003

Microsoft’s Server operating systems are specifically aligned to offer, above all, top reliability and performance. It is therefore no surprise that Windows Server 2003, at first glance, seems to lack the standard Luna desktop theme that XP users have been accustomed to. Here’s the thing: The feature isn’t missing, it’s just “hidden” by default.

Solution

Here’s how to enable it:

1) Open the Services Management Console by entering “services.msc” in the Run dialog.

To open the Run dialog, click Start > Run, or press Windows Key + R.

2) Locate the Themes service, right-click it, and select Properties.Screenshot of the "Services" dialog, with the "Themes" service selected.

3) On the General tab, select the Startup Type dropdown, and choose Automatic.

4) Click Apply.

5) Click OK.

6) Right-click the Themes service again, and select Start.

7) Close the Service Management Console.
8) Right-click on the desktop, and select Properties.

9) On the Themes tab, select the Theme dropdown, and choose Windows XP.

10) Click Apply.

11) Click OK.

The Windows XP option, by default, is not listed as an available theme in the Display Properties dialog. When we started the Themes service, the option was added… and there you have it. You can now use the XP theme (Luna), in a Windows Server 2003 environment.

A screenshot of the "Themes" tab of the "Display Settings" dialog, with the "Windows XP" theme selected.

The default XP theme, codenamed Luna, will appear in the "Display Settings" dialog as the "Windows XP" theme.

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.


12
Jun

File Locking: Access Is Denied? Not Anymore.

I’m sure most of you have encountered this type of error, at one time or another, while using Windows:

The "Error Deleting File or Folder" dialog shown when you attempt to delete a file that is in use.

Cannot delete file: Access is denied.

It appears when you try to delete a file or folder that is currently in use by an application. To be completely accurate, the file needs to be in use and locked by the application to prevent external edits – the lock is likely the reason we see the error message. Sometimes it is really obvious which application has a locked handle on the file – for example, if it is complaining about a Word document – perhaps the document is still open in Word. Personally, I consider scenarios like that acceptable because they can be solved easily; unfortunately, all too often I get into trickier situations where I can’t figure out which application is holding onto my file. In those cases, I used to just reboot, and that would usually solve the problem. Yet, there were still cases where rebooting didn’t even do the trick.

Eventually, I was tired of struggling in those moments, and began searching for an application that could help – that’s when I found Unlocker. It allows you to remove locks from individual files via an “Unlocker” option within the Windows context menu. Definitely a nice feature… but listen to this – they took it a step further via  a system tray program called Unlocker Assistant. If you encounter the “Access is denied” error while Assistant is loaded, Unlocker will automatically pop up a few seconds after you click “OK”, and it will show you the culprits:

Unlocker Assistant showing the processes that have a hold on the locked file.

From their interface, you have the option of either killing the process, or unlocking the files themselves – effectively breaking the hold the application has on the file without having to terminate it. Very handy. You can download Unlocker here.

If you’re more inclined to trust Microsoft-sanctioned applications, grab Process Explorer – a Sysinternals app. I didn’t try it for this purpose specifically, but from what I’ve read, it isn’t as simple as Unlocker when it comes to removing the “Access is Denied” error specifically. It serves multiple purposes, whereas Unlocker is specialized.

29
Apr

Applying a Custom Filter in an Open File Dialog

What I’m going to cover now is a pretty minor feature of Windows. I would of skipped this article, but I encountered a few people that never heard of this trick. I’ve personally found it useful in scenarios where I was working with custom file extensions… for example, I knew that a particular file with the uncommon extension “.def” could be opened in Microsoft Access.  The file extension “.def” is not typically associated with Microsoft Access, but I knew it was a valid file.

To explain how the feature works, consider your typical, everyday “Open File” dialog:

A an example of a File-Open dialog showing an active filter.

An example of a typical "Open File" dialog - from uTorrent

In this example, the dialog wants you to select a “.torrent” file by default. Because this is the active filter, you only see files that have a “.torrent” extension in the folders you view.  What if you had a file with a “.abc” extension – and you knew it was a valid torrent file,  just with a different extension? If you wanted to select it, you’d have to change the filter dropdown to “All Files”, and then find it that way. If you had a lot of files in the same folder as the “.abc” file, you’d have to look through the list to find the one you want.

Wouldn’t it be great if you could simply filter for “.abc” files, even though the dropdown doesn’t have it as an option? Guess what… you can.

Simply type:

*.abc

in the “File name” textbox, and click press Enter.

This is the result:

A File-Open dialog with a custom filter applied.

Notice how the “.torrent” file is no longer visible? This is because we just applied a custom filter, one that told the dialog to only display the files having an extension of “.abc”.  This little trick can be useful when you’re dealing with lots of a files -  it can reduce the clutter and make it easy to find something specific.

Here’s an interesting detail: if you take another look at the filter dropdown, as show in the screenshots, you’ll notice that the filter itself is shown in the name of the dropdown choice. Consider the “Torrents” filter from the above screenshot:

Torrents (*.torrent)

The portion within the parentheses (green font) is the filter that Windows is internally applying when you select the dropdown. All we’re really doing by typing the filter directly in the “File name” textbox is bypassing the limited options in the user interface, likely using the same approach as Windows would had the option been available as a dropdown.

27
Apr

Visualizing Disk Usage With Treemaps

Have you ever been in a situation where you’re not sure why your hard drive is as full as it is, and you wonder what exactly what is taking up the most space? I’m pretty sure most computer users have encountered this before. What I used to do when I hit this problem was look around for big folders on my drive. This ultimately works, but it takes some searching to find the problematic folders – and you’re likely to miss some stuff.

Determined to find a better approach, I looked around for an application that could help me, and eventually found one called WinDirStat that utilized a method called treemapping to help users visualize their disk usage. I tried it out, and was immediately pleased with how it worked.

Here’s how it looks:

The WinDirStat interface allows you to visualize disk usage.

The WinDirStat interface. Click to enlarge.

Each of those colored rectangles actually represents a file on the hard drive. You can hover your mouse over any one of them, and WinDirStat will reveal the name of the file as well as where it is located. It is also possible to quickly determine which types of files are using up the most space, using the “Extension” frame.

Overall, I’ve found that these features are a godsend when trying to free up disk space. I’m hoping future operating systems comes with this type of application built-in, as everyone I know seems to find this an invaluable tool when it comes to cleaning up a hard drive. It could also be useful in online applications that allow you to store data online, like Dropbox, or other similar services.

27
Mar

Measuring Those Pixels

Ever needed to measure the distance between two HTML elements, without achieving it through code?

I found a tool a while ago that allowed me to do just that; it was, essentially, a virtual ruler. Called Pixel Ruler, this free application makes a ruler appear on your screen. You can place it anywhere you want, horizontally or vertically, and use it to measure pretty much anything. It is a little buggy at times, but I still recommend you give it a try.

Using Pixel Ruler to measure the Google logo.

Pixel Ruler in action

17
Feb

Where's My Cell Phone?

Last year I decided to get drop my land line, and just get by with a cell phone. All was well, until one day where I wasn’t able to find my cell phone. I somehow managed to lose it in my apartment, and since I no longer had a land line, I couldn’t call my own phone to get it ringing. To locate it, I ended up sending an instant message to a friend on MSN, and he called my phone. That worked well enough, but it required someone else to be around. 

The next time I lost my phone, again in my apartment –  I couldn’t contact anyone on MSN, so I looked for an alternate solution. I googled around in search of people in similar situations, and I eventually found this site: Where’s My Cell Phone? – you give them your cell phone number, and they call you a few seconds later. Pretty cool – I just hope they aren’t selling our numbers to marketers. Their privacy statement seems to suggest that they do not.