An odd confluence of TV weather forecasts this week warned that eight days of rain was due to begin on Friday and, right on schedule, an appreciable amount of precipitation started falling from the sky just past midnight with only occasional breaks throughout the day. The announcement of precipitation was not at all unexpected given the time of year. What I found peculiar was the number of evening news meteorologists who were in complete agreement with each other for the first time in months regarding longer-than-average rainfalls.

Looking Through an Umbrella

Springtime rains in this part of the country tend to operate in a 2-1-2-1-2 fashion. That is we'll have rain for two days, followed by a day of sun, then two more days of rain, then sun, and finally another two days of rain before a week of reasonably mild weather. This pattern is so consistent in the spring that locals tend to look at the sky and say ”おかしいなあ〜”1 when the weather does anything else. So for multiple stations to agree that we'll have 8 solid days of rain without a typhoon anywhere in the Pacific is noticeably uncommon.

Perhaps this is nature's way of encouraging people to stay home.

This past month has been quite a trial for a large percentage of the human race as people contend with virus concerns, food shortages, work stoppages, price gouging, and generally stress-inducing restrictions on the freedoms that many of us take for granted. As someone who has worked from home for the better part of two years, I've not been seriously impacted by the measures instituted by the federal and local governments regarding COVID-19. Sure, there are inconveniences and nuisances to deal with, but nothing that can't be overcome with a little patience or a phone call. From what the TV and print news has to say, there are likely a billion people who would gladly switch places with me2. That said, if we're able to ride this out with a little isolation and stricter hygiene practices, there are worse places to be stuck than at home.

Questions do abound, though. Not a day goes by where there isn't an article in the paper or a segment on the 7 o'clock news talking about a specific business shutting down for the last time. These are usually smaller companies that employ fewer than 20 people; the businesses that quietly add value to a community. With revenues wiped out and bills that demand to be paid, there are very few options when an organisation does not have six months or more of operational cash in the bank at all times. Companies started to feel the pinch at the end of January. Here we are two months later, and half the restaurants in the area have decided to shut down until the end of the pandemic. Two have closed forever. Manufacturing businesses have also been hit pretty hard with some slashing output by as much as 80% due to a lack of orders. People are being sent home. How will they pay their bills?

A lot of my immediate neighbours have long since retired and have the benefit of decades of savings plus a mostly-functional federal pension system that will continue to provide the financial resources required to weather this invisible storm. Reiko and I have also been setting aside money every month for our retirement, the boy's education, future trips, and general savings. Even if I were to be let go from the day job, the family will be good for quite some time so long as we're careful. The neighbourhood seems to be an anomaly, though. Not everyone has the same good fortune.

This, of course, leads to the ultimate question: what can I do to help?

Donating to food banks can help. Donating to the local community centre's recently started relief fund to assist people with covering important expenses such as rent will help. Is this enough, though? There's a very persistent "No" echoing around inside my head but I've yet to work out a better way to help people get through this difficult time.

When Nozomi and I are out for our walks and we see other people with their pets in the park, I will sometimes strike up a conversation and ask how they're doing. This little bit of community building can be quite helpful for people who live alone and are unable to congregate like before. A number of the neighbours, because they're well into retirement age, have been widowed for quite some time and have seen their regular club activities or get-togethers with friends get cancelled. The single most serious problem that people talk about is the isolation. More than one senior has said to me "You're the first person I've had a conversation with all week", which is terrible given just how often I've actively avoided social interactions throughout my entire adult life.

But now we have eight days of rain forecasted for the region and we're not yet done the first. If people were feeling cut-off before, this damp weather is going to exacerbate the problem. This issue cannot be realistically solved by volunteer or non-profit groups. It's going to take a community. But how can we do this if we are not supposed to be in the same room as others? How can we do this if we are not given the opportunity to get outside and maintain some semblance of normalcy?

After this week of rain there are going to be a lot of very lonely people desperate for some kind of interaction, and I can't shake the feeling that I'm not doing something worthwhile that might help reduce the feeling of intense isolation.

  1. Okashī nā ⇢ This would be translated as "It's strange" or, depending on nuance, "Isn't it strange?"

  2. My wife would not be happy with this. She's very paranoid about germs, so this Coronavirus scare has her on edge. She's implemented a strict "No Non-family members in the house" rule.

Creative License

An odd thought crossed my mind earlier today while testing some new functionality on the 10C platform involving content licensing. When I write code that is not being paid for by an employer, everything I create is under an MIT license. This means that people can take that code and do anything they'd like with it. Use it. Abuse it. Mock it. Knock it. Anything is permissible. Want to sell the code for your own gain? Technically that's acceptable, too. Just don't expect a warranty or the ability to pass any liability onto me, because that's outside the scope of the license. Other forms of creativity, however, are under a strict CC BY-NC-SA 4.0 license. In plain English, this means that you can copy, distribute, and adapt the things I share so long as there is appropriate credit given, the license of any adaptation is the same, and there is no commercial element involved1. This means that I am more controlling of my blog posts, podcasts2, photos, and social posts than of the only thing of value that I've been able to sell to the world.

The realisation struck me as peculiar given how freely I am willing to share things that actually have value. Why don't I write blog posts under a CC0 license, which is like the MIT license in that it means anything created is immediately in the public domain, owned by nobody, for anyone to do anything with. Heck, when it comes to control of the content I publish on here, I went so far as to build tools to actively watch out for and block content scrapers.

Putting a bit of thought into the conundrum, I came to the conclusion that I'm willing to share code for the following reasons:

  • there is nothing so special about what I code that others couldn't figure it out on their own
  • I learned a lot by reading other people's code, so this is akin to returning the favour for the next generation of developers

The reason I'm not willing to share my other forms of creation is as follows:

  • many of the things I write or share reveal elements of who I am

So coding is perceived as being generic enough to share. Writing, podcasting, photographing, and baking is specific enough to tie it to me as an individual.

But is this right? Something seems to be missing from the equation. There's a great deal of character to be gleaned from reading the source code for any project I've ever worked on just as there can be a lack of personality from a blog or social post that states a generally accepted fact without context or obvious purpose.

This is an idea that I'll need to invest a bit more time thinking through. In the meantime, feel free to peek through the source code for 10Centuries.

  1. There is also the stipulation that there be no legal terms or technological measures that legally restrict others from doing anything with my content that the BY-NC-SA 4.0 license permits. So wrapping up all of my blog posts into a digital book for sale on Amazon with DRM is a no-no.

  2. There haven't been any of these in quite a while. I should really dust off the mic and put something out.

Better Results

Over the last couple of weeks a good deal of work has been put into the 10C platform to do something about the excessive number of requests coming from bots and, for the most part, the measures are working like a charm. Known content scrapers are given a 403 "Forbidden" error. Bots looking for WordPress, PHPMyAdmin, or other exploits are given a 422 "Unprocessable Entity" with this happy response page. Contact form spam is way down, too. This results in not having to process about 60,000 SQL queries per day1 and, more importantly, having more accurate statistical data available for everyone. The "Popular Posts" segment on people's blogs is a prime example of this.

Popular Posts

Before making the necessary changes to better handle bots, every page load from a machine was treated the same way as a page load from a person. This resulted in some horribly skewed numbers when it came to "popularity" as some posts from over a decade ago consistently remained near the top of the list. Because the posts were so old, just about every content scraper knew the URL was valid and would come back to it quite regularly. However, if a real set of eyes is not looking at a post, can it be considered "popular"?


So, with the filters and content loading processes better equipped to determine whether someone is actually looking at an article on a website, we get better results that are both more accurate and more relevant. Looking at the 9 most-read items on my site, it's good to see that 8 of them were written this year2. Naturally, the items listed on other 10C-powered sites will see a similar improvement in the reliability of the categorisation.

Hopefully the next round of updates to the platform are just as productive as the most recent dozen have been.

  1. 60,000 SQL queries is not very many, but it does work out to about 30-seconds of CPU time per day. Less processing power means having slightly "greener" operations.

  2. The post from 2012 is an odd aberration, but it seems to be legit.

Stuck in the Past

A large percentage of the posts published on this site over the last six months have involved sharing memories of things that happened in my life many years or decades ago. My parents have often said that as we age we look back at the past with increasing frequency simply because there's more of it to revisit. This theory certainly seems to hold water, but I wonder if there's something more to it. Is the mind comparing the past with the present? Do the memories have a common thread that should be explored? Am I just imagining correlations where none exist?

That last one sounds to be the most probable.

At some point in the future I do wonder if it would make sense to try and sort the memory posts chronologically and try to put some sort of temporal marker in the timeline of this site so that someone scrolling through a visual representation of the archives page would see a reference to this post at some point around 2003 despite being written in 2011 and this other post around 19891. One of the long-term goals I have for the 10C blogs is to present some alternative ways of viewing a lifetime. People who write prolifically will document so much of their lives, intentionally or otherwise, and giving people the ability to navigate the long progression of then to now is an excellent way to provide context to other articles on the same site. It would be more interesting if multiple posts over a span of years was found to discuss the same memory or time period as it would allow for a more complete understanding of how the author has perceived that moment in history.

This sort of visual representation is quite far off, though. Past attempts to design this view have failed spectacularly, which means I'm not thinking about the problem correctly. The articles that people write are not simply data points, after all. They're fragments of memory and personality. Any solution that is going to represent a person's lifespan will need to do so from a humanistic approach rather than a mathematical one.

One thing is for certain, though: the best solution will not involve an infinite-scrolling page consisting of only letters and numbers. This simply will not work.

  1. I wrote "Paper Boats" in June of 2019? It doesn't seem like almost a year has gone by. I still remember typing that post.


The first time I went to price a "proper" workstation-class computer was in the summer of 1997. This was during my first semester at college and, being a geek in a computer science track, I figured that a Pentium Pro with it's 256KB of L2 cache and better multi-processing capabilities would be ideal for my coursework. The budget was $2500 CAD, which was almost every dime I had saved while working through high school. This was enough to pick up a decently-equipped Dell Dimension with an Intel Pentium 233MHz CPU with MMX, but I wanted a workstation-grade machine. One Saturday morning, I went to a nearby computer shop that was known for building solid machines for reasonable rates and was handed a price list.

Suffice it to say, there would be no Pentium Pro so long as I was in college.

In the end I wound up putting mobility ahead of power and picked up a used IBM ThinkPad 486 DX4/75 with 16MB RAM, a colour screen and no audio card for the small sum of $2000 cash1. The machine did quite well for as long as I had it and, looking back, it was certainly better that I did not invest time in working nights to afford the more powerful Pentium Pro2.

Since the summer of 1997, I've stuck to using consumer-grade equipment for all of my computing needs while looking at the workstation-grade equipment from afar, knowing that investing the amount of money required to obtain one was simply unrealistic even at the best of times.

With the historical context out of the way, I was recently reading Anandtech's "Best CPUs for Workstations: 2020 Q1 article and thinking about what I would do with such a machine. The suggested processors were generally over $1400 USD and would require a motherboard that costs about $500 USD plus another $500 for a good quantity of RAM. Then there's the case, the power supply, cooling, a video card (or two), NVMe storage with some slower spinning disks for less-accessed data. We can't forget a decent keyboard or nor a good pair of colour-synced monitors, either. All in all, the sticker price would start somewhere north of $5000 USD for a decent workstation, which is plenty reasonable for people who spend their days on computers and tax them with a great deal of important tasks.

This had me thinking: What do I do that requires a workstation-grade machine?

In 2020? Nothing.

A couple of years ago a case could have been made that a workstation would be an ideal tool to work with the large sets of data that I was processing, but a solution was found to offload the heavy work to ephemeral virtual machines when required. This worked out to be much cheaper than buying even a Dell Optiplex with a Core i9. Now, however, the most taxing thing I ask of my computers is to transcode online lesson video once or twice a month and compile Java-based Salesforce integrations two or three times per year. Consumer-grade equipment can do this just fine given the frequency that the work needs to be done. Twenty three years have passed since I first contemplated getting a workstation. I've never owned one, nor does it seem necessary given the state of modern computing technology.

As bizarre as it sounds, I'm a little disappointed in myself. Generally when I'm provided the opportunity to use a powerful computer, I try to make good use of it. However, if I'm not even taxing the relatively generic systems3 that I have the good fortune to use, what the heck would I do with a proper workstation? The hardware would sit idle most of the time.

This is an odd thing to complain about as "I can't make full use of a powerful computer" is not something that many people have ever said. It does inject a little more reality into what it is that I find myself doing most of the day, though, which is typing words that result in various pieces of data being collated, sorted, and presented as a rational block of information. Heck, given the state of modern phones, I could probably do 95% of my job from a recent-model iPhone or Samsung Galaxy with the right dongles to connect a keyboard and additional monitors.

So much for thinking about a workstation.

  1. As a 17 year old walking to the computer shop with that kind of money, plus the ATM receipts to show that it was most likely not counterfeit or recently stolen, I was very nervous.

  2. I worked nights loading trucks at a warehouse to pay for rent and food. If I were to buy an entry-level Pentium Pro machine, overtime would have been required. This would have resulted in getting to class late and in even worse condition.

  3. The work-supplied Mac is not a generic system but, for the sake of this line of thought, it is treated as such. The notebook has an Intel Core i7 that can handle tasks with aplomb, but it's no Xeon or AMD ThreadRipper.

Five Things

For the first time in almost a month the family and I spent time with people who live in a different house; Reiko’s parents. We all enjoyed a couple of hours in a park with several dozen other families, though at a distance. Since the boy was pulled out of kindergarten for the last week of February we’ve been pretty much isolated from the world. Sure, neighbours will say hello, but we don’t stand around and chat anymore. When we’re out for a walk or a bike ride, we keep to ourselves. When I’m out in the park by myself, I’m allowed slightly more space from people who might otherwise walk past in closer proximity. While I’m plenty accustomed to feeling isolated and alone in a country of 127-million, this additional layer of segregation is not at all pleasant.

Societal partitioning aside, the family is physically healthy and enjoying some of the warmer temperatures. So, without further delay, it’s time for another Five Things post.

Parents of Young Kids Have Given Up

We’ve been to a number of large parks this past week looking for a place where the boy can burn off some of his energy while also spending time outside and, at every location, it seemed the boy was the only person under the age of 25 that was wearing a mask. Even a large percentage of the parents out with their kids were without masks, which struck me as interesting. That said, a number of conversations that I’ve overheard recently boil down to this lamentation:

Kids are less susceptible to the virus and ill be damned if my children spend every day inside the house and playing video games.

Advice from medical experts be darned, parents will let their kids out of the house just so they can be out of the house. Reiko has tried for weeks to help the boy stay entertained and engaged since leaving school a month ago, but it hasn’t been easy.

Malls Are Still Crowded

This one strikes me as odd given the tone, pitch, and intensity of the news this past year. I had figured that the malls would all be ghost towns by now but, driving past, the endless sea of vehicles shows that many people will continue to shop inside enclosed buildings with recirculated air. Pachinko parlours are seeing similar situations, likely as the result of an incredibly bored population.

Franchise Restaurants are Busy, Independents Are Not

While it’s true that people need to eat, I was expecting that restaurants would shut down or switch to “drive-thru-only” service methods as a result of the government’s recommendation to have no more than one seat at a table. Instead, it seems that chains are as busy as ever while the independent shops are shuttering their windows. A couple of mom & pop shops around here have decided to simply shut down permanently, likely due to the week-by-week revenue nature of restaurants.

Schools Are Expected to Open in April

Spring marks the start of a new school year with millions of young people getting back to their studies in the first or second week of April. There was talk that the education ministry might push back the start of the next semester to June or July then cancel the summer break, but this seems to have been kiboshed for reasons unknown. As of this evening, kids are expected to get back to school in two to three weeks. Reiko and I are not yet certain about what we’ll do about the boy’s classes, given that he’s in kindergarten and not one of the higher grades where attendance is a legal requirement1?

”Everybody” Wants the Olympics Postponed … Except the Government and IOC

Every news program has yet another sporting team, domestic or foreign, demanding this years Olympic summer games be postponed until the autumn or some time in 2021. The Japanese government is loathe to do this for financial reasons and the IOC is loathe to do this because money, money, money, money. Regardless of what happens, the people of Japan will be paying for these damned games until 2050.

Hopefully the summer heat and humidity will slow the Chinese virus.

  1. Home schooling is certainly an option for some parents. The amount of paperwork the government demands for this is incredible excessive, though.

Dog Food

Earlier this week there was an update to the Nice.Social web client to replace the a vertical bar chart with a GitHub-inspired calendar heat map. The reasoning behind this was to provide a little more context for when an account might be active as well as answer the question of "how active is active?". Both charts were designed to be scaled relative to the account as they're not supposed to encourage any sort of competition. The bar chart would always show the week with the highest number of posts as 100% and this was carried forward with the heat map so that the day with the highest number of posts has the strongest colour.

While testing the accuracy of the chart's data, I took a look at my own activity detail and saw this:

My 10C Usage

The chart will likely surprise absolutely nobody, but it did make me think about some of the developers I've read about, met, or worked with who generally did not use the tools they created with the same amount of zeal or consistency as is displayed here. One of my previous colleagues explained that he liked to step back from his work as much as possible so that he could see the big picture rather than get lost in the details. Another told me that she was more interested in how people used the platform than the software itself. Both of these approaches are certainly valid and likely lead to a healthier approach to working on projects, but it does make me wonder if I'm an anomaly in the creator space.

Colleagues have often expressed surprise when they learn about the various things that I've created and use on a daily or near-daily basis, as though the idea of having a hobby that is essentially the very same thing as the day job is alien to them. Then again, maybe it is. How many people enjoy what they get paid to do at work so much that they'll do it at home for fun, too? I am truly fortunate in this regard. However, by making so much of the software I rely on, it's much easier to appreciate so many of the excellent tools that I rely on. Applications like Sublime Text, Sequel Pro, Pixelmator, and Byword get used so often that if I were to rent the software by the hour, they would quickly cost more than the notebook I run them on.

More than this, though, by using my own software it's possible to see where things fail. People who use systems like 10Centuries or the LMS or the textbook systems will report bugs from time to time but, from what I've seen time and again, most people try to ignore bugs and curse my name without ever letting me know there's a problem. This is suboptimal, so I need to use the tools as well. This often results in me seeing things that could be done better, or differently, or fixed, or made optional. The observations get coded and deployed. People then notice the changes or they don't. My overarching goal is to make the software as transparent as possible. People shouldn't ever need to think about how the system works or why it isn't working. That's my job. People should have the benefit of being able to search, publish, and share what they choose without taking the failings of my code into consideration.

There's still a long way to go before anyone can claim that 10Centuries or any of my other projects — personal or professional — approach perfection, but this is my ultimate goal. The only way to get there, though, is to dog food the work and use it just as much — if not more — than the people who might see where the software fails.

Walking Down No. 4 With an MD Player Cranked

The summer of 2003 was an interesting time. I was just starting to get back on my feet after moving to the west coast of Canada and, thanks to steady employment and a reasonable debt repayment plan1, disposable income was no longer a pipe dream. My computer at the time wasn't particularly amazing2, but it could handle all of the core things I wanted to do at the time; IRC, Age of Empires, and PalmOS application development.

Work at this point in my life involved the day shift at a printing shop about 5km from my apartment. I would wake up every morning at 4:15am, hop in the shower, then walk to work and punch in by 5:45 and begin taking inventory of the workload for the next 20 hours of printing, binding, and shipping tasks. The work itself was quite enjoyable, though I did sometimes take it far too seriously. What I enjoyed more, though, was all of the walking that was required. For where I lived, the first bus of the day would get me to work 20 minutes late, so it was a non-option. I could ride a bike, like some of my colleagues at the time, but I didn't trust my roommate to not steal it3. Walking, however, is free and easy to do. It also gives a person time to listen to things.

Before I warmed to the idea of listening to podcasts, music was on an endless loop on the headset every time I'd go outside. In 2003 I invested some money into a Sony MD player and five blank disks, which would offer as much as 7 hours of music. There was one disk in particular that I would start every working day with; the red one.

On the red disk was fast-paced techno, trance, and other forms of EDM4. The very first track was Yoji Biomehanika's Ding a Ling and it was the best way to start the day. At over 10 minutes in length, I could cover almost the first kilometre and a half5 of No. 4 Road, the main street closest to the apartment. Power-walking along the sidewalk of this generally-busy road at quarter-to-five in the morning was always a treat. There would often be fog for the first half of the trek and the smell of the nearby ocean. The air was heavy with the scent of various coniferous trees. Traffic was generally absent until I reached the busier Cambie Road midway in the commute.

Every time I listen to this particular piece from Yoji Biomehanika, I'm transported back in time via the mind's eye to this point, when I was young and foolish and had so much free time. This happened earlier today when the random shuffle of the music device6 pulled up Ding a Ling - 2002 Scot Project Remix for the first time in ages. Being alone at the time, I turned the music up just as it was on those mornings 17 years ago and imagined power-walking to the point where my muscles ached from the strain. Through the fog. Past the innumerable conifers. Heart racing.

Who needs a DeLorean?

  1. It's interesting how quickly a person can amass debt at a young age. Soon after moving to Japan, I ditched credit cards and went with prepaid Visas and MasterCards. If I cannot afford a thing in cash, then I cannot afford that thing. It is better (for me) to wait a month or two than to carry a balance and pay interest or — worse — max out a card and pay it back over a period of years. Aside from my house, every large purchase in the last 15 years has been the result of saving for months or years, then paying with cash or a bank transfer; including my cars.

  2. I purchased a used HP Pavilion notebook with a PIII/850MHz processor and 1GB RAM the previous winter to replace the missing computer in my life. And, because it was a notebook, I couldn't really get trapped in the monthly upgrade cycle like I had been for 4 years between 1997 and 2001, which is where so much of my debt had come from. In 2001 I built a machine that was valued at just over $10,000 CAD. It was a beast of a machine … and it wound up being too heavy to bring with me when I moved from Ontario the following summer.

  3. He eventually did. He took the bike in the middle of the night claiming he had a job interview across town and needed to get there on time, which is rich given the guy never worked a day in his life outside of selling illicit substances.

  4. Electronic Dance Music, primarily from European artists.

  5. I walked very quickly back then. I still do when out on my own. Nozomi has helped me slow down over the years, but fast-paced power-walking has always been my M.O. … particularly if there are objectives to complete.

  6. The current music device is usually the tablet, which has a much better battery life than the phone, but both have access to the music library. Almost a decade has passed since I last used the Sony MD player, though I still have the palm-sized unit in a box upstairs with just one remaining disk; the red one.

Fast & Furious at 19

One of my favourite movie franchises began almost 20 years ago. This is sometimes hard to believe, given the number of movies that I've truly enjoyed that have stood the test of time, but there's something uniquely special about this particular series. Some movie franchises, such as the Bourne series, keep us interested because of the adrenaline rush that comes from seeing the main character consistently stay one or more steps ahead of his adversaries. This series, Fast and Furious, remains one of my favourites primarily because it's one of the few sets of movies where I feel it's okay to "turn the brain off" before settling in to enjoy the action. I love racing cars. When I wasn't doing it for real while young and invincible, I was busy with EA's Need for Speed franchise of racing games. There is no point in denying that — deep down — I enjoy competing directly and vicariously in this arena.

Fast & Furious — Final Race

Today, while waiting for the boy to fall asleep, I decided to watch a little bit of the first Fast and Furious movie. This was a time when everyone was still quite young. Brian was a cop. Dom drove an import. The romances we saw at the end of F8 were just in their infancy. It was a simpler time. Nobody had expectations for a sequel.

The brain was squarely "off" before the end of the Universal Studios logo. Despite not seeing this particular movie for quite some time, we know what we're in for ahead of time. In the words of the immortal Rick Sanchez: Don't think about it. As long as you don't, the movie is thoroughly enjoyable. Races feel fast and real. The obvious product placements for Panasonic, Corona, Mazda, Corona, Subaru, Corona, and NOS are just part of the story. The bad acting, one-dimensional antagonists, incontestable plot holes, asinine catch-phrases, and throwaway supporting characters barely draw any attention. Heck, even the obviously forced attempts at swearing and rage can be taken in stride. All because we know ahead of time that this is going to be a stereotypical "guy movie".

Even after nineteen years, none of this bothers me. The movie is just as enjoyable now as it was in 2001 when I saw it in theatres. Except …

One thing that has changed over the almost two decades since this movie first came out is my reaction to the gratuitous use of scantily-clad young women. When I was in my mid-20s the shots of long legs, dark skin, midriffs, and fiery eyes captured my attention just as much as the Nissans, Mazdas, Subarus, and Hondas they stood beside. Now, though … I'm not at all interested in the "kids" standing next to the pimped out vehicles. If anything, they're in the way. I want to see and hear the cars, not a bunch of bimbos who — as per the script — are looking to get next to those who compete and win.

Perhaps this means I'm "old". Maybe it means I would rather just spend time with a car than a fickle sleeping partner. I'm content with either assessment. There's far more to life than sex, after all. A fast car and an open road can keep me content and mostly out of trouble for years.

This is perhaps what I like most about the Fast and Furious movies. They do the things that I would not dare do anymore, and I can live vicariously through this fiction. Running from the cops. Hijacking shipments. Screaming through a 30km school zone at 220kph. These are the actions best left to the world of make believe, and there isn't a better description of Fast and Furious than "a fantasy world where having the fastest car equates to freedom from responsibility".

May I never tire of these movies ….

Compliant Cookies in PHP

A number of years have passed since the last time that I've written about coding solutions on this site, but a number of people have asked me recently how they can have PHP record the SameSite=None attribute when setting cookies. ChromeLabs has a handy example page showing how it's done but, for people who need to have more attributes, this is how it's implemented in many of my PHP-based projects:

$attribs = array( 'SameSite' => (($isHTTPS) ? 'None' : 'Strict'),
                  'Domain'   => strtolower($_SERVER['SERVER_NAME']),
                  'Expires'  => {unix-formatted expiration time},
                  'Max-Age'  => {number of seconds},
                  'Path'     => '/',
                  'Secure'   => $isHTTPS,
                  'HttpOnly' => true,
setcookie( "{cookie name}", "{cookie value}", $attribs );

This little bit of code uses $isHTTPS as a boolean to understand if the site has an SSL certificate1. Expires needs to be passed as an integer in order for PHP to set the value to the correct 'D, d M Y H:i:59' format as outlined in RFC6265.

But My Server Isn't Running PHP 7.3 …

The problem with the solution I've outlined above is that it will not work if a server is running PHP 7.2 or older. In this situation, the solution becomes a little more complicated. For the sake of visual clarity, here it is broken up across lines:

$cookieStr = "Set-Cookie: $key=$val;" .
                        " Expires=" . date('D, d M Y H:i:s', {unix-formatted expiration time}) . " GMT;" .
                        " Max-Age={number of seconds};" .
                        (($isHTTPS) ? " Secure; Path=/;" : "") .
                        " Domain=" . strtolower($_SERVER['SERVER_NAME']) . ";" .
                        " SameSite=" . (($isHTTPS) ? 'None' : 'Strict') . ";" .
                        " HttpOnly";
header( $cookieStr );

This resolves the warnings in browsers like Chrome and Firefox that developers will see when testing their work and it ensures that cookies will be properly read and saved by browsers going forward.

Fun, huh?

  1. This is important in my development process, as my local tests are done without SSL certificates, whereas the live servers are all HTTPS.