SteGriff

Blog

Blog Index

Welcome!

This blog is my notebook of solved problems, thoughts, and stuff I made.

It runs on Jekyll, and used to be powered by Upblog, hence the name. I have an old wordpress blog at stegriff.wordpress.com

All 166 posts

ASP.Net custom attributes share a DbContext and cause thread hell

Or, “How come I get errors about ‘A second operation’ starting but I’m using await right with no lazy loading?!” ASP.Net WebAPI attributes are cached by the framework, making them singletons. It’s very popular in .Net world to create a custom attribute for authentication. In our case, the auth attribute...

Setting up IIS for the first time

Windows has a built-in webserver called Internet Information Services (IIS). It’s often switched off by default, but it’s easy to switch it on and use it to host a local website! Getting IIS Press the Start button or key Start typing ‘Windows features’ Click ‘Turn Windows features on or off’...

Array Methods in LINQ, JS, and PHP

Array methods and lambdas! JavaScript has had them since ECMAScript 2015. DotNet has them in the form of LINQ, and PHP has had some variety since PHP 4.0.5(!) I know them by their LINQ names and forget what they’re called elsewhere. This is my little memory extension. LINQ JavaScript PHP...

Changing the timezone on Azure App Services

For my future self: You really can’t fix Azure App Service timezone through web.config. When has web.config ever let you run an application in a different timezone than the host machine?? You dummy. Azure App Services run in UTC time. This means that for the half of the year, they...

Node Sass Release Download Not Found

I had a problem with installing and running the build task for our Vue project on my new machine. When running npm install, I had this error: $ npm i > node-sass@4.10.0 install C:\TFS\Intermediary\ST3\Src\PSL.Intermediary.WWW\resources\js\Vue\node_modules\node-sass > node scripts/install.js Downloading binary from https://github.com/sass/node-sass/releases/download/v4.10.0/win32-x64-72_binding.node Cannot download "https://github.com/sass/node-sass/releases/download/v4.10.0/win32-x64-72_binding.node": HTTP error 404 Not Found As...

Learning to use Docker

Docker is a way of getting some software and all its dependencies, and running that software in a somewhat isolated environment. Images are available from a registry, usually Docker Hub (https://hub.docker.com/), or Microsoft Container Registry. An image is analogous to a software installer or package. You can use it to...

LINQ join where second collection overrides and supplements the first

Say you have a collection of default preferences, and a collection of user preferences which overrides some of the default values but also includes some values which don’t have a corresponding key in the set of defaults. You could write something really ugly for this with lots of looping and...

LINQ left join

When you write LINQ query syntax (from x in stuff) you can have as many from clauses as you like. Using this technique and the .DefaultIfEmpty() extension, we can write a sensible left outer join: from quote in _context.Quotes from buildingsCover in _context.BuildingsCover .Where(bc => bc.QuoteId == quote.Id) .DefaultIfEmpty() from...

Managing PowerShell Modules

At time of writing, there are three different PowerShell modules for Azure. They are Azure (classic) AzureRM, and Az, the new one. You can have more than one installed (although warnings say that AzureRM and Az don’t play nicely together) and you can also have more than one version of...

Pager Gotchas

One recurring problem I really don’t like to solve in software development is pagers. Whether it’s blog posts or API results, I’ll jump over the moon to avoid writing a pager. But why? For one thing, I remember all the finickity little problems that come up every time I try...

Set up Slate documentation generator on Windows in 2019

Slate is a documentation site generator which runs on Ruby via the Middleman site generator, with a JavaScript frontend. It doesn’t officially support Windows but it is pretty easy to get it up and running (when I wrote this!) At first I had a problem with RubyGems, which complained that...

Getting Enum attributes - fast!

Sometimes you want to attach extra information to Enum members so that you can get, for example, a user-facing string representation of the underlying value. There are a number of Stack Overflow answers and the like which will tell you how to do this with Attributes, particularly the [Display(Name =...

A quirky way to handle dependencies on artifacts from other solutions

Say you’ve got two big .Net solutions: Enormous legacy codebase including lots of patterned, reusable code (200 projects) Internal dependencies which cascade; i.e. WarehouseService depends on WarehouseBusinessModel depends on WarehouseDataModel New front layer partially dependent on the old modules (20 projects) To avoid repeating yourself (and to avoid functional shortfalls...

My project depends on two different EntityFramework data layers with different versions of Entity Framework

…Get me out of here! So how can we make a .Net solution work with more than one version of Entity Framework in the mix? It’s a horrible problem; here are my comprehensive field notes. Imagine the following projects: Data5 - A compiled DLL reference; a legacy data layer with...

What no-one tells you about getting started with BenchmarkDotNet

BenchmarkDotNet is a package for benchmarking (timing) .Net routines. It does correctly what you would do wrong if you were trying to time code yourself using System.Diagnostics.Stopwatch and gaffer tape. Like, it does timed rounds of volume testing, warmups, and JIT gymnastics all to make sure that the timings you...

How to use Moq

This is more of a ‘Note to Self’ article… something else I forget a lot… :) First, install the Moq Nuget package. Example which always returns the same value Let’s use the Mock class. You can only mock an interface, never a concrete type. // Get a LogoService which always...

WebAPI with NinjectHttpApplication the new way for 2019

There’s conflicting advice on how best to integrate Ninject with ASP.Net WebAPI. You can use NinjectWebCommon.cs with WebActivatorEx to start up your injection, or you can avoid having any of that code by making your application inherit NinjectHttpApplication. This new way suits me better! Add packages When you add the...

Reasons a breakpoint will not be hit

1. You’re not in Debug config Build configurations other than Debug, by default, have “debugging info” turned down or off, and don’t define the DEBUG or TRACE constants. You can change this for a configuration on a project: Right-click the Project and go to Properties Go to the Build tab...

Scrub bin and obj

When you run Clean Project or Clean Solution in VS, it doesn’t delete everything from bin and obj; it just removes the artefacts which VS would normally build. So the output from external tools or previous builds might be left alone. To do a full ‘scrub’ of bin and obj,...

Add Config Transform in Visual Studio

This is a basic thing but I forget how to do it from time to time. You may want to add a Config transform (i.e. Web.Something.Config) to a project in one of these situations: A) You added a new project to a solution with a load of Configurations and you...

My First PWA

A Progressive Web App is a website which you can pin to your homescreen and use offline like an app. To make a website into a PWA, you have to add some metadata and a script. I’m gonna boil these down to the absolute minimum - this example is a...

Azure API Management

I’m looking into Azure API Management (APIM) to find out how I can wrap my contemporary WCF services from the previous post. Process Make the resource I made a new Azure API Management service resource in the Azure portal. Import APIs via OpenAPI/Swagger/WSDL I added my APIs using their Swagger...

WCF from scratch in 2019

I work with a (big!) layer of WCF services and I want to know more about them and how we can adapt for the future. So I’m doing a deep dive! If I switch tenses in this post, apologies. It’s part stream-of-consciousness and part review. The big questions I hope...

How to use Git behind a Symantec Threatpulse MITM proxy/firewall

In some corporate environments, you might be behind a proxy, like Symantec Threatpulse, which intercepts would-be-secure traffic(!), re-signing it before delivery with a different CA. Of course this causes all kinds of problems with the “certificate chain”. You might see an error like one of these: fatal: unable to access...

Mothballing a mudball (or, how I moved from custom software to Jekyll)

In 2014 I gave up on Wordpress and, in the height of my PHP-hacking phase, decided to build some custom blog software with these design goals: Lets me write in Markdown Lets me upload from anywhere with FTP Lets me “bump” posts to the top of the post list by...

Make an animated expanding list/accordion in Vue

I had to do a bit of research to put together all the parts for this feature, so it’s worth writing down for future reference I think! Here is a demo: Yeah, I used Taco Bell locations again because it’s handy JSON data that I have lying around. There are...

Notepad++ command to open Git Bash in current directory

To set up this command, open Notepad++ and press F5 (or go to Run\Run...) Paste in the following: "C:\Program Files\Git\git-bash.exe" --cd=$(CURRENT_DIRECTORY) Now you can choose to Save the command as ‘Git Bash here’ or similar, and give it a keyboard shortcut if you want. I chose Ctrl+Shift+G. You can find...

Updating Service Reference destroys most members in Reference.cs

If you update or add a service reference in Visual Studio and you don’t get all of the methods you were expecting, there was probably a silent error within the svcutil process which adds the reference. You can check what the error is by running the command yourself. Open a...

Intellisense in SSMS doesn’t work any more

In my last job Intellisense stopped working in SSMS and I just lived with it for years. When I came to a new office, it worked for a while, and then stopped one day. But it’s so much extra typing, I decided to try to fix it. Here are the...

Host HTML on GitHub Pages without using git

This is a companion post for easy and free ways to host a static website. Here’s how you can use the GitHub web interface to make a new HTML website without touching git or the command line! Open GitHub in your browser, login (or make an account and login) then...

Easy and free ways to host a static website

I like to tell people to keep a technical blog because it’s good for your skills, your employer, your employability, the tech sector, and the economy at large. So today I want to share ways of starting a blog that range from extremely easy to quite easy and from free...

Windows Service starts multiple instances of out-of-process local COM Server

Here is a problem I can’t solve. I have a 32-bit client application which calls in to a third party out-of-process COM server (also 32-bit). My client application is a C# app built on Topshelf, so it can run either as a command line app or as a Windows Service....

Magically make an Azure AD user into a local machine admin

If you have standard Azure AD, it’s difficult to make a user into admin on their machine without making them a hardware/global admin across the whole Azure estate (which is not desirable). Through a chain of tricks, it’s possible. Scenario Imagine we’re setting up a new PC for New Hire...

Unit/Integration testing a project which calls an ASP.Net MVC site

In Visual Studio, running Tests does not run your Startup Projects. This is a pain if you’re integration testing, and your client program calls an endpoint of your ASP.Net MVC or Web API site, because the site needs to be running, but isn’t. It took me a long time to...

Class Not Registered

I wrote a class which was COM-exposed and registered it using RegAsm. It was a 32-bit library on a 32-bit machine, being called by a 32-bit caller. Yet when the calling program tried to make an instance, it got the error “Class not Registered”. My Solution In my case, the...

How to create an Azure Active Directory Application and a Service Principal

You can use AAD Applications to add single-sign-on capabilities into your web app. Another use is to authenticate your own program code to call the Azure APIs, or to talk to Kudu (the source control and extension system which is installed in parallel with every Azure Web App) I just...

Failure to cast an object from Azure TableOperation.Retrieve

If you use TableOperation.Retrieve in the Azure Table API, you might struggle to cast the result object into your preferred TableEntity type. In my experience, this is because of the selectColumns which you specified (or forgot to specify) in the Retrieve operation. Here’s some failing code: // Make a retrieve...

Set up log4net in 2018

log4net is a logging library for .Net projects, it can be a bit tricky to set up, so here are my personal notes: 1. Install the package Either from the NuGet Package Manager or with Install-Package log4net 2. Add a log4net.config Create a new file in your project called log4net.config....

Base64 Encode and Decode Unicode (UTF-8) strings in JavaScript and .Net

The Base64 functions in JavaScript are made for ASCII values only. MDN has an excellent code sample for making this work with what they label UCS-2, but the original source labels as UTF-8. Hmm… in any case, it makes it safe for Unicode strings instead of just ASCII: JavaScript (From...

How to do a 301/302 redirect in an Azure Function App with HttpResponseMessage

Azure Function Apps’ use the HttpRequestMessage and HttpResponseMessage classes introduced with .Net Fx 4.5 (which are heavily used in .Net Core Web API projects). It takes a little bit of re-learning to do the normal web stuff you’re used to doing, like redirects. To do a redirect with HttpResponseMessage, make...

Solve problems with using Office 365 SMTP in an Azure Web/Function App

Office 365 uses an SMTP server like any other, but we got snagged on some weird gotchas for a long time, so here’s a blog post. The turnkey solution for mail in Azure is SendGrid, but in some scenarios you need the increased privacy of using your own privately-controlled outgoing...

Paprika For All

When I first made Paprika in 2015, I wanted to give everyone access to it. I am very excited to announce that from today, anyone can try Paprika with their own custom grammars, in their browser, for free, without even creating an account! I hope that it’s so simple to...

Adding LetsEncrypt to an Azure Function App using another Azure Function App

Using Let’s Encrypt has always seemed a bit daunting but I finally bit the bullet and tried it out in Azure. A guy called Simon J.K Pederson has written some awesome turnkey extensions (Kudu stuff) for grabbing LE certificates on Azure Web Apps. These can be made to work with...

The Many Microsoft Partner Centers

At Village, we’re Microsoft Partners. Occassionally I need to check in on our competencies, qualifications, benefits etc. but there are many different portals that let you do this. So here are the ones I can find: Membership Insights (PowerBI) - my new fave Direct link: https://partner.microsoft.com/en-gb/membership/reports/myinsights?tab=1_1 To get there yourself:...

State Machine from Scratch

In most languages and frameworks, good State Machine libraries exist, like Stateless. Use them when possible. When it’s not possible, there are principles you need to have in your head before you start. tl;dr: A FromState can go to a ToState when some Trigger causes a Transition only if some...

Enable ligatures and emoji in Notepad++

By default, emoji don’t work very well in Notepad++ and font ligatures don’t work at all. I have pieced together this guide from other people who have worked on the problems, notably this GitHub issue about ligatures in Notepad++ and this newsgroup post about character encoding detection. Shoulders of giants...

AngularJS Quick Start Examples

AngularJS is a little out of vogue now because little brother ‘Angular’ (just Angular) has taken over. However, after working with it under duress for a while, I only recently discovered the beauty of AngularJS. I’m not a big fan of starting every new project with the Next Big Framework...

Windows App Certification Kit - cannot install package because a different package with the same name is already installed

When running the ‘Windows App Ceritification Kit’, you get an error message like this: Windows cannot install package 780a2c2f-f4be-4a7d-83bf-212522026da9_1.0.0.0_neutral_~_m56gs6vrxbyza because a different package 780a2c2f-f4be-4a7d-83bf-212522026da9_1.0.0.0_x64__gf73qhakswkrp with the same name is already installed. Remove package 780a2c2f-f4be-4a7d-83bf-212522026da9_1.0.0.0_x64__gf73qhakswkrp before installing. …and you might not know how to find the full internal list of installed...

My POST Body is not being received

This one trips me over all the time, lately when I’ve been triggering a HTTP POST action from Microsoft Flow. Symptoms You’ve configured a POST request something like this: Method: POST URL: https://my-service.example/Surface/DoThing Body: accessKey=NyahNyah But your tools/logs reveal that when it the request is received, the Body is completely...

Eraser, Webroot SecureAnywhere, and Windows 10

Nasty, unintended interactions between software packages are the worst thing about software. Here’s one for the list! The short version: On Windows 10 Fall Creators Update, Webroot SecureAnywhere will lock files when they are modified or when deletion is attempted. There is a report for this on the Webroot site....

Let’s make a NuGet Package

I wanted to make a NuGet package for Paprika.Net so I’ve documented the process here to make it easy for beginners to follow along! This guide is based on publishing one project alone, if you have a more complex need then you should read about deciding which assemblies to package....

.Net Framework, Core, and Standard

The distinction between these three concepts of .Net Framework, Core, and Standard, has long lay in a foggy corner of my brain saying “Danger! You do not understand the future of the primary technologies you use for everything!”. So I was glad when recently I was forced into understanding these...

Why isn’t my .Net Core Console App building an exe

Your csproj or vbproj needs to include RuntimeIdentifiers for the platforms you want to target, and then you need to use the Publish feature (not just build) to export for your target platform. <RuntimeIdentifiers>win10-x64;osx.10.11-x64</RuntimeIdentifiers> Like regular .Net apps, .Net Core apps are expected to run on a .Net runtime which...

New-AzureStorageQueue : No queue endpoint configured

If you create an Azure Storage Account with a replication setting of ZRS (Zone Redundant Storage) then you will not have access to Queues or Tables; only Blobs. Here is an example of a failing PowerShell: # Failing test of ZRS $storage = New-AzureRmStorageAccount ` -Location 'northeurope' ` -Name 'zrstestfail'...

Discovering Azure Resource Types

I was inspired by a post I found by Mitch Denny, called Azure Resource Types where he describes a programmatic process for uncovering every AZure resource type used in the Resource Template Gallery. I wanted to repeat his work because it was done almost exactly 3 years ago and is...

Non-blocking wait or sleep in Office VBA

There are a lot of ways to pause VBA execution when scripting Office and they’re nearly all bad and wrong. The ones I’ve heard, from worst to best: Loop with Application.Wait - this will completely freeze the Office app Loop and call the Windows API to sleep - you can’t...

VSTS Build - Access to the registry key … is denied

If you have a project which is registered for COM Interop then it will not build in Visual Studio Team Services (VSTS), complaining with an error like: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets (4640, 5) C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4640,5): Error MSB3216: Cannot register assembly "d:\a\1\s\MyAddIn\MyAddIn\bin\Release\MyAddIn.dll" - access denied. Please make...

Migrate MSUnit tests Accessors to PrivateObjects

MSUnits tests are fussy at the best of times and don’t run in a number of popular environments, such as Travis. If you have invested a lot into white-box MSUnit tests already and need to give your tests better compatability (with Visual Studio Online/Team Services for example) then you can...

Building Uncle Robot

Tweets by RoboUncle This is an article for my muggle friends, to describe how I built my twitter bot, uncle robot. How does it write tweets? In 2015, I created a language called ‘Paprika’ which is useful for generating random arrangements of language. How do you just ‘create a language’?...

Visual Studio 2017 underlining all MVC code in red even though it builds

This project builds fine, but in VS 2017 it shows a lot of errors, which is counterproductive for developers. The following is a reduced set of instructions from the long-titled Microsoft article, How to Upgrade an ASP.NET MVC 4 and Web API Project to ASP.NET MVC 5 and Web API...

Easy API testing without Postman

The big name in API testing is usually Postman. It used to be a Chrome extension and now it’s standalone, but as a Firefox user I never got into it. A few of my colleagues use it for ad-hoc testing of APIs. Today I came across a neat web app...

“The specified dimension is not valid for the current chart type” on ChartObject.Duplicate

Background We have an Excel Add-In product which builds charts (among other things). Last week (Aug 2017), the chart generator suddenly stopped working in Office 2016 for two developers. One developer who uses Office 2010 was unaffected. When we checked out older versions of our code which used to work,...

Link between Azure subscription and Azure AD

I wanted to improve on a diagram I found in the docs for Azure RBAC which provides a really clear illustration of how Azure administrative components are connected. You can see my version here/above, or click through for a larger version. The original was a bit hidden away in an...

My First PowerShell

A guide to the bits that I needed when starting to use PowerShell, particularly in the context of Azure. Not a complete guide to PowerShell :) For that, try these: (MSDN) PowerShell Fundamental Concepts Effective Windows PowerShell: The Free eBook Learn PowerShell in a Month of Lunches Environment For my...

Azure Resource Templates - Crash Course

Azure resource templates are a declarative JSON file which describes a load of resources which you want to create on an Azure subscription. They are generally triggered through PowerShell. If you haven’t used Azure PowerShell before, follow the first two points from this simple MS tutorial on Getting started with...

Authorise a group of developers to create new Azure resources

Our company Azure hosts an Azure AD which we use for Office 365 and also as the authority for who can do what in Azure itself. A few staff are set as Azure admins, but many other developers need the right to log in with Azure PowerShell to create new...

How I write a blog post

Uhhhhh, this post is a bit meta in a silly way that I might regret but it looks like I’m going to Do it Anyway. Since last post was the 100th post on this site (which means I post here on average every week and a half) I feel like...

BuildShadowTask task failed unexpectedly after merging Test Projects

I merged two branches of a solution which each had new MSUnit test projects in them. After the merge, this build error was raised: Error 91 The “BuildShadowTask” task failed unexpectedly. System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.VisualStudio.TestTools.BuildShadowReferences.BuildShadowTask.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() MyProject.OrderProcessor.Tests Take...

Deploy a Custom Microsoft Teams bot in 15 minutes

You can make a ‘Custom bot’ for Microsoft Teams without having to use the full-blown Microsoft Bot Framework. The requirements are dead simple which makes this a really fun entry point to bot-making! First you might want to check out these instructions on how to add a custom bot to...

Highlights from Microsoft Azure 20532

Maybe you read my previous post about taking the Azure 20532 course with QA. Here are my highlights from the course: 1. Web+SQL Using the Web+SQL template, you can deploy a web app and Azure SQL database together which have an affinity for each other. This means that when you...

Developing Azure Solutions course 20532 at QA

May 2017 Last week I got to go on a Microsoft Azure training course, courtesy of my employer Village Software. The course was run by QA in their Manchester venue, and the experience was really good! So I wanted to write a little here for anyone thinking of taking the...

Junior again

We’re building an extension at the moment. Dad is the brains, and my wife and I are labourers. It’s funny, every time Dad has to remind me again to do something that he’s already asked me a dozen times to anticipate in advance, I think to myself “dang!” why didn’t...

Anatomy of a building

I never realised there were so many types of brick. Building the extension has taught me a lot about what actually goes into a building, and where, and why. A lot of the things you learn are like answers to questions you’d never thought about. Like, where does a foundation...

Switch to, merge, and push a branch in git

To switch to a branch, use checkout. It’s important that you don’t use the -b option - this creates a new branch even if it already exists on a remote (i.e. in GitHub origin). If you’re used to having different branches checked out in different folders (as an SVN user)...

Jekyll Quickstart

Jekyll is a static site generator (SSG). An SSG lets you build reusable templates, and write your content in a flexible format like markdown (both of which make it like in a CMS), and compile the source files into static HTML which is then uploaded to the server. This means...

He Carries My Burden

We are here to make much of God - to make God look great (which should be easy because he is great). Lent is a opportune time for this, because we have so many options: Doing anything for lent? Yes, I’m giving up chocolate/meat/video games/tv/facebook/food for 40 days because Jesus...

Tips for graduates

At Village Software, we hire a good proportion of fresh graduates. After all, everyone needs their first break to get that “3 years minimum experience” that every other software development job requires. I’ve been lucky to be involved in the technical interview process for a few of these applicants, and...

Tiny angular pangram app

A pangram is a sentence that contains every letter of the alphabet, like “the quick brown fox jumps over the lazy dog”. I set out to make a tiny pangram app this morning in Angular, that would let you type in a box and “tick off” the letters after you...

Learning about design patterns

I’m starting to look into design patterns using a few different resources, so that I can expand my programming knowledge (not just of the patterns themselves but of the deeper OOP and software architecture principles). Hopefully I can also pass on some of the learning to others at work and...

Notes on JavaScript public/private

Imagine we want to write a simulation of a House class with some private fields for storing internal information, and some public getters, setters, and other methods, which can use the internal information in a safe way. I’m going to use this as an example to explore some deeply JavaScripty...

Compiling a decompiled ASP.Net MVC website

We recently took delivery of a codebase with no code… well, it might actually turn out that the original developer comes through but I started this process anyway! Currently the binaries on the FTP server are the only resource available. Set up the environment Make an SVN repo and set...

Windows Forms scaling on Surface Pro

We have been working on an Office Add-in which is primarily being deployed on Surface Pro 3s and 4s. These units all have their scaling set to 200% which presents a High DPI challenge. Here are some conditions unique to our situation: We are not able to develop on high...

Keep a technical blog

About 20% of the time, when I Duck for the answer to a technical problem online, I find it on somebody’s blog. The other 80% is obviously found on StackOverflow. But software development would be much harder without those people who keep technical blogs/notebooks online! Here are some reasons you...

Wavesurfer.js doesn’t work in Firefox 51

wavesurfer.js doesn’t play audio for me in Firefox, unless you set the backend option to MediaElement. Fault description When not working, it will draw the waveform and allow you to click around to move the seek point, but it won’t play any sound. The ready event is fired during setup....

Gilbert Sackerman

Written 2017-01-23 I am very interested in the artist Gilbert Sackerman, and I’d like to find out more about him. There is not a lot of searchable information about him on the web, so maybe I could find some books one day and gather the stuff that I learn into...

Adding anchored, scaling UserControls to a Windows Form dynamically

In Windows Forms, you can set the Anchor property on controls so that they “anchor” themselves onto specific edges of the parent Form, so that when the Form is resized, your control also resizes. In complex applications, you will often have UserControls, which are an assortment of other toolbox controls...

Merging across seperate repositories in SVN

We have a client who has the same product in two repositories; one repository is maintained for the main site, and the other is for developing a subset of backend features. Nevertheless, trunk changes from the site repository need to be merged across into the other. Ideally these would be...

ASMX Service raises 500 error and returns binary nonsense

There are a few cases when an ASMX service in ASP.Net can return a 500 error and a load of junk binary data. Here are the probable causes and solutions: “I attach Visual Studio to the running code, but the server-side function is never even reached” The parameters to the...

The Explorer’s guide to Las Vegas

Helen and I had the privelege of a business trip to Las Vegas recently, and as non-gamblers, we wanted to find fun things to do, and to explore without compromising on personal values. Helen had to be in conferences for most of the days, but we did get one full...

My Synaptics Validity Sensors driver keeps reverting

My HP Pavilion laptop has a fingerprint scanner for login. The laptop shipped with Windows 7, but since 8.1 onwards, the fingerprint sensor driver keeps reverting to a screwy version which doesn’t work, and it does this every week (seemingly). To set the driver back to the version I want,...

SVN merge is conflicting files unnecessarily and overwriting pertinent changes

The problem I was merging trunk changes into a branch and it was overwriting my actual work. This is unusual and not how SVN is supposed to work. Online sources asked whether I had accidentally selected “reintegrate” but I hadn’t. Eventually I figured out that there was an actual commit...

The rough guide to an easy SVN merge

SVN merges can be tricky. We use TortoiseSVN here at work, as do many other .Net development places, so that will be the tool of choice for this guide. This tutorial assumes the merge of a branch into the trunk. You should have both of these checked out on your...

Tail a file in Powershell

I had to split down a 42 billion line log file. To get the last n lines of a file using PowerShell, like Linux’ tail program does: Get-Content .\file.log -Tail 470000 > output.txt

Umbraco 4 navigation menu with hidden items

Look, I don’t choose to work with Umbraco 4, but sometimes you’re maintaining a legacy system for a client and needs must. A lot of older Umbraco systems just use XSLT for macros like this, but this project is heavy on .Net user controls and we use the old Umbraco...

LINQ is generating SQL with two joins when I only want one

If you have a lot of conditions in your LINQ statement, sometimes LINQ-to-SQL does it wrong: var query = from pp in Context.ProductPrices where productCodes.Contains(pp.Product.ProductCode) && pp.PriceList == priceList && pp.Product.AccountNumber == customer.AccountNumber select new { Price = pp.Price, ProductCode = pp.Product.ProductCode } Generates this: SELECT 1 AS [C1], [Extent1].[Price]...

Where are FileZilla Site Manager entries stored?

To retrieve FileZilla connection details from an old hard disk or PC, go to C:\Users\Username\AppData\Roaming\FileZilla\ and get sitemanager.xml or any other settings file you care for. Replace C with whatever drive letter you want, and Username with your Windows username.

Derived classes and Entity Framework Mapping

If you wanted to add extra (unmapped) data to an Entity Framework model, you might think to create a derived class to hold the extra fields, but this is a mistake and will cause more problems. The usual way to add unmapped data to an EF class is to stick...

Approaches to Version Control

Apart from using different technologies, different people and companies take a different approach to how they employ version control. I want to talk about a couple of patterns very briefly. Before we begin The SVN term “trunk” is essentially equivalent to the git term “master”. In SVN, there is a...

Outer join without an ‘on’ clause in SQL

You can do an old-style join using a comma , between table selections to perform a full outer join which has no ‘on’ clause. Say you have a table for Ships and a table for ShipAttributes which lets you extend Ship by adding arbitrary extra data fields. You want to...

Setting up Native Instruments Komplete 6 for Audacity

Tags: #GriffWiki This is our family guide to setting up a Native Instruments Komplete Audio 6 soundcard with a voice recording mic. It may be of limited use to outsiders ;) Plug the sound card into the PC via USB The lights should come on steady on the sound card;...

Select items from a LINQ grouping based on multiple criteria

The data Say you have a collection of Ships Logs. var logs = new List<Log>() { new Log(){ Id = 1, ShipId = 1, Message = null, CreatedDate = today.AddMinutes(-4)}, new Log(){ Id = 2, ShipId = 1, Message = "Ready", CreatedDate = today.AddMinutes(-3)}, //Most recent with message for Ship...

Quick Reference - .Net File Open Dialog

Making a file open dialog can be a bit laborious and I always forget which fields to fill in, so here’s my current copy-pasta for the task. In C# string fileExt = ".xlsx"; string filter = string.Format("Excel files (*{0})|*{0}", fileExt); var loadDialog = new OpenFileDialog() { Filter = filter, Title...

Postman sets login cookie but my web app doesn’t

I just lost a lot of time on this one! I have a web app written in HTML/Javascript/Angular and hosted by grunt (at localhost:8000), and a back-end API written in C# and hosted by pressing play in Visual Studio (which uses a default ASP.Net Express instance at localhost:8001). I have...

Writing .Net Events, the even shorter version

A follow up to my previous quick start for writing C# events. Let’s assume you just want to raise a simple event which can be represented by EventArgs. If not, read the guide linked above. 1. Add a delegate above the class public delegate void FinishedHandler(object sender, EventArgs e); public...

Error in loading DLL - Why doesn’t my VSTO installer work?

My problem and solution I have a workbook with a significant amount of VBA code, most of which calls methods of a VSTO add-in containing lots of business logic which has been ported from VBA into VB.Net. This works fine on developer machines, but when we create an installer and...

Exposing a WebForms usercontrol as a Partial View

If you’re like me, you work with ASP.Net MVC and are used to all these new parts and the cool things they offer, but the truth of commercial web development is that sometimes we have to work with and maintain older ASP.Net solutions using WebForms (the predecessor to Razor and...

Globals.ThisAddIn is null or Nothing in VSTO Automation Add-In

Scenario You’ve created a VSTO Add-In and you want to call some of the code from VBA, so you’ve followed the procedure to expose RequestComAddInAutomationService. But when you create an instance of that exposed object and try to call one of its properties or methods, you get an error because...

VBA run-time Error ‘-2147024894 (80070002)’ with VSTO

I was developing a VSTO Add-In for Excel. One day it was working and the next day it was not, and I had the following error: Run-time error -2147024894 (80070002) Automation error The system cannot find the file specified This was because the registered assembly no longer matched the bitness...

Get intellisense for VSTO add-in in VBA

If you’re calling VSTO code from VBA, like in this article, you may want to add a reference to your VSTO project so that you get Intellisense in the VBA Editor. If you can’t find your add-in in the Tools/References list, and Browsing for it results in a “Can’t add...

Excel VSTO add-in won’t show my Windows Form

You put the Windows Form in a separate project because you were trying to be a good engineer, didn’t you? Excel can’t load the dependency DLL so it can’t/won’t display your form. Move your form into the same project as the add-in (You could create a GUI or Forms folder...

EU Referendum Opinion

I think Christians should vote for the UK to remain in the EU. What follows is a Christian rationale for remaining in the EU. Someone expressed an opinion to me along the lines, “Staying in the EU will result in increasingly evil, secular government of the UK”. As a Christian,...

Using git with local folders

‘Git’ and ‘GitHub’ are so synonymous nowadays that you’d be forgiven for thinking you can’t have one without the other. I just realised that I personally don’t know how to use git its online counterpart, as I’ve only ever experienced using clone, push and the like with GitHub URLs. So...

Where are Pandoc’s default templates stored

On Windows, you can find the default templates for Pandoc in: C:\Users\{user}\AppData\Roaming\pandoc\templates So the default HTML template would be C:\Users\{user}\AppData\Roaming\pandoc\templates\default.html I initially could not find it there on my work PC because I was looking in the user ste and not stephen, which is my domain user (just in case...

ISO 8601 in PHP

The one that ends in ‘Z’ To get the zoneless ISO-8601 formatted date, use this format string: date("o-m-d\Th:i:s\Z"); To get this: 2016-02-18T07:56:04Z The one with the timezone To get it with timezone, you can use the short formatting code: date("c"); To get this: 2016-02-18T07:56:04+00:00

Embrace the case or don’t

Every few years, Microsoft refreshes its core productivity software suites like Office and Visual Studio to match whatever is going on with Windows at the time. The corresponding releases for Windows 8 were Visual Studio 2012 and Office 2013. Both of these were devisive for one key design decision: uppercase...

ASP.Net AJAX “Unknown web method, Parameter name: methodName”

Scenario You have some backend code in an .asmx or .aspx file to handle AJAX requests. When you call them from the frontend with a perfectly formed jQuery request, you get the error: Unknown web method _____. Parameter name: methodName Exception Details: System.ArgumentException: Unknown web method _____. Causes If you...

My CSS in 2016

1. What should CSS be? Maintainable No specificity hell. No !important. Must have rules and class names that are easy to read. Flexible CSS be reusable like code is reusable Semantic HTML tags have a meaning, a role: <header> So should classes describe a role: <aside class="bio"> (Note for later,...

Virtual Pets

My cool childhood When I was a kid, my parents and I used to holiday in Devon or Cornwall in our camper van. These were very enjoyable and memorable times! One of the special treats of such a trip was visiting the Pound Shops. In an era before Poundland and...

PHP errors not displaying on OVH even though display_errors = on

This happens because OVH uses an optimised PHP infrastructure known as PHP-FPM. This system does not respect php.ini files like PHP-CGI does. Instead, there are settings in .ovhconfig which determine how PHP-FPM handles things like errors, based on an environment setting. When environment = production, errors are not displayed. There...

Notepad++ slow typing and high CPU usage

This can be caused by the function completion scanner if its character limit is set to more than 1. Symptoms Typing is slow. If you hold down a letter key, the characters don’t appear until you release the key. During key-hold, N++ will appear to be using a high portion...

Using Git and GitHub in general IT

If you need version control in the office and you’re not all software developers, git can still be a good choice. If you want to keep your repositories online at GitHub you can also use the great GitHub Desktop client. This is a ‘getting started’ guide. What’s a repository? A...

Ignore certain files and types in GitHub Desktop

Git has a config file called .gitignore which you can use to specify files and types which should be ignored for the life of the repository. Be aware that if such files have previously been committed then you will need to explicitly remove them for the ignore to take hold....

Requirements Analysis, Humbled

I was listening to a great interview today featuring Suzanne and James Robertson of the Atlantic Systems Guild where they discuss “big ‘A’ Agile” versus “little ‘a’ agile”. That is, how stepping back from the (ironically*, rigid) processes of the central Agile methodologies (Kanban, Crystal, etc.) we can take away...

BSOD when joining mobile hotspot

Whenever I join the WiFi from my phone’s Internet Sharing feature, my Windows 8.1 PC suffers a Blue Screen of Death (Kernel Panic). This is because you need to enable FIPS in the network’s security settings, which I can’t do because the BSOD is immediate when I connect to the...

Managing a standard product and a personal version on GitHub

SG 2019-01-26: From 2015 until 2019, this blog ran on homebrew PHP software called Upblog, a kind of headless CMS. Now it is a static site built with Jekyll. This blog platform, Upblog, is on GitHub; I want anyone to be able to download and install it. But I also...

gitattributes error ‘ is not a valid attribute name’

You’re setting an attribute value, but you’ve put spaces around the equals sign. Just remove the spaces! Instead of: .htaccess merge = ours Consider: .htaccess merge=ours Symptom You add a new gitattributes file or line and run git status, and receive this error or similar: is not a valid attribute...

The AGENT smartwatch

The AGENT smartwatch was an early Pebble competitor on Kickstarter. With a campaign launched in May 2013, the AGENT promised lower power consumption than its contemporaries, Qi charging, and a .Net toolchain. That was the most exciting part to me; as a Microsoft developer, I really wanted a smartwatch which...

Why is Adobe Reader so big?

Because it has a lot of features made to let Adobe’s corporate customers get better value out of you! This post is inspired by a comment about Adobe Reader by howardhus on Reddit. “Adobe Reader” is not just a PDF reader. At the pro tier, it has a massive feature...

When was the database last used?

Keep having to Duck this so I thought I’d make a post. In SQL Server, to check when a database was last in use, you can query the sys.dm_db_index_usage_stats system table like this: select DB_NAME(us.[database_id]) as [db], OBJECT_NAME(us.[object_id], us.[database_id]) as [object], MAX(us.[last_user_lookup]) as [last_user_lookup], MAX(us.[last_user_scan]) as [last_user_scan], MAX(us.[last_user_seek]) as [last_user_seek]...

Using email addresses as LOGIN usernames on Azure SQL

If your SQL Database server is called myazureserver and your login is user@example.com, then you must supply your login as user@example.com@myazureserver. This is a modified quote from the documentation for CREATE LOGIN (section titled ‘Windows Azure SQL Database Logins’). user@example.com@myazureserver is obviously a very clumsy username. If you maintain some...

Embed web pages into Powerpoint

Doing a demo? Want to include a fancy HTML5 page, maybe an interactive D3 chart? Are you technical? We’re going to host your demo on GitHub (or GitHub Gist) and then embed it using an official PowerPoint extension. Some foreknowledge is required. This is for Office 2013, but may be...

Publish or Web Deploy an Azure Web App with MSBuild

It’s taken me a day and half to get this working. We have a Web App project which needs to be pushed to Azure from Jenkins. I was following this guide, Publish an Azure Web Site from the Command Line but it wasn’t doing the publish/deploy part at all. At...

Jenkins Release button disappears when security is enabled

I just installed the Active Directory plugin and set our Jenkins server to secure using it. Then, all of the ‘Release’ buttons on our projects disappeared. If this happens to you, it is probably because you have set ‘Logged-in users can do anything’ and for some reasons ‘anything’ doesn’t encompass...

The 10,000 most common passwords

These files were originally published by Mark Burnett (xato.net) on the 20th of June 2011, but it can be hard to get hold of them because search results are pretty bad and his old site page only exists in the Internet Archive right now. So for your convenience, I have...

Make the MVP

MVP means Minimum Viable Product (among other things). The minimum viable product is the first build that does something useful/fun (depending on what your user was going for). I like to compare this to Petri Purho’s advice, “build the toy first”. Petri spent a long time making games in 7...

Defined

This is a web app I made on 18th November 2014 and I forgot to talk about it until now! It’s just a dictionary, powered by the Wordnik API. In this season of life, I was particularly into making minimal web services, and rapid prototypes. The address is currently just...

Git saves the day

I’m working on a game for a bit of fun at the moment, called Space Fleet. I’ve set aside my train commute to Liverpool, and code in Visual Studio on my trusty 2011 HP laptop. The other day I had a sub-moment of horror when I opened the project and...

AJAX ASAP

This was just a passing tweet but I want to give it another look… AJAX is sometime not Async, not JavaScript, and not XML. So I say we call it "ASAP": Async/Awaitable Scripts and Partials Whaddya think— Ste Griffiths (@SteGriff) July 6, 2015 What I’m saying about AJAX is true as...

Using CommonMark in Pandoc

If you’re doing offline publishing of Markdown to any other format under the sun, you probably are (or should be) using Pandoc. And I’ll come onto how to do that in a minute, if you don’t know! But, as many web people now recognise, Markdown is not sufficient because it...

Make blogging easier

Blogging can be hard. Blogging can be easy. Here are my mental rules for making it easier: Find a workflow that you enjoy I didn’t enjoy Wordpress.com. It did everything in its power to foil me at every turn. Now that I can write posts in Notepad++, my favourite editor...

CommonMark and Markdown

Markdown is the web publishing format which has exploded over the last few years. This blog engine and many, many others are powered by it. That means that we write posts that look like this and they come out looking like shiny webpages. There are a load of ways of...

Allow password storage in Filezilla

I turned off password saving when I set up Filezilla. Recently I got sick of having to type in FTP passwords every time, so I wanted to re-enable the option to remember passwords. You can find it in Edit | Settings | Interface; in the Behaviour group, un-tick the box...

IIS Error 500.19 when web.config is fine

This article affects you if IIS is showing an HTTP 500.19 error with Error Code 0x8007000d, but your web.config file looks well formed. A special indicator is that the ‘Config source’ section just says: -1: 0:. Solution This is probably happening because your web.config makes use of an extension which...

Quickstart a Cordova application

This guide uses the Cordova CLI, and is a condensed version of the Apache Cordova Documentation. Install any development kits you’ll need to compile for your target platforms; Install Node and Git if you haven’t already; Install Cordova if you haven’t already, using npm install -g cordova (-g makes it...

TortoiseSVN failed to run the WC DB work queue… access is denied.

This could happen when you attempt to ‘Upgrade Working Copy’ on a repository. I got this error while resolving problems with a Jenkins job which had just moved to a new build server. It seemed that Jenkins couldn’t update the repository, so I went to investigate, hoping to revert and...

Serialize .Net objects to file and back again

When writing some progams, especially games, you might want an easy way to serialize an object with all of its properites into binary so that it can be saved to a file. Here’s a good way! Full example source code is at github.com/SteGriff/SerializerExample 1. Mark your game or data class...

Easily crop to selection in Irfanview

I like to have Photoshop installed on my PCs if possible, but at work it isn’t. So for most of those common image editing tasks, I use Irfanview! In Irfanview, you can click and drag on an image to create a selection border; Once you have a region selected, press...

Getting Started with Masonry JS

Masonry JS is a powerful library for making reactive tile layouts so that content boxes and images can shuffle themselves around your page layout to make best use of space. 1. Create an HTML page and add some boxes Create an HTML template and add some basic stuff like this....

Bugzilla Permission Denied in IIS on Windows

You’re setting up Buzilla on Windows with IIS and get a permissions error like this whenever you try to save config values: Error in tempfile() using template data\params.XXXXX: Could not create temp file data\params.I19Ig: Permission denied at Bugzilla/Config.pm line 270. For help, please send mail to this site's webmaster, giving...

Bugzilla cannot determine local time zone on Windows

If you get this error in a new Bugzilla installation on Windows: “bugzilla undef error - Cannot determine local time zone”, it could be because you don’t have the Win32-specific part of the Perl DateTime::TimeZone library. You can check by going to your Perl directory, like C:\Perl64\site\lib\DateTime\TimeZone\Local (for ActiveState Perl)....

Emoji Studio

Released to Windows Phone Store on 21st April 2015, Emoji Studio is an art app that lets you place, resize, and arrange any of the characters you can type on the Windows Phone keyboard, including Emoji! (Emoji Studio gathers anonymous metrics, based on users opening the app and exporting images....

Write your own C# events

Every other guide is too long! So this one is as much for my own reference as anyone else’s. Let’s go! We have: A class which owns (and fires) the event, say, “Owner”; Some class which handles the event, say, “App”. 1. Write an EventArgs class Shift+Alt+C to add a...

Save a generated value from one SQL query to use in the next query

Say you want to insert a value into Dog and then reuse some aspect of it – such as an automatically generated ID – to use in the next query where you add a DogHouse mapping. The ID might be an identity column, or a GUID which you populated with...

Creating an ad hoc network in Windows 8.1

On Windows 8 and 8.1, you can host a wireless network so that multiple PCs can play a LAN game or share files. Open a new command prompt as administrator: netsh wlan set hostednetwork mode=allow ssid=MyWirelessNetwork key=MyWirelessNetworkPassword1111 netsh wlan start hostednetwork Then when you want to stop sharing netsh wlan...

Order by GUID/UUID in SQL Server

We have some tables in MS SQL land where the ID fields are GUIDs (also known as UUIDs), and often you want to sort by ID when you run a query: select * from kiosk order by KioskId …but it doesn’t come out in the kind of “alphabetical” order you...

Javascript for each returns numbers instead of objects

You’ve made an ajax request or something and now you have some data. You want to for-each over it, but instead of objects with accessible properties, your code is just outputting numbers. That’s because those are the indexes, not the objects! Two choices Instead of: for(var i in items) {...

SIGN

I made a little service for fun at the end of 2014. I wanted one of those scrolling LED displays, but built this instead as a solution which can use any small screens you have lying around. Check out sign.me.uk if you want to try it. It doesn’t have user...

Upblog

SG 2019-01-26: From 2015 until 2019, this blog ran on homebrew PHP software called Upblog, a kind of headless CMS. Now it is a static site built with Jekyll. Upblog is a website system. The site/blog is generated from pages/posts which you write in markdown. You write an HTML template...

How to convert a video to a different format

Sometimes you have a video on your PC which you can’t watch because it’s in the wrong format. Maybe you shot the video on an old mobile phone, or you’re moving it from an Apple system to PC. This guide will let you fix it quickly and easily. FreeMake Video...

Umbraco: Cannot use lambda expression as argument to dynamically dispatched operation

You’re probably doing something like this: var pages = Umbraco .ContentAtRoot() .Children .OrderBy(p => p.SortOrder); But the result of ContentAtRoot() is a dynamic, and you can’t sort a dynamic because the compiler doesn’t know any of its properties until its too late. Really easy solution: use the Typed version of...

Umbraco can’t publish due to MySql.Web.v20

Twice in two weeks, I’ve had the problem of not being able to Save and publish a content node in Umbraco. It saves, and appears to publish, but an ASP.Net error pops up complaining about MySql.Web. Even the status is set to published; the content just fails to make it...

XML Serialization tricks in .Net

We had some fairly complicated XML to parse here at the office yesterday. I’m going to give some examples here, but the node names have been changed because they’re part of a proprietary standard (I’m not really working with farmyard XML ;) ). This article is in C#. XmlArray annotation...

Mimic /usr/bin in Windows

In UNIX and Linux, you can create symlinks (shortcuts) in /usr/bin which let you run extra apps from the command line. I’ve made a few custom command line tools in Windows, and I want to be able to run them from the command prompt, using just their name. If you’re...

Coded

Coded is a Windows Phone 8 app for editing plain text documents, such as code. I wrote it to satisfy my own need for portable, usable, code editing, and I’ve field tested it a reasonable amount. It’s had about 1000 downloads. Coded is useful for editing all sorts of things,...

Don’t spell check code blocks in Microsoft Word

If you’ve pasted in code with syntax highlighting Select the affected code block, and go to Review on the menu strip or ribbon. Select Language\Set Proofing Language... and tick Do not check spelling or grammar. Creating a code block style If you want to type a code block and don’t...

Traverse PHP array in key order

Say you’ve got an array with numerical keys (which aren’t continuous), such as file information keyed by file modified time: //Make an array of all files in the directory './stuff' $fileArray = []; foreach(glob('stuff/*') as $file) { //Get the time it was last updated (int) $modified = filemtime($file); //Make a...