Wednesday, 31 January 2018

Ouchie

I have an interesting relationship with pain. It's been a part of my life forever but not in the way that would make me seem like I'm feeling sorry for myself, or at least not too much.

I grew up with a significant other who had juvenile arthritis, developing into old-git arthritis when they reached their majority. They had one particularly severe bout of it when I was growing up that I can remember, and I'd never seen anyone suffering so much. The experience of watching them destroyed my illusions of what it was to be an adult as they spent what seemed like months getting over it, probably with the use of decent pharmaceuticals. They were undoubtedly hooked on something for years afterwards, and it took ages for them to get off of it (I think I would've stopped on it, TBH).

Then in adulthood, I spent a lot of time in pain clinics and thinking about pain in regards to another significant other. To say their pain affected me is, perhaps, an understatement.

I've had aches and pains since being a teenager. There was the bone chip stuck under my kneecap which stopped me playing sports except for table tennis at school (have you ever played table tennis against yourself for an hour straight: boring!). Then, when I worked nights, I'd often ask my colleagues to drag me along corridors by my legs to ease the pain in my hips. All these aches and pains meant that I was always taking painkillers of one sort or another - my favourite was co-proxamol, but the dodgy dossier put paid to that particular avenue, so it's been double up doses of Paracetamol and Ibuprofen for something like 15 years. And alcohol as well I guess, though that was partly down to needing a wee dram to get me off to sleep after a night shift.

I'd go and donate platelets and make sure I'd not taken any Ibuprofen for 48 hours or Paracetamol for 24. It wasn't always easy, and I had to cancel a couple of times because I'd forget (but only once or twice - nearly made it to 200 before the NSAID put paid to platelet donations). When asked if it were for something recurring I'd have to hold my hand up and say I'd been taking them since I was a teenager for various aches and pains. I had to wait a couple of times while the nurses at the donor centre liaised with medics to check. Check that someone who had near constant headaches, as well as aching fingers, wrists, elbows, shoulders, neck, back (upper and lower), hips, knees, ankles and toes, could donate platelets. They always asked about medical investigations, and I again said there was arthritis in the family and that so far nothing serious had been diagnosed. But I'd be given advice and told to see the GP, and off I went to donate. I always forgot to see the GP because multiple trips during my youth had revealed nothing - I wasn't being stoic, I just didn't want to waste time!

I guessed it was just something that was a little unusual about me... or perhaps everyone else felt like I did and I simply had a lower pain threshold than anyone else. Maybe everyone else ached, and it was merely that I was more sensitive to it, so I put it to the back of my mind and carried on. And I really did carry on! I went to the gym on a semi-regular basis on and off (definitely on at the minute, and it has been for over a year now). I cycled everywhere (easy to do in Cambridge TBH) and at one point had all three of my boys on the bike at once (#1 on a tag along, #2 in a bike seat between my legs and #3 on a bike seat behind me). Boy did we walk as well, whole days during the Summer holidays wandering around Cambridge, walking for miles, but my stride was getting shorter - I put this down to respecting the boys and not striding off and leaving them behind, but it was probably my crumbling hips.

Then, with the diagnosis of AS, I got prescribed a longer lasting and more powerful NSAID. But that was bloody odd! I was snappy as anything for about three days and a right miserable sod and quick to jump down the throats of anyone (sorry Katrina). Then that stopped, and I was right as rain - and was sleeping way past 05:00. Sometimes managing to sleep in, something I'd not managed to do in a long old time. No more staggering out of bed while it was still dark and trying to get myself moving with a cup of coffee, fag and the three S's.

I guess it's not easy trying to get the tone of this down right. I'm not looking for sympathy or anything, just trying to get my feelings down properly about my relationship with my failing body and it's near constant warnings to me (interesting euphemism for the pain that is). I'd been checked over about 18 months before my diagnosis and knew that I had an unhealthy relationship with carbohydrates, but that was solved by knocking bread, rice and potatoes out of my diet (and switching from bitter to lager). The type 2 diabetes is now classed as being in remission, so that worked a treat. My blood pressure is being treated with Statins and seems to be being slowly sorted. What I thought was angina was actually tennis elbow in my shoulder (though maybe it's AS as well?).

I ran out of the NSAIDs last month for three days and went back to Paracetamol and Ibuprofen until the prescription was filled. Not too much of a bother until I got them again, and again, I was a pain to live with for a day or three until I got used to them.

Then came an invitation to take part in a clinical trial. Coming off of them and having an MRI, going back on them and having another after they'd built up and having another MRI to check that they were of some therapeutic use rather than just stopping me feeling the pain. And I'm about a week in and aching again. I used to say that I knew I was alive because I ached, and that was the case, but I'm sort of getting used to living without constant pain. It's the transitions that cause the problem though.

So I'm a week into being NSAID free, and I ache, but I'm used to it now. Posture and exercise as well as eating a healthy diet are helping - as they did before - but I'm planning on what to do when I go back on them... as well as pondering not returning to them due to the serious grumps they seem to engender.

I'm not sure why that is the case though. I know that Paracetamol is linked to a reduction in empathy and there are suggestions that that reduction in empathy is down to a reduction in the pain subjects experience. Apparently feeling pain improves empathy... but that's an interesting thing, in that once my body is acclimatised to it I go back to being less grumpy... and I'm not 100% sure that my ill-temper is down to reduced empathy or just being a git generally.

Saturday, 6 January 2018

Btrax - Lights Go Down ( Remix ) [ Drum

Monday, 18 December 2017

FullCalendar Anatomy

This will detail discoveries about the FullCalendar plugin.

We're primarily interested in three views: month, agendaWeek and agendaDay. Further, we're only interested in the calendar itself and not the header (div.fc-toolbar).

I've written it in Markdown so I can scroll the container.

## month ##
The `div.fc-month-view` is within the `div.fc-view-container` and consists of a table with a `thead.fc-head` which has the days of the week and a `tbody.fc-body`.
* `tbody.fc-body`
    * `tr`
        * `tr.fc-widget-content`
            * `div.fc-day-grid-container`
                * `div.fc-day-grid`
                    * `div.fc-row.fc-week` **×6**
                        * `div.fc-bg`
                            * `table`
                                * `tbody`
                                    * `tr`
                                        * `td.fc-day.fc-widget-content` **×7 plus (`fc-sun`, `fc-mon`, `fc-tue`, `fc-wed`, `fc-thu`, `fc-fri` or `fc-sat`)**
                        * `div.fc-content-skeleton`
                            * `table`
                                * `thead`
                                    * `tr`
                                        * `td.fc-day-number`  **×7 plus (`fc-sun`, `fc-mon`, `fc-tue`, `fc-wed`, `fc-thu`, `fc-fri` or `fc-sat`), this is where the numbers are.**                    
                                * `tbody`
                                    * `tr`
                                        * `td` **if these have events then `.fc-event-container`, otherwise just empty**                           

## agendaWeek ##
* `tbody.fc-body`
    * `tr`
        * `td.fc-widget-content`
            * `div.fc-day-grid`
                * `div.fc-row.fc-week.fc-widget-content`
                    * `div.fc-bg`
                        * `table`
                            * `tbody`
                                * `tr`
                                    * `td.fc-axis.fc-widget-content`
                                        * `span`
                                    * `td.fc-day.fc-widget-content` **×7 plus (`fc-sun`, `fc-mon`, `fc-tue`, `fc-wed`, `fc-thu`, `fc-fri` or `fc-sat`)**
                    * `div.fc-content-skeleton`
            * `hr.fc-divider.fc-widget-header`
            * `div.fc-time-grid-container.fc-scroller`
                * `div.fc-time-grid`
                    * `div.fc-bg`
                        * `table`
                            * `tbody`
                                * `tr`
                                    * `td.fc-axis.fc-widget-content`
                                    * `td.fc-day.fc-widget-content` **×7 plus (`fc-sun`, `fc-mon`, `fc-tue`, `fc-wed`, `fc-thu`, `fc-fri` or `fc-sat`)**
                    * `div.fc-slats`
                        * `table`
                            * `tbody`
                                * `tr`
                                    * `td.fc-axis.fc-time fc-widget-content`
                                        * `span` **Time here (repeated for every half hour during the day)** 
                                    * `td.fc-widget-content`
                                * `tr.fc-minor`
                    * `div.fc-content-skeleton`
                        * `table`
                            * `tbody`
                                * `tr`
                                    * `td.fc.axis`
                                    * `td` **×7**
                                        * `div.fc-content-col`
                                            * `div.fc-event-container.fc-helper-container`
                                            * `div.fc-event-container` **Events go here**
                                            * `div.fc-highlight-container`
                                            * `div.fc-bgevent-container`
                                            * `div.fc-business-container`

## agendaDay ##
* `tbody.fc-body`
    * `tr`
        * `td.fc-widget-content`
            * `div.fc-day-grid.fc-unselectable`
                * `div.fc-row.fc-week.fc-widget-content`
                    * `div.fc-bg`
                        * `table`
                            * `tbody`
                                * `tr`
                                    * `td.fc-axis.fc-widget-content`
                                        * `span` **all-day**
                                    * `td.fc-day.fc-widget-content` **and fc-*day***
                    * `div.fc-content-skeleton`
            * `hr.fc-divider.fc-widget-header`
            * `div.fc-scroller.fc-time-grid-container`
                * `div.fc-time-grid.fc-unselectable`
                    * `div.fc-bg`
                        * `table`
                            * `tbody`
                                * `tr`
                                    * `td.fc-axis.fc-widget-content`
                                    * `td.fc-day.fc-widget-content` **and fc-*day***
                    * `div.fc-slats`
                        * `table`
                            * `tbody`
                                * `tr`
                                    * `td.fc-axis.fc-time.fc-widget-content` **these two cells are repeated every half hour**
                                        * `span` **time here**
                                    * `td.fc-widget-content`
                    * `hr.fc-divider.fc-widget-header`
                    * `div.fc-content-skeleton`
                        * `table`
                            * `tbody`
                                * `tr`
                                    * `td.fc-axis`
                                    * `td`
                                        * `div.fc-content-col`
                                            * `div.fc-event-container.fc-helper-container`
                                            * `div.fc-event-container` **Events here**
                                                * `a.fc-time-grid-event.fc-v-event.fc-event.fc-start.fc-end.fc-draggable.fc-resizable`
                                                    * `div.fc-content`
                                                        * `div.fc-time`
                                                            * `span` **time here**
                                                        * `div.fc-title`
                                                    * `div.fc-bg`
                                            * `div.fc-highlight-container`
                                            * `div.fc-bgevent-container`
                                            * `div.fc-business-container`

Saturday, 25 November 2017

Dom's Swan Song

Cross posted from Arcus Global's Blog where Nic Williams let me say goodbye. Thanks, Nic!

On the 30th of January 2010 I left my boat (I was living aboard, moored on Stourbridge common in Cambridge, at the time), unlocked and got on my bike and put my headphones on. I cycled along at a silly pace as I was listening to a cool French Punk band at the time. Getting to the Judge Business School took far too little time, and I locked my bike up and went looking for Lars. The next 45 minutes was such a fun experience I ended up emailing him afterwards and saying thanks and apologising for interrupting him – I know that that is seen as good practice in some areas, but not in nursing interviews. As I hinted, I came from a different career, full of people who practice active listening for a living and being able to talk about all the cool things I was interested in, without having to worry that I was being actively listened to, was just cool.

After a call from Denis, to check I knew what I was talking about, I was in and started in the beginning of March 2010 - encouraged to play with all the cool things I was, and still am, fascinated by. We soon won the Guardian Megas and Peter encouraged me to go up with Lars and Denis to accept the prize. One of the best nights I have ever had that was! I got to meet some fantastically bright people at work and not feel like a fraud as I could keep up my end of the conversation more often than not. I was even dragged in front of prospective clients who were so impressed they asked if I could assure them that I’d not disappear off to the Bahamas before the project was done.

We have grown such a lot since then, but I still feel valued, which is why my recent decision to leave Arcus has been so hard.

Arcus helped me more than I can ever hope to express when the worst tragedy rocked my family. Denis was a rock and let me witter on to him in the depths of my despair at ridiculous hours of the day and night – I dread to think what I was saying. That happened in the Summer and every Summer since I have had the urge to wander off. This year I have let the urge have its way, so I am leaving. It feels like leaving home. I have learnt such a lot and grown as a person and developer, but I feel its time to test myself somewhere else.

I no longer live aboard a boat but live in a house that I could not have afforded unless my efforts were rewarded at Arcus. Though being paid has always felt a little odd, as I code for fun rather more than for profit. I know I am not supposed to say that, but there’s nothing quite so much fun as being paid to do what you love. I love the fact that I am allowed, even encouraged, to disappear in my head and figure things out – though the waking up in the early hours with my head full of data structures can be disruptive. However, that is accepted at Arcus, I have popped into the office in the early hours of the morning and left in the early afternoon thanks to getting far more than eight and a half hours in and needing to rest if only to crack the next challenge.

The perks and the close-knit team make this the best place I have ever worked. The people are helpful and generous with their time and – I know I have said this before – frighteningly bright! This in itself is a challenge, but not in a bad way, rather in a way that encourages me to be brighter too.

So I will miss everyone at Arcus, and I hope that you continue to go from strength to strength. It is time for me to test myself though. Who knows, perhaps I will come close to finding a team of people who are as stunning, I do hope so.

Friday, 3 November 2017

p5 Pacman.js

I've been playing with p5js on and off for a while in order to generate some resources for use with Code Club and I've made (so far) Frogger, Snake and I've helped with Pong. Now I'm working with Pacman.

The thing about Pacman though, is that his jaws open and close as he's moving along and me and maths have an interesting relationship thanks to a somewhat spotchy formal education. Anyway, p5js has an arc so I was sorted. Sorted until I clocked that by default it uses radians rather than degrees, so much head scratching followed, as well as visits to the Khan Academy. And I got it working.

But p5js knows that people have issues with radians so instead of using radians I set angleMode(DEGREES);, neat eh?

The other thing about Pacman is that he moves and moves along 4 axes so the chomping needs to go in the direction of travel. Again I was stuck with radians until I realised that degrees would work (despite them being an arbitrary measurement). So I just had to rotate the start and stop angles of the arc by 90-degree increments to get this working - except that when Pacman was going right or up he flashed when his mouth was closed, so then I had to replace the arc with a circle if the gap was zero.

This is what I came up with:

if(this.jawWidth === 0){
    ellipse(this.x, this.y, this.r * 2, this.r * 2);
}else{
    let topJaw = this.jawWidth;
    let bottomJaw = -Math.abs(this.jawWidth);
    if(this.speed.every((e, i) => e === [0,-1][i])){
        topJaw += 270;
        bottomJaw += 270;
    }
    if(this.speed.every((e, i) => e === [0,1][i])){
        topJaw += 90;
        bottomJaw += 90;
    }
    if(this.speed.every((e, i) => e === [-1,0][i])){
        topJaw += 180;
        bottomJaw += 180;
    }
    arc(
      this.x, 
      this.y, 
      this.r * 2, 
      this.r * 2, 
      topJaw, 
      bottomJaw, 
      PIE);
}

I was not overly happy with it, but it worked. But what about just rotating Pacman instead? It turns out that that is even easier but does involve pushing and popping to ensure everything works properly - and that took quite a bit of head-scratching as well (It really is no wonder I'm bald). Anyway, here it is:

push();
translate(this.x, this.y);
if(this.speed.every((e, i) => e === [0,-1][i])){
    rotate(270);
}
if(this.speed.every((e, i) => e === [0,1][i])){
    rotate(90);
}
if(this.speed.every((e, i) => e === [-1,0][i])){
    rotate(180);
}
arc(
  0, 
  0, 
  this.r * 2, 
  this.r * 2, 
  this.jawWidth, 
  -Math.abs(this.jawWidth), 
  PIE);  
pop();

It's much more elegant isn't it?

Monday, 30 October 2017

Chomping through a string from the front.

I am quite keen on functional programming techniques, so I am sort of disappointed in myself today. I am disappointed because I have had to change the state of some data, but for the best of reasons considering the use case. I went so far as to write a class that did what I needed it to do without interfering with the original data, but that just felt wrong, as though I was hiding what I was doing and I am not sure if I should try to hide my guilt. On the upside, I did use recursion!

Anyway, my use case required some fragments of a string to be spat to a backend where they would then be stitched back together again. I could send the whole string in one go, but it could be arbitrarily large, so I need to chomp through it and spit each uniform chunk back to the server.

I spent ages thinking about it then, as is so often the case, I went to JSFiddle and wrote this:

const container = document.getElementById("data");
const ourString = "1234567";
const chunkSize = 2;

const sendChunk = (ourString) => {
    const chunk = ourString.substr(0, chunkSize);
    const div = document.createElement("div");
    div.textContent = `Sending: ${chunk}`;
    container.appendChild(div);
    ourString = ourString.slice(chunkSize);
    if (ourString.length) {
        sendChunk(ourString);
    } else {
        const finalDiv = document.createElement("div");
        finalDiv.textContent = "All Done!";
        container.appendChild(finalDiv);
    }
};

sendChunk(ourString);

Along with this simple bit of HTML:

<div id="data"></div>

Basically it uses substr and slice to extract and then remove a portion of the string. If the string still has a length it then repeats the process, otherwise it tells us we’re all done. Neat eh? I just wish it didn’t feel so dirty.

Wednesday, 30 August 2017

p5 Frogger

We've been playing with p5.js lately in order to generate some of our own resources for Code Club. I'm sort of really keen on using JSFiddle but I'm also conscious that it's not overly kid friendly - it's not unfriendly, but it is tailored to an adult audience who know what they're doing. So I thought I'd try using trinket:

Not sure if it's playable in its embedded form but the arrow keys should move it if it is.

Needless to say, it was mostly stolen from The Coding Train but adapted and converted into ES6 (not sure why I hated classes in Java but I love them in JavaScript).

The colours are fun: The red is a London Bus, the yellow is a DHL Truck, the blue are two Tesco vans and the three green ones are minis in British Racing Green...