Split OneDrive folder over multiple drives

OK, so you have 1TB OneDrive storage in the cloud. Nice. But your puny little SSD is only 128 GB, and every last gig counts.

Sure, you could move your entire OneDrive folder to your secondary, mechanical hard drive. But you don’t want to do that. You work with lots of those documents all the time, and want them to be as speedy as possible. It’s just a few folders with big, old content that you would want to have somewhere else, but still synced to the cloud.

Turns out it’s perfectly possible. In fact, it’s so easy you’ll kick yourself for not thinking of it earlier. It probably works equally well with DropBox, GDrive etc.

Just create an NTFS reparse point within your OneDrive folder, to your secondary drive.

So, say for instance that you have OneDrive mapped to C:\Data\OneDrive, and you have a secondary disk with some big data in D:\BigData. Just open a command prompt, and go

MKLINK /J C:\Data\OneDrive\BigData D:\BigData

You data appears as a directory within C:\Data\OneDrive, and is synced to the cloud, but it actually resides on D: so no space is wasted on C:

Boom.

Posted in Uncategorized | Comments Off on Split OneDrive folder over multiple drives

Forcing comments on commit with TortoiseSVN

It turnes out that it is absolutly trivial to force users of TortoiseSVN to add a comment while checking in changes to subversion, without messing around with pre-commit hooks on the server. Just add a property called “tsvn:logminsize” to the directories you want the restriction on, and set the value to 1 (or a larger value if you want to enforce a minimum comment length). You can have different values on different directories (just remember to set the property recursively, and then commit your new property). This is handled beautifully in TortoiseSVN, the “OK” button is simply disabled until an adequatly long comment is entered.

I found this via Anuj Gakhar.

Posted in Uncategorized | Tagged , | Comments Off on Forcing comments on commit with TortoiseSVN

Don’t fill up your disks

I recently commented on an interesting blogg entry regarding optimizing Lightroom, where there was some confusion about why you should keep a large portion of your disk unused (and how large is large enough).

Since it became a rather long comment, and since this is an important performance factor that isn’t talked about a lot, I am simply reposting my comment as an entry here… I’m lazy like that…

I just wanted to shed some light on the “Keep space on your hard drive” tip. Michael asks if he really needs 400GB free on his 1TB drive, and the answer is yes, if maximum performance is the goal, he does. This is not so much to improve stability (once you have enough free space to write any temporary files, unfragmented, even more free space doesn’t really help you in that regard) but rather because of the way traditional hard drives work. A hard drive’s performance is not consistent across the entire surface, but varies significantly depending on which part of the drive gets read or written.

Generally, a hard drive will be fastest while writing to the outer edges of the drive’s platters, and performance will decrease when writing closer to the center of the platters. For this reason, drives fill up from the edges toward the center. The specifics of at which points and to what degree performance is cut is drive model-dependant, but generally speaking, the last parts of the disk will have about half the read and write transfer performance of the first parts.

Typical examples of this can be seen in more detailed tests of hard drives, for instance http://www.tomshardware.com/reviews/2tb-hdd-7200,2430-6.html (just a test of three disks I chose at random to illustrate the point).

To get the absolute maximum speed from your disk, you shouldn’t normally use much more than 20-25% of the disk, the rest should be unused space. Getting disks that are four times as big as “needed” is expensive, of course, and exactly how much you want to fill your disk, and in other words how much performance degradation you will suffer, will be an individual question. But when you’ve passed 50-60% of your disk space, this starts to be a real factor.

Finally, this relates to traditional, mechanical hard drives. The story for SSDs is far more complex. While they theoretically don’t suffer any degradation depending on what memory addresses are written, the controllers on current SSDs (especially MLC-based disks) tend to run in to a lot of optimization problems with data writes once free space starts to get scarce. So, expensive as they may be, SSDs will also give you the best performance while they are primarily empty.

Posted in Uncategorized | Tagged | Comments Off on Don’t fill up your disks

Using Drivel with WordPress

While trying out Ubuntu, I’m without my standard blogging client (Windows Live Writer), so I’m testing Drivel instead. When starting, it’s not clear how to connect to a WordPress blog, but it’s really quite easy. Just set Journal type to Moveable Type, and Server address to http://yoursite/xmlrpc.php

Posted in Uncategorized | Tagged | Comments Off on Using Drivel with WordPress

Unable to add certificate exceptions in Firefox on Ubuntu

I don’t know if this is an issue with Firefox (3.0.10), Ubuntu (9.04), Apache2 or the default apache config file, but when trying to surf to a SSL-encrypted page on a default installation of Apache on Ubuntu, with a default self-signed certificate, Firefox (also a completely default installation, this is on a new system with nothing on it yet) just gave me a sec_error_ca_cert_invalid popup, without any possibility to add an exception. The “Or you can add an exception…” link I’m used to simply did not appear. Surfing into the site from a windows computer worked nicely.

After a (long) while I realized that whatever the problem was, it only appeared when surfing to https://localhost/ . If i surfed to https://computername/ , I got the expected behavior.

Weird.

Posted in Uncategorized | Tagged , | Comments Off on Unable to add certificate exceptions in Firefox on Ubuntu

Overloading == in C#

When overriding the == operator on immutable objects, I’ve previously done something akin to

public static bool operator ==(MyThing x, MyThing y)
{
    // Null tests
    try {var ignore =  x.GetType(); } // Provoke NRE
    catch(NullReferenceException)
    {
        try
        {
            var ignore = y.GetType();
            return false; // Only one operand null
        }
        catch (NullReferenceException)
        {
            // Both operands null
            return true;
        }               
    }
    return x.Equals(y);
}

to catch the case of two null objects. (null == null) should evaluate to true. Equals, of course, evaluates if the fields of the objects are identical. However, this solution purposefully raises an exception and then catches it, which is never a good design, and also makes debugging with “break on all exceptions” a pain. So I was quite happy when I realized that the test could be written as

public static bool operator ==(MyThing x, MyThing y)
{
    // If both are null, or both are same instance, return true.
    if (System.Object.ReferenceEquals(x, y))
    {
        return true;
    }

    // If one is null, but not both, return false.
    if (((object)x == null) || ((object)y == null))
    {
        return false;
    }

    // Return true if the fields match:
    return x.Equals(y);
}

instead. I can’t take any credit for the solution above, since it’s lifted almost verbatim from Microsoft’s C# Programming Guide, Guidelines for Overloading Equals() and Operator ==. But that’s the way it always is, any information you want is always out there on the net somewhere, you just need to find it. Hopefully this post helps someone else do just that.

Posted in Uncategorized | Tagged | Comments Off on Overloading == in C#

Using OPTION (FORCE ORDER) with user definied functions in SQL Server 2005

Really interesting thing I realised today: Using OPTION (FORCE ORDER) within a UDF, at least in SQL Server 2005 (i haven’t tested in other versions), doesn’t work if you are within the RETURN clause. It does, however, if you aren’t.

For example:

CREATE FUNCTION SchemaName.udfName ()
RETURNS VARCHAR(50)
AS
BEGIN
    RETURN
    (   
        SELECT  t1.Field
        FROM    SchemaName.Table1 t1
        INNER JOIN SchemaName.Table2 t2
            ON t1.Field1=t2.Field2
        INNER JOIN SchemaName.Table3 t3
            ON t2.Field1=t3.Field2
        OPTION (FORCE ORDER)
    )
END

will just return

Msg 156, Level 15, State 1, Procedure udfName, Line 12
Incorrect syntax near the keyword ‘OPTION’.

however,

CREATE FUNCTION SchemaName.udfName ()
RETURNS VARCHAR(50)
AS
BEGIN

    DECLARE @ret VARCHAR(50)
    SELECT  @ret=t1.Field
    FROM    SchemaName.Table1 t1
    INNER JOIN SchemaName.Table2 t2
        ON t1.Field1=t2.Field2
    INNER JOIN SchemaName.Table3 t3
        ON t2.Field1=t3.Field2
    OPTION (FORCE ORDER)
    RETURN
    (   
        @ret
    )
END

will work just fine!

Posted in Uncategorized | Tagged | Comments Off on Using OPTION (FORCE ORDER) with user definied functions in SQL Server 2005

Getting SQL Server Express 2008 to work the way you probably want it to

SQL Express is the free, low-powered MySQL-competing version of SQL Server. It’s primarily neutered when it comes to hardware utilization (it will use at most 1 CPU and 1GB memory) and maximum database size (4GB excluding log files), but for quite a large number of personal or workgroup-level applications, as well as test and development machines, that’s quite enough. As opposed to for instance MySQL, it has the full TSQL language implemented, so you can make reasonably advanced systems based on it. Did I mention that it’s free?

Anyway, the default installation of SQL Express gives you an install that borders on complete unuseable, giving you the impression that this is only a toy, move along, install that full version from your MSDN disks (or The Pirate Bay). But it can, in fact, be made to work resonably.

The default installation gives you two main problems: It doesn’t install Management Studio, so you’re left to managing the database inside of Visual Studio, which of course is a horrible experience. Secondly, it installs the server as a named instance (which there is no reason for at all on a computer with only one instance), creating all kinds of strange problems with programs not expecting this. The installation process has an alternative for “default instance”, but this doesn’t in fact create a normal default instance! Someone at Microsoft is probably laughing himself to sleep over how he could get this practical joke into the product…

Anyway, to fix it, start by uninstalling. There is no way to alter the situation after installation. Then make sure you have a download of Microsoft® SQL Server® 2008 Express with Tools (don’t miss the “with Tools” part). Start the install, and select all features, especially “Management Tools – Basic”. If you don’t have Management Tools in your feature list, you didn’t listen to me when I told you not to miss the “with Tools” part. Go back and redownload.

When you come to the Instance Configuration screen, don’t leave the default Named instance at SQLExpress. Don’t, as you might be prone to believe, choose Default instance either. Create a Named instance with the instance name “MSSQLSERVER” and Instance ID “MSSQLSERVER”.

On Server Configuration, choose what user to run the service under (like SYSTEM or NETWORK SERVICE, or maybe your own user if you’re on a development machine), and make sure you’ve got the collation you want. On Database Engine Configuration, I recommend setting up Mixed Mode Authentication, since this gives you the most alternatives to get all your programs connecting to the server in some way. Make sure you add yourself as a server administrator, if you’re going to use windows authentication. You may also want to move the data directories to somewhere useful, by default they reside under C:\Program Files\Microsoft SQL Server\yadda\yadda\yadda. Personally, I allways put them in C:\MSSQL (or on some other drive than C if such a drive exists on the machine) and shorten the paths from the useless MSSQL.10.MSSQLSERVER\MSSQL crap, so that data files for example lie in C:\MSSQL\Data. Nice and simple.

After installation, you’ll likely want to go into SQL Server Configuration Manager and enable TCP/IP and maybe Named Pipes under SQL Server Network Configuration. As for TCP/IP, you need to enable it on the Protocol tab, and then Enable it again under IP Addresses. And of course, if you want to be able to reach the server from outside of the machine it’s installed on, you need to tweak your firewall. Make sure SQL Server, Server Browser and Server Agent services are set to Automatic startup, and restart them (for the protocol changes to kick in).

That’s all there is to it. Now you have a database that can do most everything you need, except use the profiler (yes, that sucks, but I guess MS has to have something left to push people into buying Workgroup Edition).

Posted in Uncategorized | Tagged | Comments Off on Getting SQL Server Express 2008 to work the way you probably want it to

GMail Notifier stopped working?

Did your GMail Notifier stop working a little while ago? Does it all of a sudden always sit there with an exclamation point instead of the envelope? Does it just say

An error has occurred.

Cannot connect to mailbox.

Service unavailable

every time you try to check your mail?

You probably just did the same thing I did when the latest interface came you, went through the settings and immediately checked the “Always use https” option. This turned out to the the problem. Notifier probably can’t follow the redirect. To fix it, you can uncheck the option, or, better yet, use a registry hack (from Google) to allow Notifier to also use SSL.

I certainly can’t take any credit for this, lots of other people figured this out before me, but those blog entries didn’t really come up high when I searched for a solution, so maybe this one has the right keywords to help someone ;-) .

Posted in Uncategorized | Tagged | Comments Off on GMail Notifier stopped working?

Uploading images with Windows Live Writer to WordPress

I’ve gone completely insane the last days trying to publish to my WordPress blog (self-hosted) using Windows Live Writer. Most of the time it works, but sometimes it doesn’t (I get Xml-Rpc errors), and I can’t find any clear pattern. Longer posts tend to have more problems than shorter ones, and posts with more images tend to have more problem than posts with fewer images, but sometimes a one line post with one image will fail.

The best workaround I’ve found right now is to upload all images to an FTP directory, instead of putting them in the normal wp-content directory. In Writer that’s Tools, Accounts, Images, Edit…, Images, Transfer images to an FTP server (I’m guessing about the exact labels, since I’m using a swedish copy of Writer, but it should be something like that). Since I made that change, everything has been working, but I’m not ready to count my chickens quite yet…

Posted in Uncategorized | Tagged , | Comments Off on Uploading images with Windows Live Writer to WordPress