Skip to content

Instantly share code, notes, and snippets.

View holtwick's full-sized avatar
👁️‍🗨️
On a mission for privacy

Dirk Holtwick holtwick

👁️‍🗨️
On a mission for privacy
View GitHub Profile
@holtwick
holtwick / SeaObject.h
Created May 8, 2018 12:36
Cosy NSObject
// (C)opyright 2018-04-25 Dirk Holtwick, holtwick.it. All rights reserved.
#import <Foundation/Foundation.h>
/* A dictionary like object that allows to define custom dynamic properties
* for typed and easy access. Only simple types like string, number, array and
* dictionary are supported. It is mainly thought to be a convenience class that
* can be serialized easily to JSON and other formats.
*
* MAKE SURE to add @dynamic for any property you define in a subclass of SeaObject!
@holtwick
holtwick / KeyPathHelper.m
Last active June 21, 2018 09:43
Autocomplete and refactoring compatible keyPaths: https://holtwick.de/blog/keypath-refatoring
// (C)opyright 2018-06-20 Dirk Holtwick, holtwick.it. All rights reserved.
#import <Foundation/Foundation.h>
#define keyPath(k) YES ? @#k : (k ? @"": nil)
#define keyPathFromObject(o, k) YES ? @#k : ((o ?: o.k) ? @"" : nil)
@interface Sample : NSObject
@property id greeting;
@end
@holtwick
holtwick / HORegExp.h
Last active September 25, 2021 02:11
ObjC RegExp Helper with rudimentary named groups
// Copyright 2012 Dirk Holtwick, holtwick.it. All rights reserved.
@import Foundation;
#define HORegexDefaultOptions NSRegularExpressionCaseInsensitive | NSRegularExpressionAnchorsMatchLines | NSRegularExpressionAllowCommentsAndWhitespace
@interface HORegexMatch : NSTextCheckingResult
@property (readonly, nonatomic) NSString *text;
@property (readonly, nonatomic) NSTextCheckingResult *match;
@holtwick
holtwick / yjs-vue3-experiment.vue
Created May 4, 2021 20:47
yjs-vue3-experiment.vue
<template>
<div class="test-sfu">
<div class="prose">
<h1>
<router-link to="/test">Test Vue3 + Yjs</router-link>
</h1>
<p>Experiment to combine Vue3 reactivity and Yjs realtime sync.</p>
<p>
Play around on the console by changing values of
<code>window.realtime</code>
@holtwick
holtwick / log-sentry.ts
Last active July 1, 2021 13:08
🌱 Zeed sample for Sentry.io logging
// See https://github.com/holtwick/zeed
import * as Sentry from "@sentry/browser"
import { Integrations } from "@sentry/tracing"
import { LogHandler, LogLevel, LogMessage, renderMessages } from "zeed"
import { DEBUG, RELEASE, SENTRY_DSN } from "@/config" // Use your config here
export function LoggerSentryHandler(
level: LogLevel = LogLevel.debug
<?php
// Adjust these for your needs
$umamiCollect = 'https://z-umami.holtwick.de/api/collect';
$website = "6893805d-a37d-4d63-a043-5baec4a6b32c";
// Collected info from original call
$language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$ua = $_SERVER['HTTP_USER_AGENT'];
$referrer = $_SERVER['HTTP_REFERER']; // 1x"r" vs 2x"r" !!!
@holtwick
holtwick / forceReloadOnIOS.js
Created November 1, 2021 22:01
Force PWA Reload on iOS
if ('serviceWorker' in navigator) {
navigator.serviceWorker.getRegistrations().then(function(registrations) {
registrations.map(r => {
r.unregister()
})
})
window.location.reload(true)
}
@holtwick
holtwick / jest.ts
Created March 19, 2022 06:59
A runtime for in browser test execution
import { format } from "pretty-format"
import { reactive } from "vue"
import { deepEqual, isPromise, Logger, SerialQueue } from "zeed"
const log = Logger("jest")
let context: any = {}
let performedAssertions = 0
let expectAssertions = -1