Posts
Vue.js with dark mode while taking system preference and user preference into account
tl;dr - A vue.js example of adding dark mode support to your website that takes system preference and user preference into account. See link image/svg+xml for source.
When you are developing a website with dark-mode support, there are usually two paths you can take:
Use the [prefers-color-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) CSS media feature and thereby use the system preference. Use a website setting to set a .
Posts
How not to get the row count in InnoDB MySQL
Yesterday I had to migrate a MySQL schema to a new server. Fun times. After I had finished the migration, I wanted to compare whether no data was lost. So I turned to Stackoverflow to find me a good MySQL command that would give me the row count of all tables in the schema so I could compare it to the schema on the old server. The command I used was:
Posts
How to move an off-screen application window in Windows 11
As I frequently disconnect and connect monitors from and to my laptop, a bug(?) in Windows 11 causes the windows of application to disappear sometimes. This usually happens with [Zettlr](https://www.zettlr.com/), my note-taking app of choice. This frustrated me endlessly, as I want my notes to be easily accessible. But now I think I found a solution to make the window appear again.
Simply press alt + space whenever the disappeared window is active.
Posts
Wordpress custom blocks: Pass down attributes to child blocks
Suppose you are working on a set of interacting custom blocks in Wordpress. You have a child block that needs information from the parent block to display, in this situation, information about a specific record. In such a case you want to use Block context image/svg+xml .
Block context is a feature which enables ancestor blocks to provide values which can be consumed by descendent blocks within its own hierarchy.
Posts
Add JavaScript to a custom block in Wordpress
Using Wordpress custom blocks, I’m currently trying to create a popover component that contains a button and a hidden content. The hidden content should appear when the user clicks on or hovers over the button (on the frontend of the website, not in the block editor).
Problem However, when I add an onClick or onHover to the button, the event handler is not executed.
Additionally, trying to use the useState hook to store the display state of the popover crashes my block editor.
Posts
Sort list of lists in dotnet core
using System; using System.Text.Json; var array = JsonSerializer.Deserialize<List<List<int>>>("[[3, 2], [1, 1], [0,3],[0,2],[0,1], [1,3], [1,2], [2, 3]]"); Console.WriteLine(JsonSerializer.Serialize(array)); // [[3,2],[1,1],[0,3],[0,2],[0,1],[1,3],[1,2],[2,3]] var sorted = array.OrderBy(y => y[0]).ThenBy(y => y[1]); Console.WriteLine(JsonSerializer.Serialize(sorted)); // [[0,1],[0,2],[0,3],[1,1],[1,2],[1,3],[2,3],[3,2]] Source image/svg+xml
Posts
Customizable javascript cookie banner
class CookieBanner { dropCookie = true; // false disables the Cookie, allowing you to style the banner cookieDuration = 14; // Number of days before the cookie expires, and the banner reappears cookieName = 'complianceCookie'; // Name of our cookie cookieValue = 'on'; // Value of cookie initialBodyPaddingTop = 0; message = 'Our website uses cookies. By continuing we assume your permission to deploy cookies, as detailed in our {{privacyPolicy}}.
Posts
Check if a Wordpress constant has been defined
Suppose I have configured a constant in the wp-config.php of my website:
<?php /\* Super important configuration constant \*/ define('SUPER\_IMPORTANT\_VALUE', '123e4567-e89b-12d3-a456-426614174000'); ?>Whenever you want to use this value in your website, it would be nice to know if the constant has been defined already. You’d expect to be able to do this using something like:
<?php /\* !empty does not work for a constant \*/ if (!empty(SUPER\_IMPORTANT\_VALUE)) { // Do stuff } ?
Posts
Insert a Google Analytics sitetag in Wordpress using a constant defined in wp-config.php
First, define your Google Analytics constant in wp-config.php:
// wp-config.php /\* Google Analytics Key \*/ define('GOOGLE\_ANALYTICS\_KEY', 'G-XXXXXXXXXX'); Then, insert the following gist inside the <head> of your website (header.php in my case):
// header.php (for example) <?php if (defined('GOOGLE\_ANALYTICS\_KEY')) { ?><!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo GOOGLE\_ANALYTICS\_KEY; ?>"></script> <script> window.dataLayer = window.dataLayer || \[\]; function gtag() { dataLayer.push(arguments); } gtag('js', new Date()); gtag('config', '<?
Posts
SQL error with code 40531 when trying to fetch schema in Azure Database Sync
As I was trying to sync my Hub database to my Member database in Azure Database Sync, I got this error when trying to fetch the schema of the Hub database:
Getting schema information for the database failed with the exception "Failed to connect to server databasename-0182730712073.database.windows.net.Inner exception: SqlException ID: {someGuid}, Error Code: -2146232060 - SqlError Number:40531, Message: SQL error with code 40531 For more information, provide tracing ID ‘{someGuid}’ to customer support.