Brain Phrye

code cooking diy fiction personal photos politics reviews tools 


Speak

I added a new [ Listen to article ] link to my pages. This is done via the SpeechSynthesis API that I played around with in my little spoken cube toy. The code to do it is in the speak.js file that each page loads. I’ve broken it out into a gist as I minimize all my js files when I publish. There are clearly problems with this. Some of them are due to the API, some are due to the fact that I pull the text directly from the article tags. Read more

Sarcasm (updated)

After years of complaining that the internet lacked a sarcasm font it seems we’ve decided on random mixed case for denoting sarcasm. Clearly we need a shell script to do this. Or rather, “cLearLY wE neeD a SheLl sCrIpT to do tHiS.” But I do find it useful, hence this recent addition to my home dir - ~/bin/sarcasm: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #! Read more

Shebang

The Laravel PHP framework uses environment variables to configure itself. There are ways to set envirnment variables for Apache but then you also need to set them for cron and for CLI scripts as well. On Ubuntu this is usually done with /etc/environment which is read by the pam_env PAM module when a PAM session is created. I wanted this to work on FreeBSD which was a bit of a learning experience into where free unixes are diverging. Read more

The Three Problems with EVs

Since I’ve had this conversation in person a few times, I thought I’d write it down. The are three problems with EVs that people talk about that aren’t really problems. However, the reality of EVs that makes those issues not-exist causes a number of problems. The three non-problems people talk about are cost, charging times and range. Costs are coming down and as time goes on the used EV car market is growing. Read more

Git http Serve

Sometimes it’s really handy to be able to serve out a git repo from your laptop. Say you’re at a conference or on a plane and lack an external net connection but can make a local network connection between you. Or you want to do some sort of local testing of a git clone or pull. I needed to do that recently and came across this article which described a really quick way to do it - though it’s instructions were a bit off. Read more

CI for your home dir

Once you start putting your home dir in version control, some more options start coming up. And with something like a personal gitlab instance those options multiply even more. Here I’m going to explore using gitlab’s CI features. I already discussed using gitlab’s ticketing feature to keep track of tasks. And previously I wrote about an update script for my home dir to keep the various tools I use current. However gitlab also offers a CI system which allows me to automate those updates. Read more

Surround

Every now and then I come across a new vim plugin that makes life way easier. Yesterday I came across one that I’ve already made use of twice. Which kind of indicates it solves a problem pretty well. The idea is that sometimes you have a thing surrounded by delimiters - double quotes, html tags, whatever. And you want to change or remove them. The surround plugin lets you do that with a few simple steps. Read more

Bash Letter Fun

For some reason I thought sorting the letters of the alphabet by the words we use to pronounce them would be amusing. So i wrote this. Column 2 is American-English, column 3 is Hiberno-English. Since it might be interesting to do other languages - at least ones that use these 26 letters - I wrote the script so it can handle more columns. The current results are: 1 2 3 A H R B D W E F L M N S X G I J K O P Q C T V Y U Z A B D W E F L M N S X H I J G K O R P Q C T V Y U Z The script is here: Read more

Reframing tic-tac-toe

A while back I recorded my high school tic tac toe program. I notice I failed to paste up the code, but I’ll do that in a later part of this. For now I got distracted by this video which reframed tic tac toe as a magic square problem. Which means I could just use math to see if a winning move had been made. So now I rewrote it in javascript here. Read more

Terraform and dynamodb

This post is mainly a reminder to myself, but if you work with terraform and AWS it might help you too. Say you decide to completely reset a terraform project. All AWS resources had been deleted outside of terraform and now you just need to delete the state file in s3 so you can start all over. aws s3 rm s3://tf-bucket/state/bounce-project.tfstate This is based on this terraform backend config: 1 2 3 4 5 6 7 8 9 10 terraform { backend "s3" { profile = "personal" encrypt = true bucket = "tf-bucket" region = "eu-west-1" dynamodb_table = "tf-bucket-state-lock" key = "bounce-project. Read more

Gamifying tedious work

I’m currently implementing a client library for a REST API. There are around 150 endpoints and while I automated a lot of the code generation there’s still a lot to do.

To make that easier I decided to gamify it a bit. I wrote a little shell script to show me some progress numbers:

Read more

Performance

A really interesting talk. As usual, metrics are important - but also as usual, the right metrics are important. If you think metric X relates to algorithmic performance, you need to actually show that’s true. And just because it used to be true, times change and maybe it’s not true anymore. In this case the idea that counting compares and swaps would predict sort algorithm performance was wrong because branch prediction, and to a lesser extent cache, in modern processors has a noticeable effect of time. Read more

Gitmojis

Started trying to do gitmojis for my commit messages. The idea is to quickly highlight what a change is with an emoji. It’s a neat idea, but old dogs need tricks to learn new tricks. To help learn this new trick I wrote this script to put gitmojis in my commit template message: 1 2 3 4 5 6 7 8 9 #!/bin/bash exec > ~/.gitmessage echo ":sparkles: New feature. Read more

Revisiting how to deploy ephemeral twitter

In my initial post on setting up my tweaks on Vicky Lai’s ephemeral, I made a manky shell script to do the deployment. I mainly did it because I was still a bit dubious about terraform. However for the past year I’ve gotten way more comfortable with it and used it in anger loads of times. It works rather well and seems to be improving at a good clip. Think of it as make but for infrastructure. Read more

FreeBSD ipfw Notes

Last week I wrote about fail2ban on FreeBSD. One note about that is that service ipfw restart seems to break all connections. This is frustrating / terrifying when you’re ssh’d into a machine and running that command. In my case I thought the box was inaccessible for a number of days before realising I could just reconnect (always test assumptions - advice I still fail to heed regularly). I’ve read a number of discussions about this, but the answer that seems best is in this answer. Read more

Diner

My primary memory of the diner was that is was brown. It was 1983 and interior design hadn’t fully shaken off the 1970s. Memory is odd. I remember the color of the diner, but not why we were there. I’m pretty sure it was for my great-aunt Cassie’s memorial, but that’s largely due to the timing and who was there. And I’m not really sure where it was - Concordia, Great Bend? Read more

Fail2ban on FreeBSD

I’ve come across a number of posts describing how to set up fail2ban on FreeBSD. Every damn one of them modifies a .conf file which is a fail2ban no-no. And the package in ports even tells you this: 1 2 3 4 5 6 7 8 9 10 Please do not edit the fail2ban.conf, jail.conf, or any other files in the distributen as they will be overwritten upon each upgrade of the port. Read more

Composer

I don’t tend to do much php but it comes up from time to time. The package manager for php is composer and it’s generally not in distro packages. So I wrote the following for my home dir to make it easier to get on the odd time I need it. This would go in ~/bin/composer 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 #! Read more

Systemd User

A while back I set up a CO2 sensor in my office. The setup requires a prometheus server to scrape it and a python script to get the data off the sensor and expose them for prometheus to scrape. I’ve been running it in two open terminals for several months now. You can upgrade Linux desktops without rebooting or restarting your desktop session for quite a while. Eventually though it will start getting kinda flakey. Read more

Brexit Timeline

This is a simple Brexit General Election calculator. It does not factor in public holidays. Enter the date and press return. Date No Confidence Vote proposed: Date of No Confidence Vote: Date to schedule election (14 days): Date of election (25 working days): Date of count (1 day): Date government formed (3 days): Some of these time periods are set in stone by the Fixed Term Parliaments Act (2011). Read more