- 
    I stopped taking Amitriptyline after a run of headaches and migraines and have instead decided to try two things: - Going for a lunchtime run around the local tarn twice a week, greeting the ducks as I complete two laps.
- Using the Pomodoro Technique to force me to take breaks throughout the workday.
 
- 
    I struggled to find a simple macOS application to help with the Pomodoro Technique but settled on Flow as it gives me a timer for four 25 minute sessions separated by 5 minute breaks followed by a longer 30 minute break. 
- 
    Yesterday, I realised my understanding of database transactions was wrong. I thought it was safe to do the following in Rails: Key.transaction do key = Key.where(name:).first_or_initialize key.update!(age: 42) endHowever, a concurrent transaction could write another Keywith the same name between thewhereand theupdate!. This would cause a conflict ifnameis unique.Using upsert (which uses PostgreSQL’s INSERT ... ON CONFLICT) would help but you still can’t rely on any state you read in that first query.If you’re only ever expecting UPDATEs to cause conflicts (and neverINSERTs), you can useSELECT ... FOR UPDATEvialock:Key.transaction do key = Key.where(name:).lock.first_or_initialize key.update!(age: 42) endIf you might have conflicts from INSERTs too, you can go for the strictest transaction isolation level and keep retrying your transaction in case there’s a conflict:begin Key.transaction(isolation: :serializable) do key = Key.where(name:).first_or_initialize key.update!(age: 42) end rescue ActiveRecord::SerializationFailure retry end
- 
    After watching Joel Spolsky’s “You Suck At Excel”, I replaced my overcomplicated budget.rbwith a spreadsheet that is both easier to read and produces numbers in which I have much more confidence.
- 
    We borrowed my dad’s car to drive the family to Cornwall and suffered the narrow roads and surprisingly spiky roadside foliage. Before we returned, I ordered an Autoglym Scratch Removal Kit as recommended by Which? and it worked on both our recent scratches and ones I’m now sure were the work of my dad over the past eight years. 
- 
    We had carpet fitted in C——’s bedroom though the fitter asked us to take up the floor and remove any large furniture beforehand. This led to us dismantling two IKEA PAX wardrobes and a cot before ripping up the wood floor. There was something cathartic about the totally empty room, stripped back to its stone underfloor. The carpets were fitted in a matter of hours but reconstructing the wardrobes in place (given the low ceiling) required three adults. Planing the doors that no longer fit was a perilous experience. 
- 
    While nailing the flimsy back to the wardrobe, I unthinkingly cautioned one of the people helping me by saying “watch your fingies!” 
Weeknotes #96
          By Paul Mucur,
          
          on