Skip to content

Instantly share code, notes, and snippets.

jackpal / ConvertBlogFromPublishToJekyll.swift
Created Dec 28, 2020
A Swift Command Line tool to translate the posts of a simple website from Publish to Jekyll
View ConvertBlogFromPublishToJekyll.swift
// ConvertBlogFromPublishToJekyll.swift
// Quick and dirty script to translate the posts of my personal website from the
// [Publish]( site generator to the
// [Jekyll]( site generator.
// Created by Jack Palevich on 12/27/20.
import Foundation
jackpal / TVSlideshowView.swift
Created Feb 17, 2020
A SwiftUI slideshow view
View TVSlideshowView.swift
struct TVSlideshowView : View {
let publisher : AnyPublisher<UIImage?, Never>
@State private var uiImageA: UIImage? = nil
@State private var uiImageB: UIImage? = nil
@State private var imageAHasPriority: Bool = true
var body: some View {
ZStack {
decorate(uiImage: uiImageA, isImageA: true)
jackpal / pipeline.swift
Created Feb 17, 2020
Combine pipeline for an image board slideshow
View pipeline.swift
public extension Publisher {
/// Perform requests after a delay.
func slowRequest(delay: DispatchQueue.SchedulerTimeType.Stride)
-> AnyPublisher<Self.Output, Self.Failure> {
var firstItem = true
let serialQueue = DispatchQueue(label: "slowRequest")
return self
.flatMap(maxPublishers: .max(1)) { (item: Self.Output)
jackpal / BotaniculaAnemonePuzzleSolver.swift
Last active Nov 22, 2018
Swift code to solve the iPad Botanicula anemone puzzle
View BotaniculaAnemonePuzzleSolver.swift
// Solve the anemone Botanicula puzzle.
// Number the anenome 1 to 7, left-to-right.
// Encode a list of anemones into a single integer, where bit 0 is anemone 1, etc.
func encode(_ d:[Int])->Int {
return d.reduce(0, {x, y in x | (1 << (y-1)) })
// A list of which anemones are pulled down when a given anemone is tapped.
let moves = [