Skip to content

Instantly share code, notes, and snippets.

Avatar
👁️‍🗨️
On a mission for privacy

Dirk Holtwick holtwick

👁️‍🗨️
On a mission for privacy
View GitHub Profile
@holtwick
holtwick / jest.ts
Created Mar 19, 2022
A runtime for in browser test execution
View jest.ts
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
@holtwick
holtwick / forceReloadOnIOS.js
Created Nov 1, 2021
Force PWA Reload on iOS
View forceReloadOnIOS.js
if ('serviceWorker' in navigator) {
navigator.serviceWorker.getRegistrations().then(function(registrations) {
registrations.map(r => {
r.unregister()
})
})
window.location.reload(true)
}
View trackWithUmami.php
<?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 / log-sentry.ts
Last active Jul 1, 2021
🌱 Zeed sample for Sentry.io logging
View log-sentry.ts
// 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
View 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 / HORegExp.h
Last active Sep 25, 2021
ObjC RegExp Helper with rudimentary named groups
View HORegExp.h
// 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 / KeyPathHelper.m
Last active Jun 21, 2018
Autocomplete and refactoring compatible keyPaths: https://holtwick.de/blog/keypath-refatoring
View KeyPathHelper.m
// (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
View SeaObject.h
// (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 / SeaDataSpeedTests.m
Created Feb 3, 2018
Speed and size testing for JSON, MessagePack, Plist and KeyedArchiver
View SeaDataSpeedTests.m
// (C)opyright 2018-02-03 Dirk Holtwick, holtwick.it. All rights reserved.
#import <XCTest/XCTest.h>
#import "MPMessagePack.h"
#import "NSData+GZIP.h"
@interface SeaDataSpeedTests : XCTestCase
@end
@holtwick
holtwick / proceedsappstore.py
Created Dec 7, 2010
Analyze AppStore Daily Reports
View proceedsappstore.py
import glob
d = {}
for fn in glob.glob('appsales/*.txt'):
lines = open(fn, 'r').readlines()[1:]
# print fn
for l in lines:
l = l.split('\t')
if len(l) == 18: # only newest format
proceeds = float(l[8])