Mega

Illustration

Since I am now in States and away from my home backup solution, I am always looking into ways to make offsite backup work. My current practice is using WinRAR to compress (and encrypt) important files and then syncing them to cloud via SugarSync.

Since I do backup quite a lot I am nearly always close to not having enough space. That is why I was happy when I heard about Mega. With 50 GB free space I would cover all my backup needs and then some more. So I got my self an account.

It took ages for website to load. Few times I even got up and checked my Internet connection just in off chance that fairies changed it into 28.8k baud modem. Once it finally got loaded I snooped around and noticed that there is no Windows/Linux/Mac/anything client. Relying only on browser upload is a brave decision and, if done right, might not be too ugly until third-party clients arrive.

Biggest annoyance of browser upload if fortunately avoided since there is an option of folder upload. As I uploaded my backup folder I noticed that all files would stay in “pending” state. After few attempts upload did start but speed was maxing at 2 KB. Smallest backup file I got was estimating completion in couple of hours. For 20 MB. And you cannot leave page once upload starts - remember, this is a browser solution.

With this I finish this rather short review of nothing. Because there is actually nothing (other than registering) that I could really test. Site was falling apart even without me doing anything.

Yes, I do know that service is very popular and that is probably reason why it is slow. But frankly I don’t care much. If there is too many users using it, why do they still allow for registration? Wouldn’t it be wiser if they would stop influx of new users until new servers are in place? Or just lock every second account for a few days (with a nice apologetic message). That way at least some people would find service in usable state. Come on guys, you kept Megaupload going. Cannot you float this piece of shit?

I will probably just revisit this in a month or two. In this state Mega might be a nice publicity stunt but as a service it is complete and utter failure.

[2013-01-23: To make things worse, service also seems to be ridden with basic security flaws.]

[2013-01-27: Things do look a bit better now as speed is greatly improved. Although lack of native client still makes whole thing quite annoying for uploads that lack even most basic features (e.g. speed control).]

[2013-01-31: It gets even better. Mega can lose your content on a whim. Nice encourgament to continue using SugarSync.]

Avoiding Windows Update

Illustration

Work day is over. You pack your things and you shut down your laptop. And then Windows update kicks in and tells you not to turn off your computer until it is done. Congratulations, you have just wasted a ten minutes waiting for computer.

This annoyance is usually avoided by putting your computer to sleep instead of shutting it down. But that option is not a valid one for those with dual boot. At one point or another you will have to go through shut down procedure.

If you have a laptop (or UPS) there is a trick that you can pull. Just unplug your laptop from power. Windows will detect that it is running on battery power and it will not apply updates during that shut down. You’ve got quick shut down and update will wait for whenever you actually want it.

To Round a Penny

Canada decided to withdraw penny coin. In order to keep everything going smoothly and fair they also specified rules for rounding. Rules that are not readily available in any programming language.

In time before rounding functions you would round stuff by multiplying by 100 (in case of pennies) and adding 0.5. You would truncate resulting number and divide it with 100 thus abusing implicit rounding when stuff gets converted to int. Something like this:

int pennies = (int)(value * 100 + 0.5);
return pennies / 100.0;

With nickel rounding we shall use almost same algorithm:

private static Decimal RoundPenny(Decimal value) {
    var pennies = Math.Round(value * 100, 0);
    var nickels = Math.Truncate((pennies + 2) / 5);
    var roundedPennies = nickels * 5;
    return roundedPennies / 100;
}

First we just get a number of pennies. Then we increase number by two pennies (half of nickel) and divide everything by one nickel. Truncating result gives us number of nickel coins that we need for a given penny count. Multiplication by five converts everything back to pennies and final division by 100 ensures that dollars are returned.

Code is here.

PS: Yes, you can write this more concise but I think that this makes example much more readable. Concise example would be:

return Math.Round(value * 20, 0) / 20;

Trimming Text in AfterLabelEdit

Editing text of ListView item is quite easy. Just set LabelEdit = True and you are good. This will allow user to change text of item and it will even let us validate it in AfterLabelEdit handler. But can we additionally adjust edited text?

Most obvious choice would be setting e.Label to some other value. That will unfortunately never compile since Label property is read-only. Next guess will be just hijacking AfterLabelEdit and editing text in code. Something like this:

if (e.Label == null) { return; }
var text = e.Label.Trim();
if (string.IsNullOrEmpty(text)) {
    e.CancelEdit = true;
} else {
    list.Items[e.Item].Text = text;
}

And this works - almost.

Editing label at this point does not really matter. Whatever you write into Text property will be overwritten with e.Label once AfterLabelEdit handler is returns.

In order to handle things our self we just need to pretend that we canceled original edit:

if (e.Label == null) { return; }
var text = e.Label.Trim();
if (string.IsNullOrEmpty(text)) {
    e.CancelEdit = true;
} else {
    list.Items[e.Item].Text = text;
    e.CancelEdit = true;
}

Full code is here.

We Are Sorry

Illustration

I am an honest man. Not a perfect one but I try. Given choice and acceptable price I will always try to buy.

I already got pissed a few times before with my inability to buy content in Croatia. It wasn’t question of money. Content was just not available for my IP.

Since I am in States now I though that no further issues would arise - I have a money and I have a proper address. Armed with confidence I tried to rent a movie on Amazon. Guess what? I was denied opportunity to actually pay.

Amazon has policy of not allowing movie purchases with foreign credit cards. It does not really matter that I am actually living in US. It does not matter that I can use my credit card for other Amazon purchases. I don’t have an US credit card and that is enough to deny me a purchase.

And then movie industry wonders why people turn to pirates…