Saturday, November 26, 2011

Google Maps slows down on Saturday mornings

I use Google Maps a lot to investigate a place I'm going to or to get direction there. I've noticed that on Saturday mornings Google Maps often fails but when it doesn't it just runs real slow and I get this message:

Still loading... Slow? Use the troubleshooting guide or basic HTML.

My theory is that everyone is using Google Maps to find directions before or while going out on a Saturday and this is overloading their maps servers. When are you most likely going to need directions? When you go somewhere you haven't been to in a while or ever. That's not going to happen during the week when you're going to and from work, that's going to happen on the weekend when you have the time to adventure off the beaten path. So my guess is that the requests to the mapping service peaks over the weekend.

Monday, October 17, 2011

AdWords AdSense Arbitrage

 I've heard about people doing AdWords/AdSense Arbitrage but I question if it's even possible.

First of all, what is arbitrage? The classic definition of arbitrage has someone, usually a trader in the stock markets, buy and sell a financial instrument at exactly the same time such that there is zero risk and an instant profit. Essentially you are the middle-man who has a buyer and seller lined up and you pass the item being sold from one to the other and pull in the difference.

With AdWords/AdSense arbitrage it's a little different because it is by no means risk free and it does not take place at the same time. The idea is that you buy traffic using AdWords and then you sell it on to another site using AdSense and the rate that you buy it at is lower than the rate that you sell it at.

Let's look at the math involved.

Google keeps 32% of the revenue earned from a click on an advert on your site (assumes AdSense-for-Content). So if you pay $1 through AdWords to bring a visitor to your site you need to earn $1.47 from AdSense from that visitor in order to break-even. So far this is not impossible but there's a lot of competition out there and you have to assume that your visitors are looking for the same type of item so advertising rates should be similar. It also assumes that 100% of visitors arriving through your AdWords campaigns click on an AdSense advert.

Now let's imagine that only 10% of your visitors that arrive from your AdWords campaigns click on one of your AdSense adverts. At our example rate of $1/visitor you have spent $10 to get someone to click on your AdSense advert and you need to make sure that you earn $14.71 from that click to break-even. That's a huge jump from a $1 Adwords campaign to an AdSense advert.

This table shows you how much you have to earn per AdSense click in order to break-even based on the click-through-rate based on $1/AdWords click:

CTR AdSense
1 147.06
5 29.41
10 14.71
20 7.35
50 2.94
75 1.96
100 1.47

This is why I think that AdWords/AdSense Arbitrage is almost impossible. 

Wednesday, September 14, 2011

Gigabit networks with low quality cables

I have 2 computers attached to a Gigabit switch and both these computers have NICs that support 1 GBPS speed. However, I noticed that transferring files between them was slow so when I inspected the speeds I saw that one of them was operating at 100MBPS and the other at 1GBPS.

At first I went into the driver config setup and fiddled around with half and full duplex to see if that would make a difference. After a bit more research I found a comment that a network cable might be the culprit and that some network cables (e.g. Cat 5) do not support speeds over 100MBPS. I didn't believe that could possibly be the problem but it was easy to test so I switch the cables and the slow speed moved with the cable. So replacing the cable did the trick. Apparently Cat 5e and Cat 6 are what you need to get the higher speeds.

I'm now transferring data at 10 times the original speed.

Mouse without Borders

Do you have 2 or more PC's on your desk that each have their own keyboard and mouse? Do you want to control it all from one keyboard and mouse without using a KVM and have the mouse float from one monitor to the next and allow copy and paste between them? Then Mouse without Borders is for you:

http://aka.ms/MouseWithOutBorders

I've been using it for a few days now to link my two desktops together and it's working very well. The only hiccough is that I need to sign in to my primary computer first and then the secondary computer second (with its keyboard) if I want them to work together. After that it's all controlled from the primary keyboard and mouse. If I sign in in the other order then I have to use their own keyboards and mice to control them.

Wednesday, August 24, 2011

Collection was modified; enumeration operation may not execute.

This .Net error typically occurs when the underlying collection is modified during enumeration. For example if you remove items from the collection while enumerating the collection.

It can also happen when you're accessing a collection while adding to the collection. See if you can see the bug in the following code which is in the Menus accessor in a singleton object.

if (_Menus == null)
{
    lock (lockObj)
    {
        if (_Menus == null)
        {
            _Menus = new List<MenuItem>();
            _Menus.Add(new MenuItem
            {
                Link = "/mylink",
                AnchorText = "MyText",
                TitleText = "My Title"
            });
            // ... add more items
        }
    }
}
return _Menus;

Note above that we are correctly doing the double null check. Also, not visible in the code we have marked the _Menus item as volatile to prevent the compiler from removing the seemingly redundant double null check.

Here is the fixed code:

if (_Menus == null)
{
    lock (lockObj)
    {
        if (_Menus == null)
        {
            List<MenuItem> tempMenus = new List<MenuItem>();
            tempMenus.Add(new MenuItem
            {
                Link = "/mylink",
                AnchorText = "MyText",
                TitleText = "My Title"
            });
            // ... add more items
           _Menus = tempMenus;
        }
    }
}
return _Menus;

The solution, as demonstrated, is to create a locally scoped temporary collector and build that before assigning it to the _Menus variable. That way all other requests for this object will hold on the lock until this has completed building and then won't attempt to build it because it already exists as determined by the second null check.
 

 

Sunday, July 31, 2011

Creating a composite key in your container

If you need to create a composite key (for a dictionary for example) where the natural key could come from multiple sources a standard technique is to prepend the source to the natural key to ensure that it is unique. However, this can still cause duplicate keys so to solve this problem you should always add a delimiter between any concatenations that you do.

The problem is easily illustrated by looking at how files are managed in folders. Typically the composite key is the fully directory path and file name which identifies the file you are looking for. The delimiter is the backslash.

Say you had 2 files: bat.txt and mybat.txt

Let's say that they were in 2 directories:
c:\temp\somy and c:\temp\so
i.e.
c:\temp\somy\bat.txt
and
c:\temp\so\mybat.txt

Without those backslashes we would have:
c:tempsomybat.txt
and
c:tempsomybat.txt
giving us the same key.

So in code you may have:

public void AddItem(string source, string itemName,
  object data, Dictionary<string, object> myDictionary)
{
     string compositeKey = source + "+" + itemName;
     myDictionary.Add(compositeKey, data);
}
 

Tuesday, July 26, 2011

Disable thumbs.db in Win7

Notes for self on how to do this.

  1. Start Local Group Policy Editor.
    1. From start menu type gpedit.msc and hit enter.
  2. Navigate the left pane:
    1. User Configuration
    2. Administrative Templates
    3. Windows Components
    4. Windows Explorer
  3. On right hand side find:
    1. Turn off the caching of thumbnails in hidden thumbs.dg files
    2. Double click this item.
    3. Change value to Enabled

Other notes:

Might need to log off and log on again.

Will not delete existing thumbs.db file.