Making Postgres date_trunc() use a Sunday based week
Postgres provides a function called date_trunc()
which rounds a timestamp (or date) to various granularities including:
Life, the universe, and everything
Postgres provides a function called date_trunc()
which rounds a timestamp (or date) to various granularities including:
Did you ever Google for a solution to something, find one, then wonder who wrote it only to discover it was you ? Well as of today I have. There had to be a reason the code looked so familiar and it fit my problem so perfectly I wasn’t even paying attention to what website I was looking at that.
I recently had the need to convert a 64-bit hex string to an INT64 value in a BigQuery
user defined function (UDF). I’ll post more about why later but for now lets just say
you have a sixteen character hex string such as 7FFFFFFFFFFFFFFF
and need it as an INT64
value. Easy you say, just prepend “0x” and do CAST("0x7FFFFFFFFFFFFFFF" AS INT64)
.
But what if you have something just a bit bigger, like 8000000000000000
? Let’s try that:
For the past six months I’ve been using Brave browser exclusively for my personal browsing on my work laptop. I used to have multiple user profiles set up in the standard Google Chrome browser but I wanted an excuse to be using Brave more and I was tired of our corporate Slack messaging tool always opening work web pages in my personal Chrome profile. Brave is based on the open source Chromium which is the foundation of Chrome browser but comes without the Google tie ins and “call home” stuff that increasingly creeps out a lot of people as Google increasingly loses its “Were not evil” shine in the public eye (rightly or wrongly). Since Brave added support for all Chrome extensions it was pretty much a no-brainer to make the switch - very strong ad-blocking, device tracking blocking, etc, etc.
This is the first post of my new Jekyll and GitHub pages powered blog. Thanks to Barry Clark’s Jekyll Now repo for making it easy and not requiring any commandline tools, I can add and edit posts online with GitHub or since it using Markdown format for posts I can use the excellent StackEdit to edit pages and push to GitHub. Once I’ve finished messing with DNS this will also be registered with Basic Attention Token as a channel for publisher rewards when anyone using the new Brave Browser visits. Eventually Brave will show ads for those that don’t want to contribute, and ad-free pages for those that do. In the mean time enjoy an ad-free experience. You’re welcome…