Skip to content

Instantly share code, notes, and snippets.

View Paul-van-Klaveren's full-sized avatar

Paul van Klaveren Paul-van-Klaveren

  • ABN AMRO
  • Amsterdam
View GitHub Profile
@danielgindi
danielgindi / delete_bitbucket_lfs_files.js
Last active November 8, 2024 17:14
Bulk delete Bitbucket LFS files
(() => {
// Run this in Chrome's console, while in Bitbucket's website and logged in
const csrftoken = document.cookie.match(/\bcsrftoken=(.*?)(?:;| |$)/)[1];
const repoName = window.__initial_state__.section.repository.currentRepository.full_name;
const expiry = 1000 * 60 * 60; // Delete only files older than an hour
let page = 1;
function iterateNext() {
fetch(`https://bitbucket.org/${repoName}/admin/lfs/file-management/?iframe=true&spa=0&page=${page}`, {
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active May 7, 2025 16:00
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@ian-mcdowell
ian-mcdowell / DebuggingOverlay.m
Last active February 27, 2021 19:04
UIDebuggingInformationOverlay for iOS 10, 11, and 12
#import <objc/runtime.h>
@interface DebuggingOverlay: NSObject
@end
@implementation DebuggingOverlay
+ (void)toggleOverlay {
id debugInfoClass = NSClassFromString(@"UIDebuggingInformationOverlay");
import Foundation
import PlaygroundSupport
/// A thread-safe array.
public class SynchronizedArray<Element> {
private let queue = DispatchQueue(label: "io.zamzam.ZamzamKit.SynchronizedArray", attributes: .concurrent)
private var array = [Element]()
public init() { }
import Foundation
/// Prints the elapsed time to execute a block under whatever optimization
/// conditions are currently in use by the compiler
public func timetest(_ note: String, block: () -> Void) {
print("Starting Test:", note)
let now = ProcessInfo().systemUptime
block()
let timeInterval = ProcessInfo().systemUptime - now
print("Ending Test:", note); print("Elapsed time: \(timeInterval)")
@zwaldowski
zwaldowski / Activity.swift
Last active November 3, 2024 17:37
os_activity_t for Swift 3
//
// Activity.swift
//
// Created by Zachary Waldowski on 8/21/16.
// Copyright © 2016 Zachary Waldowski. Licensed under MIT.
//
import os.activity
private final class LegacyActivityContext {
public extension Int {
public var seconds: DispatchTimeInterval {
return DispatchTimeInterval.seconds(self)
}
public var second: DispatchTimeInterval {
return seconds
}
@andymatuschak
andymatuschak / States-v3.md
Last active May 1, 2025 11:28
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@rnapier
rnapier / crusty.txt
Created February 3, 2016 16:12
Crusty Notes
# Beyond Crusty: Real-World Protocols
## Slide 1
Who here saw last WWDC's talk Protocol-Oriented Programming in Swift? The Crusty talk?
It is without a doubt the most important Swift talk. You have to watch it. It is probably the best talk I've ever seen at WWDC. And it's entire point is that subclassing is a needless complexity and that the right solution to most problems is protocols. Apple goes so far as to say that Swift is the first Protocol-Oriented Programming language.
Now, I take some exception to that. I don't think Swift is the first Protocol-Oriented Programming language. I think Go is much more "protocol-oriented" than Swift today, but that's a debate for beer later. Swift clearly is protocol-oriented, and that's great.
## Slide 2
@IanKeen
IanKeen / Example.swift
Last active July 10, 2019 22:02
Small utility methods to simplify dealing with Reusable items i.e. table/collection view cells
//`UITableViewCell` and `UICollectionViewCell` are `Reusable` by defaut
//Use the extension method to dequeue an instance of the appropriate `Reusable`
class MyVC: UITableViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
tableView
.registerReusable(FooCell.self)
.registerReusable(BarCell.self)
}