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...
Consider the following HTML and JavaScript:
<div data-ng-controller="controller">
<button data-ng-click="showTb=true">
Show TextBox
</button>
<div data-ng-show="showTb">
<form>
<input type="text" />
</form>
</div>
</div>
angular.module('module')
.controller("controller", [
"$scope", "$timeout", function($scope, $timeout) {
$scope.showTb=false;
}
]);
This is a basic example of a simple AngularJS setup to show a textbox. Now we'll edit it to fire the focus event.
<div data-ng-controller="controller">
<button data-ng-click="displayTb()">
Show TextBox
</button>
<div data-ng-show="showTb">
<form>
<input type="text" id="textBox" />
</form>
</div>
</div>
angular.module('module')
.controller("controller", [
"$scope", "$timeout", function($scope, $timeout) {
$scope.showTb=false;
var displayTb=function(){
$scope.showTb=true;
var ele
Posted on Tuesday the 28th of July 2015
Read more...
For this trip to the National Cycling Centre I chose my Arkose. There was no reason for this trip other than wanting to and having nothing better to do. I loaded up my panniers, checked my tyre pressure, entered the route into my phone. Set to do as little on roads as possible I set off from my home just North of Macclesfield. A few suburban roads and then on to the Middlewood way for seven and a half miles to Marple. Through Marple I followed National Cycle Route 55 where it terminated in Stockport. So far the route had been rather uneventful. I did meet a family in Marple trying to follow the route and gave information which reassured them they were on the right path.
I made my way to Stockport Road West which I followed until I my turning down Welkin Road. This led me to my next bit of off road pathway, which took me under the M60. I wish I took some pictures because it was the the most decrepit looking part, with [cycle gates](http://www.guerrilla-innovation.com/archives/britain
Posted on Sunday the 1st of June 2014
Read more...