Software Engineer, somewhere between irritated and annoyed.

Handy rsync for copying large amounts of data in linux

When copying to the local file system I always use the following rsync options: rsync -aWhv --no-compress --progress /source/ /destinationfolder/ --no-compress as it's on the same machine --progress speaks for itself -a preserves ownership & permissions using archive flag -W copying whole files only # and optional ones for watching -h human-readable transfer rate and file sizes -v keeps it verbose so we can see whats happening…

C# logo for stickers + stuff

Back in early 2013 I was pasting stickers all over my acer, as if it was some sort of third rate thermal insulation, and I thought to myself, wouldn't it be nice if I could have a C# one. Annoyingly all the C# ones were god awful. But Jeremy Kratz and had kindly made it clear he wasn't bothered about the licence something confirmed recently. Anyhoo I liked it and decided to try and replicate it…

Handy MongoDB C# Tools

Just a few bits and bobs I've collected up lately. Aggregation is a neat feature in MongoDB and as with most mongo c# stuff it's often a small hurdle to implementing the same query you perform in BSON in the driver language… Sooo just to get you started https://chrismckee.co.uk/mongo-aggregation-in-c/ Quite a good idea to mix this with Profiling so you can watch how it's querying etc... Pipeline Requests I like the…

Simple MongoDB Aggregation in C#

Grouping Data with Count Note: This starts with the 1.10.1 version of the mongo driver; https://www.nuget.org/packages/mongocsharpdriver/1.10.1 the v2 driver wraps the Async methods to syncronous to stay 'compatible' and as such is slower. So running 'synchronous' using v2 would be disadvantaged by the new driver while async with the async driver may have a minor benefit. The async is covered further down using Driver 2.1.…

Creating & Mounting new drives in Ubuntu / Azure

Leading note: The drive creation is based on using Azure with an ubuntu 14.04 LTS release. This stuff doesn't change very often but sometimes ubuntu changes the advice and occasionally includes features or options that might not exist in other releases. Create a Site & A disk (or more) Ok this bits all azure based, so hang fire or skip to the next bit if you've done this, or are in some other vm/cloud…

What the fuck woke my PC up

My PC hates hibernating, in fact it hibernates for a whopping minute then wakes up due to the genius default driver power management settings. Quick way to find the culprit. Open command prompt and ask... C:\Users\Chris>powercfg -lastwake Wake History Count - 1 Wake History [0] Wake Source Count - 0 Of course if it had woke up it would tell you what caused it. My network card had reset its settings during…

Updating / Restoring Nuget Packages FAST

The VS NuGet client is great for browsing for new packages; in fact it works pretty well for upgrading when your on a small project. But it locks the UI, lags out, if it errors it does so in a useless fashion, the moment you get past a few projects it becomes unbarably slow (especially updating cross solution) and half of the time you just want to stamp on it. Restoring Nuget Packages Create a file,…

NuGet from command line error - Microsoft.Build.Exceptions.InvalidProjectFileException

Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "E:\_PROJECTS\x\c\src\Services\Azure\.nuget\nuget.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. E:\_PROJECTS\x\c\src\Services\Azure\x\x.csproj at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args) at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(IElementLocation elementLocation, String resourceName, Object arg0) at…

Set Up TeamCity on Ubuntu 14 LTS

Prep essentials Change versions to latest as required... _JetBrains version is on this page: https://www.jetbrains.com/teamcity/download/ PostGres Driver version is on this page: http://jdbc.postgresql.org/_ SSH into your server and lets begin. Go root, type sudo su. Cheat mode (skip to : Create a Database Config file for PostGres) wget https://gist.githubusercontent.com/ChrisMcKee/a45e5cd5d7d9b8f9fa00/raw/2b4a8fea3fcff9e6675e560e908fa785d6ac2697/teamcitysetup.sh && chmod +x teamcitysetup.sh && ./teamcitysetup.sh apt-get…

Forcing SSLv3 Upstream in NGINX... fml

Sometimes you have to make sacrifices; often I wish I could place IT professionals at large Banks on a sodding Altar and cut their balls off. Anyway. In some rare horrible occasions you need to force the type of ssl used for an upstream. You do that as follows. upstream shittyserver { server 8.8.8.8:443; } server { listen 443; server_name dodgyproxy.com; access_log /var/log/nginx/access.log; error_log /var/log/nginx/…

Neither the JAVA_HOME nor the JRE_HOME environment variable is defined

If you need a different version or are targeting a different version of Java, change version number accordingly the rest is the same. Going in hard; lets get some root on sudo su Enter password if you need to. If you prefer, you can enter sudo before each command. Install Java apt-get install openjdk-7-jre-headless Find Java Little tip: Installing locate helps a whole lot on Linux, in ubuntu it's usually installed by default (if it's not,…

Dear Umbraco… I Can Haz Content?!

Basic mission; code not my own. Create an advert type; consisting of URL and Image. Additional requirement created setting the type of advert (using uComponents) An AdvertContainer (Doc Type) With two 'types' of advert (i.e. 3rdparty/mpu) ThirdParty contains JS (no image/URL) MPU contains Image/URL var nodes = GetMultiNodeSelection(1101, "adverts"); Foists off into some god awful linq abuse… private IEnumerable<IContent> GetMultiNodeSelection(int id, string property) { var node = _contentService.GetById(id)…

Lowercase Routes in ASP.net MVC4

Back in MVC2 days I wrote a post on setting up a project with lowercase urls / redirecting and a workaround for IIS6. Luckily these days we have MVC4 which is a tad friendlier… to a degree. In the Route collection registration area (Most likely in App_Start lest you've moved it) you can now simply add routes.LowercaseUrls = true; (http://msdn.microsoft.com/en-us/library/system.web.routing.routecollection.lowercaseurls.aspx ) The big bugger about this…

Self Referencing Table Joins in FluentNHibernate

A common usage of the self-referencing joins is the use of 1 table for regions and subregions; its also the laziest example that comes to mind. Entity using System.Collections.Generic; using Domain.Base; public class Region : DomainObject<int, Region> { private IList<Region> _subRegion = new List<Region>(); public virtual string Name { get; set; } public virtual IList<Region> SubRegion { get { return _subRegion; } set { _subRegion = value; } } } ClassMap using Domain; using…

Using Umbraco Content Service outside of Umbraco context/control in Umbraco 6

In order to make user of IContentService outside of Umbraco Controllers/Views/etc you're going to need to expose it. Much in the same way you'd setup NHibernate to create a session factory on application start we grab IContentService and make it accessible. In this case via UmbracoApplication.UmbContentService UmbracoApplication.cs namespace XXX.UI { using System.Web.Http; using System.Web.Mvc; using System.Web.Routing; using Umbraco.Core; using Umbraco.Core.Services; public class UmbracoApplication…