I just finished an update to the site that should dramatically improve its download performance. I shrunk the images down a ton, and wrote some javascript that loads images in a more pleasing, controlled way.
When I first conceived this site, I was thinking of it mostly as a text based site. The photo aspect of it was thrown in as an afterthought. As time progressed I found that I really liked posting images more than anything. It has gotten to the point where well over half of my posts are images, so I was time to revise the way the site handles images. Load times were awful, because I was just dumping these big image files to the browser, and it would try to download them all at once.
I took a two-pronged approach to solving the issue: 1) reformat the images to reduce image size, & 2) make it so the images didn’t try to load all at one at time.
Just Make them Smaller
The way I upload photos to the site is using an iOS shortcut that I wrote, so it was pretty simple to go into there and revise the resizing function so it scales all the way down to 1000px wide (previously it was set to 2500px, which is kinda insane). And because of the nature of being a static site, it was really simple to go into my photos and use an app called PhotoBulk to tear through and resize them all. That process alone made the site 150% smaller, which frankly solved 80% of the problem.
Cicada Function
The way that I made the site serve images smarter relies on Javascript. I rewrote the HTML source code so that the HTML doesn’t actually download the file, but still has the link embedded as data in the img tags. Then I wrote a function that finds all the images and downloads them one at a time.
The cool thing about the function is that it’s what I’m calling a Cicada Function (I’m sure there is a real term for this that hardcore programing people know. Not me though.) The way it works is it takes the data in the img tag and reassigns it to be the image source, which causes the image to start to load. At this point the function is almost done, but right before it ends, it adds an event listener to the img that tells it to run this same function on the next image once this image is done loading. It’s like a loop, but the function is actually not running most of the time. Sort of like the way Cicadas sleep for years underground, and just emerge for a few days to lay eggs and die, restarting the cycle.
Honestly, I don’t know what the precise best practice for this particular goal would have been, but I think that this does the trick and it’s conceptually fun.
Much Better
This site has always been very performant by most metrics, so it’s evaluation by the web bots hasn’t changed that much, but the total page load times are like 3x quicker at least and experientially it’s even better, because you don’t have to wait nearly as long for the first images to load. So far it seems like the lower res images still have enough quality for the site, even if it’s not as fun to view them blown up to full size.
Enjoy!
❖ ❖
There’s a small scandal unfolding in the West Union Police Department I’ve been trying to follow. I became aware of it when I read an article about it in the local paper, the Fayette County Union, but it’s been unfolding for the past few months.
The Facts as I Understand Them
When I picked up the thread on the story, the situation was as follows: the lone female Police Officer in the West Union Police Department, Sierra Fox, had just submitted her resignation to the city council at their request. It is unclear to me who in particular made the decision to ask for her resignation, but it was requested in a meeting with the city administrator and at least 2 council members (the Police Committee). The reason, more-or-less, boiled down to there being a judgment made that she wasn’t performing to the standard of the job.
She submitted her resignation letter (which you can find here) several days later. Besides resigning her position, the content of the resignation letter that Officer Fox submitted included allegations against the WUPD Chief of Police, Paul Becthold. She claimed that he was abusive to her and treated her differently than other officers because she was a woman. As far as I know, this letter was the first public airing of this issue, but they knew about it internally. She submitted a formal complaint about these issues to the city on January 23, 2019. The city did some kind of investigation, determined that the complaint was unfounded, and Becthold was cleared of any wrongdoing. It seems as though the city was already trying to address performance issues with Officer Fox prior to January 23, when she submitted her complaint.
On February 9 (which I believe, but am uncertain, is after the initial internal investigation was completed), she submitted a formal complaint to the Iowa Civil Rights Commission. I believe that complaint is still unresolved. In her resignation letter, she claimed that she was being forced to resign in retaliation for submitting these complaints. She’s worked in the WUPD since 2015 and claims to have only started having trouble when Becthold took his position as Chief of Police in September 2017. He was previously Chief of Police in Nashua, starting in 2014.
Alongside this resignation letter, Officer Fox submitted supporting materials that included two sworn affidavits by former WUPD officers corroborating many of her claims—specifically about the sexist and derogatory language that Becthold is said to have used about Fox and other women, and about various ways Becthold acted inappropriately toward Fox. These examples go back to January 2018 and include an allegation that he pressured and lied to her to convince her to leave the Teamsters Union because it would supposedly allow the police force to go from hourly wages to salary.
The resignation letter also includes the six performance complaints that were presented to her at the meeting where she was asked to resign. They broadly related to things like time usage, responsiveness, coordination, K-9 responsibilities, and equipment maintenance. There are obviously more details—especially regarding her dog (she was a k-9 handler)—but those were the key facts that jumped out at me as being most important.
Most of this information is based on documents attatched to Fox’s resignation letter, and the reporting of various news orgs. Since reading through the documents, I’ve learned a couple of interesting things from talking to people. The most notable is that it appears that an external firm has been hired to re-investigate Becthold. For some reason, at this point I don’t believe that’s been publicly disclosed. The second is that there might be a good deal more documentation that has not come to light that indicates that Officer Fox was justly terminated—there is at least a genuine impression among some people in law enforcement that she wasn’t a particularly good officer.
What Does it Mean
My immediate reaction is that this looks bad for both Becthold and the city. The fact that there are two officers willing to corroborate many of her claims and vouch for her competency as an officer, makes her own claims seem that much more credible. If Becthold has in fact been behaving as she and the other officers describe, then he definitely shouldn’t have a job on a police force, let alone be Chief of Police. And if the claims are true, the city bungled the initial investigation of Becthold and then continued to enable Becthold’s retaliatory behavior without enough skepticism (I don’t have any reason to think they were acting spitefully themselves). Even if Fox had performance issues, the described behavior by Becthold is obviously unacceptable if true.
My evaluation of the situation is that 1 of 4 things can be true:
1) Officer Fox is an incompetent police officer who has fabricated these allegations as leverage to keep her K-9 partner, get a cash pay-out, and restore her reputation, and she has somehow convinced two other officers to corroborate her lies.
2) Chief of Police Becthold was sexist and abusive toward Officer Fox, but she also has some shortcomings as a police officer that justify removing her from the police force that exist independently of Becthold’s sexist behavior.
3) Officer Fox is a good officer who hasn’t been performing up to her potential as the result of the toxic, sexist environment created by Chief of Police Becthold.
4) Chief of Police Becthold has been extremely abusive of Fox and maligned and mischaracterized her so broadly that he’s convinced the city administration and members of the law enforcement community that she is a terrible officer, even though she is performing perfectly well.
I’m open to any of these possibilities being true. On their face, I find the affidavits submitted by the two officers to be very persuasive and realistic, and I think it would be remarkable for them to have been fabricated. I could be convinced otherwise, but for Possibility 1 to be true, it seems like those affidavits need to be demonstrated to be false. That said, I think the truth is likely somewhere on the continuum of Possibilities 2, 3, & 4.
On the other hand, the city investigated Becthold’s behavior and cleared him. I have little insight into how that investigation was conducted. In the documents I’ve seen as part of this release I’ve found 2 references to the investigation: 1) the mayor and city administrator interviewing Chief Becthold directly, and 2) Officer Moore meeting briefly with the mayor and city admin and not having time to discuss the sex discrimination against Officer Fox.
I don’t know about the backgrounds of the mayor or city admin, but I suspect neither are trained investigators or interviewers. I’m very open to learning more about that investigation. Based on those two lonely data points I feel a little uneasy, but that’s a very tentative impression. Hopefully, the investigation was sufficiently skeptical of Becthold and there were more people involved than just the mayor and city admin.
What Should be Done
First of all, I want to say the people in the West Union City Government are public servants and even if I think things should be handled differently, their service is still very much appreciated. This is a tough situation, and even if there were mistakes made in hindsight (which may not even be true), that doesn’t mean they are incompetent or anything like that. This is tricky. And there’s a good chance I’m wrong about lots of stuff.
I think it’s good that the city has hired an external firm to investigate the situation (assuming this is true). In the meantime, I think it would be appropriate to ask Chief Becthold to go on leave while this investigation takes place. Even if Possibility 1 proves to be true, putting him on leave is the responsible thing to do and does no harm.
I would urge the city to be more transparent about the situation. The allegations against the WUPD Chief of Police are extremely troubling and they need to be addressed publicly. For now, it could be as simple as saying, “We’re aware that new detailed allegations have come to light regarding Chief Becthold, and we’ve hired an external firm to investigate the matter.” Ultimately, the results of the investigation need to be shared, and if Becthold remains Chief of Police, an absolutely bulletproof explanation needs to be provided.
Questions I Still Have
Obviously, not all of these questions will be answered publicly, but here are some things I’m wondering about:
- How was the initial investigation of Becthold conducted?
- Is there, in fact, a new investigation underway? If so, why hasn’t it been publicly disclosed?
- Are there more officers willing to corroborate accounts of Becthold’s alleged to behavior, and to what extent?
- Has Becthold supervised any female officers before?
- Has staff turnover under Becthold been unusual in any way?
- What are the relationships of the two corroborating officers with both Becthold and Fox?
- How much additional documentation is there of Fox’s performance issues?
- Fox claims that she has logs and documentation contradicting several of the complaints against her. Is that true?
- Is there any documentation of performance issues with Officer Fox that predate Becthold’s time as Police Chief?
- Is there corroboration that Officer Fox was pressured to leave her union? If so, why?
- How does union membership affect the city’s ability to dismiss police officers?
p.s. If you happen to have info that can help inform or correct the public accounting of the situation you can email me at benjfriedrich@gmail.com
❖ ❖
We put Dewey down today after a long slow decline in health. He was a Welsh Corgi and was about to turn 16 in May. It was past time, but still very sad. His mother was my dog, Taff, and his father was my brother’s dog, Govan.
He lived all of is life, from birth to his final days, at the same home. He slept under the steps in the summer and in the porch in the winter. He loved food more than any other dog I’ve ever met. When he was a pup, we fed him separate from the other puppies, because he would eat all of the food before the others got any at all.
He’s buried in the windbreak, alongside his mother and father.
He was a good dog. Rest in peace, buddy.
❖ ❖
There are two reasons this website exists. The most sensible one is that I miss having a website for just posting whatever. I miss blogs and I think it’ll be cool to have one site I can use as a hub to point to my other projects.
The other reason is that I wanted to try out a new (to me) web development stack I think is interesting. When I build a site from scratch I’ve mostly used Wordpress as the content management system (CMS). Wordpress is fine but has drawbacks. It can be unwieldy and overbuilt for a lot of uses, setting up a Wordpress site so it runs fast can be finicky, and the whole software and plugin overhead around Wordpress can bloat up really quickly.
Instead, I wanted to set up this site as a static generated site, which I think turned out great. I ended up with this lightweight, fast site that I’m able to host totally free, and I can make work in the way that suits me.
The rest of this post is about the technical side of the site, so if you’re interested, read on!
Static Sites
Here is the way traditional websites built with CMS’s work: when someone wants to view a webpage they make a request to your web server for a page, and web server gathers all the data it needs, assembles the page, and sends that info back to you. That’s a lot of work, especially if lots of people are visiting a site. There are ways to make this more efficient (namely caching, which helps a ton if it’s set up correctly), but that’s the principle. These traditional monolithic dynamic sites are assembled on the fly, which means if something goes wrong, your site gets slow or goes down.
The development stack I’m using for this site is built around something called a static site generator. What a static site generator does is it creates the entire website all at once, only regenerating the pages when you actually update the website. So instead of assembling the webpage from scratch every time a web browser visits a page, all the pages have already been created, so it just has to send out that pre-made file to the user, which is easy.
What this means, practically, is that you can create a website that is highly efficient and won’t get overloaded, and is also much more secure than a website built with a traditional CMS like Wordpress. Once the site has been generated, not much can go wrong.
The other interesting attribute of a static generated site is that the content of the site is stored as text files in folders. There’s no invisible database. It’s just like files in your finder. This can be a good thing or a bad thing depending on your needs. For my uses, I think it’s great. It gives me a lot more flexibility.
Deployment: GitHub
My deployment system is built around GitHub. Since the content for a static site is just files in folders, you’re able to manage and deploy the entire site via git (which is a commonly used version control system that makes it so you can restore old versions of your code if you break something). This is cool because it fully backs up and versions your site and your content, and you can sync it between multiple locations. GitHub is the de facto web-based git repository host of choice for most developers, and I have a free account already, so I decided early on that I’d use GitHub as a middleman in my deploy process.
Here’s how I decided I wanted the site deployment process to work: I make edits or write posts > I push the updates to Github when I’m finished > Github tells my web server that there are updates > the server pulls the update from Github > the server, running the site generator builds the site.
Static Site Generator: Jekyll
A static site generator is the tool that takes your content and your templates and converts them into actual web pages. You can run the generator on your local computer, output the site there and then send it to your server, or you can have the server running the generator by itself. I decided early on I didn’t want to generate the site on my personal computer, because I wanted to be able to update the site from my phone, so the generator needed to be hosted on the server.
In hindsight, I wish I had researched the different static site generators more before I started on the project because there are lots of great static site generators. I went with one called Jekyll basically just because I’d heard of it. It was one of the first ones in the category and is still the most popular. Jekyll is good, but after I was mostly done with the project I checked out the other options and I think I should have given Hugo a closer look. It’s supposed to be a lot quicker at generating sites than Jekyll. This doesn’t affect the speed the user gets the site—just how fast new changes get uploaded.
That being said, I enjoyed working with Jekyll and found it to be pretty simple. I had to install a plugin to support pagination, but that wasn’t bad at all. If I feel like build times are ever getting out of hand, maybe I’ll convert it to Hugo.
Web Host: Netlify
There were two options I considered and tested. I could use the virtual private server I already use to host my other sites, or I could try out a service specifically designed to host static sites.
The virtual private server I already have running is a Digital Ocean Droplet that just costs $5 a month. I really like it. I have it running on NGINX, and it’s easy to add new sites too. Getting the site up and running on the server is something I felt comfortable with (you just have to SSH into the server > install Jekyll > download your site from GitHub > generate the site pages > set up the NGINX config files so it knows when to serve the site)—the problem for me is that I don’t know as much about triggering the site to download new updates and generate the site. I didn’t want to have to manually SSH in, pull down the new data, and build the site each time.
The way that you could get the server to download the files and build them automatically is using a thing called webhooks. You can configure GitHub to send out a webhook notification to your server whenever the GitHub hosted data is updated and have that notification trigger a script on the server that will make the server download the updated files and run the build process. It probably wouldn’t be too hard to figure this out, but I’d need to install some new software, and I didn’t feel like messing too much with that server since I’ve got all my other stuff running on there.
The other option I looked at (the one I went with) was using a service called Netlify that is specifically designed to work with static generated sites. For my purposes, it seems like it is just plain a better option than hosting it on my virtual server. They have a free tier designed exactly for sites like this (which is cool), they have a full-scale content distribution network, they can automatically sync up with your GitHub, and they can set up your domain name stuff for you (which isn’t hard, but it’s slick).
For me, there were a bunch of advantages over using my own server. One of the biggest is I didn’t need to figure out webhooks, but there are performance boosts too. My server is in New York, so in the US it is quick, but if you’re in Australia it’d be a bit slower. Netlify has servers all over, so this isn’t an issue at all. Basically, it’s better in every single way for my use, with the exception that I had to set my main domain as www.bnjmn.us instead of just plain bnjmn.us. Not a huge deal, but I prefer the latter. Oh well.
One option that I didn’t really consider was hosting it using GitHub Pages, but this would have also been an option. It’s less flexible than Netlify (you can’t have any plugin dependencies it looked like), but it’s also free and seems like it’s probably reliable. Lots of people think it’s great.
Updating Content
Because of the way I have the site set up, there are a bunch of ways for me to update content. I can do it locally on my Mac using Ulysses (or any text editor) and push it to Github. I can log into Github and update it directly. Another cool option is this web app called Forestry.io that you can point at your Github repo and manage the files inside using a nice interface that you can access from anywhere.
The trickiest part of adding posts is making sure that the headers (technically they are called front matter) and filenames of the text files use the proper conventions. On the mac, it’s easy enough because I have templates, but one cool feature using Forestry.io is that it has tools you can preset those headers in whatever way you need to. It also lets you specify where you want to serve photos from, and lets you upload them directly.
The one thing I haven’t implemented yet, but intend to, is the ability to publish Asides via this great little iOS app called Drafts that makes it easy to do random stuff like this with text. Basically, the plan is to use drafts to format the text and have it send the formatted text to an app like Working Draft (at least that’s the first one I’ll try) to add the file to the GitHub repo.
Conclusion
For something that is technically a simpler process than a Wordpress site, it is complicated in its own way, because it doesn’t hide the process from you like Wordpress does. The cool thing is that it’s modular. I can get the features I want and the resulting site is super light-weight and I can easily swap out tools at any point. It’s organized in a way that makes sense to me and it’s fully backed up via GitHub.
I can see a setup like this being interesting solutions for lots of low-maintenance, small business and organizations. It has extremely low upkeep cost, it doesn’t require software updates, and it is remarkably straightforward to make edits, especially if you set someone up with one of the faux CMS’s, like forestry.io.
For now, I’m just going to use it and see how it goes.
❖ ❖