One of the major drawbacks with Umbraco is the need to manage the config when making a new deployment over an existing one. When you're in a managed environment, such as Azure App Service in my case, you can't log on to a box to do the usual backup/deploy/restore so easily. Also; I don't want to have to do that every time I want to deploy, particularly for a CI environment where multiple developers could be pushing multiple times a day.
So why not just commit the config changes after install, then you don't have to do that, I hear you ask? Well I also don't want to have to delete the install specific config when deploying to a fresh environment, or when a new developer pulls the repo.
To start the process I put in a git clean filter to strip out any install specific config. Now developers won't be able to commit their environment specific config and mess up the deployment. I've described how I did that [here](/blog/view/git-ignoring-specific-lines-prevent-personal-config-being-co
Posted on Friday the 7th of February 2020
Read more...
When working on a microsevice architecture utilising AWS lambda my team and I were finding that it was taking over 30 seconds to complete our web requests after the service had been idle for a while (AWS kills lambda instances idle for greater than 15 mins). This was a problem for 2 reasons; the lambda function sits behind API gateway which has a timeout of 30 seconds, and it's unacceptable to have a request take that long. We needed to improve this situation and we had two obvious options; stop the lambda from being idle, and improve startup performance.
And with a microservice architecture this is exacerbated because each service you talk to has to go through the startup procedure.
Stopping the idle lambda from dying
There's a common concept among those that have used AWS lambda in the past to serve up sites: warming. This is basically when there is a scheduled job to call the lambda at intervals below 15 minutes in order to keep AWS from killing it. This can either be a se
Posted on Saturday the 25th of January 2020
Read more...
When you're dealing with a microservice architecture solution, it's likely you have a lot of small repositories. Keeping them up to date can be a pain, so I wrote a simple script to update each directory:
Bash:
#!/usr/bin/env bash
for f in *; do
if [ -d "$f" ]; then
cd $f
git pull
cd ..
fi
done
Batch:
@echo off
FOR /D %%f IN ("*") DO (
cd %%f
git pull
cd ..
)
Pretty basic stuff; just goes in to each directory and does a pull. Saves having to do the same thing yourself. Particularly useful if you've not picked up the project in a while.
Posted on Wednesday the 22nd of January 2020
Read more...
This site has been a thing of neglect. I've been looking at it from afar thinking about how I should just put it out of its misery. It was written in PHP in a self rolled MVC framework many years ago. At the time I was happy with what I accomplished with it, and I learned a lot from doing it all myself, but it's not aged well.
So I've redone it from the ground up in ASP.NET Core MVC. It uses markdown for the blog entry now instead of my own parser, it includes a list of my 5 most recently worked on projects in the nav, and has a much more basic front end design. I've gotten rid of all the Javascript because I don't really need it. The design is a bit ugly, but I'll get round to investing some more time in it at some point (yeah, right).
I'm hoping with this much simpler setup that I will write down some of the more interesting challenges I've had to overcome and their solutions. There's a few things I've had to do that I wanted to write about, but didn't want to deal with the web
Posted on Friday the 3rd of January 2020
Read more...
I recently had a project at work that I wanted to pass in a JSON string as a means of configuration. There is a .NET package that will read in a JSON file, but not one to read in a string. So below you will find a set of classes I made to take in a JSON string and parse it in to the application config using the Newtonsoft JSON library.
public static class ConfigurationExtensions
{
public static IConfigurationBuilder AddJsonString(this IConfigurationBuilder configurationBuilder, string json)
{
configurationBuilder.Add(new JsonStringConfigurationSource(json));
return configurationBuilder;
}
}
public class JsonStringConfigurationSource : IConfigurationSource
{
private readonly string _json;
public JsonStringConfigurationSource(string json) => _json = json;
public IConfigurationProvider Build(IConfigurationBuilder builder) => new JsonStringConfigurationProvider(_json);
}
public class JsonStringConfigurationProvider : ConfigurationProvider
{
private readonly string _js
Posted on Wednesday the 3rd of October 2018
Read more...
Since my posts heading in to the world of home automation I've gone on a bit of a saga. I've abandoned Home Assistant, as I wasn't happy with the way it functioned; I found creating rules for it far too obtuse if you wanted to do anything more than turn things on and off based on a single event. My response to this was, of course, to write my own software for it.
The idea behind my implementation is to simply be able to set rules up through a GUI. There are 3 main parts to it: the core backend, the web interface, and the components. It is currently in active development, and by no means complete, but functions enough to have fully replaced Home Assistant for my needs.
The backend is written in C# (Mono compatible) and uses a simple message bus system to allow each object to communicate. It has triggers which contain a set
Posted on Saturday the 30th of September 2017
Read more...
For one of my Sonoff switches I'm using a timer to ping my PC so it switches everything off with my PC (see code). Originally, for the sake of time (forgive the pun), I ripped code from [url link="]this page[/url]. However, it was a bit more complicated to use that I anticipated and resetting the timer interval didn't always work (I don't know if it ever did, tbh). So I wrote my own, with significantly fewer lines. The only major disadvantage is that you can't register multiple timers under one loop method.
Anyway, here it is:
#ifndef _TIMER_h
#define _TIMER_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif
#include <functional>
class Timer
{
protected:
int _interval;
std::function<void()> _callback;
unsigned long _lastRunTime;
bool _enabled;
void constructor(int interval, std::function<void()> callback, bool startImmediately);
public:
Posted on Saturday the 25th of February 2017
Read more...
It's been nearly a year since my last post. I had no idea it'd been that long!
When I last posted I was trying to get some control over the boiler in my home. This sort of worked for a while until the relay in the receiver unit seized. It was replaced with a new unit that's totally different. It uses the 868MHz frequency instead of 433MHz. I did get a transceiver, going by the catchy name of nRF905, to attempt to communicate with the new receiver unit, but failed to get it working with the RPi. I have not had another attempt at it for a while.
The code for the thermostat Pi has not gone unloved, however. See here for the code as it currently stands. The main change is that it can now publish to MQTT, and that I've massively sped up reading from the sensor.
Further towards the home automation goal I've found these Sonoff units. They use an ESP8266 chip which can run Ardui
Posted on Saturday the 28th of January 2017
Read more...
My DS18B20 sensors arrived the other day. Using Adafruit's tutorial on the sensor I was able to get a reading out of it in a matter of minutes. During Friday evening I was able to knock up a quick thermostat script.
import time;
import sys;
import RPi.GPIO as GPIO;
targetTemp = 21;
sendPin = 24;
sendAttempts = 3;
tempSensor = '28-03157469ceff';
onCode = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1];
offCode = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1];
def sendSignal(code):
signal = False;
for t in range(sendAttempts):
for i in code:
signal = not signal;
if (signal):
GPIO
Posted on Saturday the 12th of March 2016
Read more...
Since forever I've always been enamoured with the idea of home automation, but it's always been beyond my reach for one reason or another. Lately the blocking factor has been that I'm renting so I can't really pull apart the makings of the house. Fortunately, however, the house I'm in now has a wireless thermostat, which means I can control the heating without any intrusive measures as it uses the 433MHz band.
I have managed to replicate the wireless signal that the thermostat sends to the boiler for both the [i]on[/i] and [i]off[/i] commands with a Raspberry Pi and a cheap 433MHz receiver and transmitter. This instructables article was instrumental in understanding what I needed to do in order to get the job done. This blog post was
Posted on Sunday the 6th of March 2016
Read more...