Skip to content

Instantly share code, notes, and snippets.

View osteslag's full-sized avatar

Joachim Bondo osteslag

View GitHub Profile
@osteslag
osteslag / Suit+Codable.swift
Created March 13, 2019 08:34
Contrived example illustrating problems with singleValueContainer on Encoder, and maybe Character not being Codable.
// Contrived example illustrating problems with singleValueContainer on Encoder, and maybe Character not being Codable.
import XCTest
enum Suit: Character {
case diamonds = "♦"
case clubs = "♣"
case hearts = "♥"
case spades = "♠"
}
@osteslag
osteslag / Metadata.swift
Created August 14, 2018 16:55
Swift Playground for updating an image file’s metadata without re-processing the image.
// Adapted from Apple's Tech Note, [Modifying Image Metadata Without Recompressing Image](https://developer.apple.com/library/archive/qa/qa1895/_index.html).
import Cocoa
import ImageIO
let url = URL(fileURLWithPath: "/path/to/file.tiff")
guard let imageSource = CGImageSourceCreateWithURL(url as CFURL, nil) else { fatalError("Cannot create URL") }
guard var properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as? Dictionary<CFString, Any> else { fatalError("Cannot get image properties") }
properties[kCGImageDestinationDateTime] = Date()
@osteslag
osteslag / Quadrilateral.swift
Last active October 9, 2019 20:17
A composable type to suplement the read-only CIRectangleFeature.
//
// Quadrilateral.swift
// CPR
//
// Created by Joachim Bondo on 16/08/16.
// Copyright © 2016 Joachim Bondo. All rights reserved.
//
import UIKit
import CoreImage
@osteslag
osteslag / UIKit+Changeset.swift
Created February 7, 2016 09:53
Untested Changeset extension on UITableView and UICollectionView
//
// UIKit+Changeset.swift
// Copyright (c) 2016 Joachim Bondo. All rights reserved.
//
import UIKit
import Changeset
public extension UITableView {
@osteslag
osteslag / keybase.md
Created February 20, 2015 14:30
Keybase.io Identity Proof

Keybase proof

I hereby claim:

  • I am osteslag on github.
  • I am bondo (https://keybase.io/bondo) on keybase.
  • I have a public key whose fingerprint is 79D8 8215 2CEA 0B1B 693E F2D2 3DD9 D69D 916E FFC5

To claim this, I am signing this object:

@osteslag
osteslag / remove_conflicted_copies.sh
Created August 22, 2014 08:55
Outputs and deletes Dropbox-conflicted files recursively from the current directory and below.
#!/bin/sh
find . -name "*conflicted copy*" -print -delete
@osteslag
osteslag / fan.sh
Last active January 28, 2018 20:06
Control the fan speed of an 27-inch, Mid 2010, iMac. I use this after installing an SSD drive instead of the factory-supplied HDD.
#!/bin/sh
version="0.1"
script=$(basename $0)
smc=/Applications/smcFanControl.app/Contents/Resources/smc
smc_key="F1Mx" # HDD fan key
minimum_speed=2500
fan_speed=0
version () {
@osteslag
osteslag / version.sh
Created July 18, 2011 12:45
Script for managing build and version numbers using git and agvtool. See link in comments below.
#!/bin/sh
# Script for managing build and version numbers using git and agvtool.
# Change log:
# v1.0 18-Jul-11 First public release.
# v1.1 29-Sep-12 Launch git, agvtool via xcrun.
version() {
@osteslag
osteslag / IR_Black.dvtcolortheme
Created February 20, 2011 10:54
IR_Black theme for Xcode 4, based on IR_Black for Xcode 3 by David Zhou, based on IR_Black for TextMate by Todd Werth. See links in comments below.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.811765 0.796078 0.564706 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Inconsolata - 16.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>1 1 1 1</string>