Skip to content

Instantly share code, notes, and snippets.

View palmin's full-sized avatar

Anders Borum palmin

View GitHub Profile
//
// Promise.swift
// ShellFish
//
// Created by Anders Borum on 25/02/2019.
// Copyright © 2019 Anders Borum. All rights reserved.
//
import Foundation
import SwiftUI
#if os(iOS)
import UIKit
struct BranchPickerButton: UIViewRepresentable {
public var title: String = ""
public let producer: () async throws -> [(String, String)]
@Binding public var value: String
extension Array where Element == UIImage {
func gifData(frameDelay: TimeInterval = 0.2) -> Data? {
let data = NSMutableData()
guard let destination = CGImageDestinationCreateWithData(data, kUTTypeGIF, self.count, nil) else {
return nil
}
let frameProperties: CFDictionary = [kCGImagePropertyGIFDictionary as String: [(kCGImagePropertyGIFDelayTime as String): frameDelay]] as CFDictionary
let fileProperties: CFDictionary = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFLoopCount as String: 0]] as CFDictionary
CGImageDestinationSetProperties(destination, fileProperties)
private var constantFloatSelection = NSMakeRange(0, 0)
public override func beginFloatingCursor(at point: CGPoint) {
// remember how it starts out
constantFloatSelection = selectedRange
super.beginFloatingCursor(at: point)
}
public override func updateFloatingCursor(at point: CGPoint) {
@palmin
palmin / .shellfishrc
Last active September 25, 2022 07:54
# include this from .bashrc, .zshrc or
# another shell startup file
# this script does nothing outside ShellFish
if [ "$LC_TERMINAL" = "ShellFish" ]; then
printURIComponent() {
awk 'BEGIN {while (y++ < 125) z[sprintf("%c", y)] = y
    while (y = substr(ARGV[1], ++j, 1))
    q = y ~ /[a-zA-Z0-9]/ ? q y : q sprintf("%%%02X", z[y])
    printf("%s", q)}' "$1"
// Keep polling the memory usage (through number of wired pages) every millisecond to discover if usage
// stays below some limit.
//
// let limit = MemoryGrowthLimit(megabytes: 5)
// hardWorkingMemoryConsumingMethodCall()
// XCTAssertFalse(limit.exceeded)
//
class MemoryGrowthLimit {
private let pollingInterval = 0.001
console.log("Hello World!")
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: pink; icon-glyph: user;
// lookup gravatar for contacts without images.
var MD5 = function (string) {
function RotateLeft(lValue, iShiftBits) {
return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
}

I'm Anders Borum and I make a Git client for iOS called Working Copy.

It uses libgit2 as the main dependency and the way this is included in my Xcode project is making debugging and development harder than it should be.

I have a build script that creates a static library I can use in my Xcode project which works well for the end-result, but I need a solution where the libgit2 source code is fully available in my project, letting me set breakpoints and make small changes that build immediately instead of having to run a multi-minute build-script for every change.