Skip to content

Instantly share code, notes, and snippets.

@wvteijlingen
wvteijlingen / Component.tsx
Created May 7, 2024 09:07
React Native Dark Mode
import useThemedStyles, { createThemedStyleSheet } from "./useThemedStyles"
export default function Component() {
const [styles, colorScheme] = useThemedStyles(stylesheet)
// ...
}
const stylesheet = createThemedStyleSheet((theme) => ({
container: {
backgroundColor: theme.colors.background
@wvteijlingen
wvteijlingen / WebSocket.swift
Last active July 11, 2024 09:57
Swift WebSocket that uses AsyncThrowingStream
import Foundation
import Combine
public enum WebSocketError: Swift.Error {
case alreadyConnectedOrConnecting
case notConnected
case cannotParseMessage(String)
}
public extension WebSocket {
@wvteijlingen
wvteijlingen / RetryStrategy.swift
Last active March 4, 2024 17:10
Swift RetryStrategy
public protocol RetryStrategy {
/// True if the strategy allows to retry a failed action. False if all the retries have been 'used up'.
var shouldRetry: Bool { get }
/// The delay for which to wait before attempting to retry a failed action.
var delay: TimeInterval { get }
/// Returns a copy of this retry strategy with the number of allowable retries lowered by one.
var consumedOnce: Self { get }
}
@wvteijlingen
wvteijlingen / Welcome to Gistblog.md
Last active February 20, 2023 16:06
blog/Welcome to Gistblog!
excerpt
Gistblog is a website that turns your Github gists into a blog! Simple write a gist, prefix the name with `blog/`, and it will show up on `gistblog.land/your-github-username`

Welcome to Gistblog!

Gistblog is a website that turns your Github gists into a blog! Simple write a gist, prefix the name with blog/, and it will show up on gistblog.land/your-github-username.

Why should I use Gistblog?

# Very naive way of finding files that are in the filesystem but not added to an Xcode project
proj = File.read("path-to-project.pbxproj")
puts Dir.glob("./**/*.swift")
.map { |e| File.basename(e) }
.reject { |e| proj.include?(e) }
import CallKit
import Foundation
class PhoneCaller: NSObject {
typealias OnCallConnected = () -> Void
static let shared: PhoneCaller = PhoneCaller()
private let observer = CXCallObserver()
private var isCalling: Bool = false

Hierbij mijn lijst. Sorry dat het een beetje veel is geworden. Ik heb gewoon de app doorgelopen en opgeschreven wat me te binnen schoot. Om het een beetje behapbaarder te maken heb ik het wel onderverdeeld in categorieën.

Customer Journey

Autocheck De autocheck is volgens mij een van de kernpunten die we aanbieden met Smart Driver. Ik vind dat dit wel wat meer naar voren zou mogen komen in de app; de customer journey voor autocheck is eigenlijk gewoon non existent.

De enige informatie over de check is de summiere tekst in de bottom sheet als je het invite-item opent, en zelfs daarin staat eigenlijk niet uitgelegd hoe het werkt en wat we doen. De autocheck invite-detailpagina is nu alleen een functionele lijst met checkmarks en een belknop. Het is niet echt enthousiasmerend, terwijl het toch best een mooie service is die ANWB ook promoot in haar marketing.

Opt-in voor locatie

@wvteijlingen
wvteijlingen / Protected songs.scpt
Created November 15, 2019 19:34
Finds all purchased songs that are DRM protected, and adds them to a "Protected songs" playlist
-- Finds all purchased songs that are DRM protected, and adds them to a "Protected songs" playlist
tell application "iTunes"
set aPlaylist to (make new user playlist with properties {name:"Protected songs"})
repeat with aTrack in tracks of library playlist 1
if purchaser Apple ID of aTrack is not missing value and kind of aTrack is "Protected AAC audio file" then
duplicate aTrack to aPlaylist
end if
end repeat
end tell
@wvteijlingen
wvteijlingen / use-toggle.ts
Created October 30, 2019 18:50
react-native-use-toggle
import { useState } from "react"
export function useToggle(initialState: boolean = false): [boolean, () => void] {
const [state, setState] = useState<boolean>(initialState)
return [
state,
() => setState(!state)
]
}
@wvteijlingen
wvteijlingen / index.js
Last active July 20, 2019 12:36
HOC for react-navigation that maps params to props
import paramsToProps from 'paramsToProps.js'
const MainNavigator = StackNavigator({
firstScreen: { screen: paramsToProps(FirstScreenComponent) },
secondScreen: { screen: paramsToProps(SecondScreenComponent) },
});