Skip to content

Instantly share code, notes, and snippets.

View claus's full-sized avatar
🎅

Claus Wahlers claus

🎅
View GitHub Profile
@claus
claus / flashforward.asm
Created October 16, 2019 09:09
6502 assembler intro for Flash Forward awards ceremony 2006 in Austin, Tx (FC64 emulator)
; FC64 Flashforward Trailer
; =========================
; Basic: "1 SYS(2064)"
.a 0801
.b 0d,08,01,00,9e,28,32,30,36,34,29,00,00,00,00
@claus
claus / NextWorkboxPlugin.js
Last active October 15, 2019 13:47
Simple Webpack plugin to create Workbox based service workers for Next.js 9.1+ projects.
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const readdir = require('recursive-readdir');
const SW_NAME = 'sw.js';
const fileBlacklist = [
'sw.js',
'build-manifest.json',
@claus
claus / screencapture.sh
Created September 11, 2018 00:16
MacOS: capture screenshot and add it to IPFS
# Exit on errors
set -e
set -o pipefail
# Filename of captured image
FILE="$(date +%Y-%m-%d-%H-%M-%S).png"
# User/host
HOST="user@xx.xxx.xxx.xxx"
# Capture screen (interactively) and save image to the desktop
screencapture -i ~/Desktop/$FILE
# Upload the captured image to the server
@claus
claus / functions.php
Created August 17, 2018 19:45
Wordpress: Also search tags in addition to post title and content
function tax_search_join( $join, $query ) {
global $wpdb;
if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) {
$join .= "
INNER JOIN
{$wpdb->term_relationships} ON {$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id
INNER JOIN
{$wpdb->term_taxonomy} ON {$wpdb->term_taxonomy}.term_taxonomy_id = {$wpdb->term_relationships}.term_taxonomy_id
INNER JOIN
{$wpdb->terms} ON {$wpdb->terms}.term_id = {$wpdb->term_taxonomy}.term_id
@claus
claus / data-prefetching-in-next-js.md
Last active October 20, 2022 06:23
Data Prefetching in Next.js

Data Prefetching in Next.js

The Miroskii Team

(and who they really are)

Miroskii advisors and team screenshotted off miroskii.com, 2018-03-04 at 14.50.18 PST:

Miroskii advisors and team

"Craig Gulledge"

A while ago i needed a way to look up addresses from zip codes in Brazil for a weekend tinker project (Zip codes are called "CEP" here, "Código de Endereçamento Postal", or Postal Addressing Code). Turns out such a database is pretty hard to get hold of. Zip code data is created and maintained by the Brazilian Post (Correios), they have a copyright on it and are selling it for a hefty price tag. There are two versions for sale, "DNE Básico" for R$1.100 (complete dataset in text format, probably CSV), and "DNE Máster" for R$2.500. As far as i aware, the "Máster" version is just the same as the "Básico" version, but additionally contains the database in MS Access format. Okay, both are a bit above my budget.

Luckily there is another option, called "Guia Postal Brasileiro Eletrônico", or GPBe. This is an executable that you can run on your PC to manually query zip codes and addresses. And to be able to do that it must somehow contain the entire database in some form. It costs R$50, which is affordable (about US

Verifying my Blockstack ID is secured with the address 18LbnFamubJd8mXjWS8WZta46XzHBmRLUC https://explorer.blockstack.org/address/18LbnFamubJd8mXjWS8WZta46XzHBmRLUC
@claus
claus / ipfs-server-setup.md
Last active May 9, 2023 03:51
Host Your Site Under Your Domain on IPFS

Host Your Site Under Your Domain on IPFS

This is a step-by-step tutorial for hosting your website under your domain on IPFS, from zero, on a DigitalOcean Ubuntu 16.04.3 x64 Droplet (i am using the $10 variant with 2GB RAM).

Install IPFS

Log in as root.

First, make sure the system is up to date, and install tar and wget:

Mobile Safari's 100% Height Dilemma

Whether you're developing a web application with native-ish UI, or just a simple modal popup overlay that covers the viewport, when it comes to making things work on iDevices in Mobile Safari, you're in for a decent amount of pain and suffering. Making something "100% height" is not as easy as it seems.

This post is a collection of Mobile Safari's gotchas and quirks on that topic, some with solutions and fixes, some without, in good parts pulled from various sources across the internets, to have it all in one place. Things discussed here apply to iOS8, iOS9 and iOS10.

The Disappearing Browser Chrome

Screen real estate on smartphones is limited, so Mobile Safari collapses the browser chrome (address bar and optional tab bar at the top, and tool bar at the bottom) when the user scrolls down. When you want to make something span exactly the height of the viewport, or pin something to the bottom of the screen, this can get tricky because the viewport changes size (or