Skip to content

Instantly share code, notes, and snippets.

@wvteijlingen
wvteijlingen / WebSocket.swift
Last active July 2, 2023 10:49
Swift WebSocket that uses AsyncThrowingStream
View WebSocket.swift
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 June 27, 2023 19:40
Swift RetryStrategy
View RetryStrategy.swift
public protocol RetryStrategy {
var shouldRetry: Bool { get }
var delay: TimeInterval { get }
var consumedOnce: Self { get }
}
// MARK: - NoRetryStrategy
extension RetryStrategy where Self == NoRetryStrategy {
public static var noRetry: Self {
@wvteijlingen
wvteijlingen / Using Google Sheets to localise your app or website.md
Last active February 20, 2023 16:00
Blog/Using Google Sheets to localise your app or website
View Using Google Sheets to localise your app or website.md
excerpt
If you're building a mobile app or website, chances are that you need to manage translations for multiple languages. In this post I want to show how to use a free tool called "Localeasy", to use Google Sheets to store and manage your translation strings

Using Google Sheets to localise your app or website

If you're building a mobile app or website, chances are that you need to manage translations for multiple languages. There are many complicated paid platforms that you can use to do this, but in this post I want to show you a free alternative: Localeasy.

With Localeasy you can use Google Sheets to store and manage your app translations. This has many benefits such as easy user management, change tracking, comments, no limits on contributors, and best of all: it's free of charge!

@wvteijlingen
wvteijlingen / Welcome to Gistblog.md
Last active February 20, 2023 16:06
blog/Welcome to Gistblog!
View Welcome to Gistblog.md
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?

View find-dead-swift-files.rb
# 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) }
View PhoneCaller.swift
import CallKit
import Foundation
class PhoneCaller: NSObject {
typealias OnCallConnected = () -> Void
static let shared: PhoneCaller = PhoneCaller()
private let observer = CXCallObserver()
private var isCalling: Bool = false
View SD2.md

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
View Protected songs.scpt
-- 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
View use-toggle.ts
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
View index.js
import paramsToProps from 'paramsToProps.js'
const MainNavigator = StackNavigator({
firstScreen: { screen: paramsToProps(FirstScreenComponent) },
secondScreen: { screen: paramsToProps(SecondScreenComponent) },
});