Skip to content

Instantly share code, notes, and snippets.

View NicholasBellucci's full-sized avatar
💭
👨‍💻

Nicholas Bellucci NicholasBellucci

💭
👨‍💻
View GitHub Profile
.toolbar {
ToolbarItemGroup {
Button(action: {}, label: {
Image(systemName: "sidebar.left")
})
Spacer()
Button(action: {}, label: {
Image(systemName: "play.fill")
})
Button(action: {}, label: {
import Cocoa
import SwiftUI
public extension View {
func bindWindow(_ window: Binding<NSWindow?>) -> some View {
return background(WindowAccessor(window))
}
}
public struct WindowAccessor: NSViewRepresentable {
@joltguy
joltguy / StrikethroughString.swift
Created April 13, 2018 16:01
Swift String extension for Unicode strikethrough text
extension String {
func strikeThrough() -> String {
var struck = ""
let strikeChar: Character = "\u{0336}"
self.forEach { (char) in
var xchar = UnicodeScalarView(char.unicodeScalars)
xchar.append(strikeChar.unicodeScalars.first!)
struck.append(String(xchar))
}
return struck
@rcharlton
rcharlton / enum.swift
Last active December 23, 2022 13:53
Swift enums, Equatable and Hashable
// Enums with associated values are not equatable...
enum MyEnum {
case a(number: Int)
case b
case c(text: String)
}
// We can define a hash based on the case or the case plus associated value.
extension MyEnum: Hashable {
@ndarville
ndarville / diff.mdown
Created July 23, 2012 20:33
Paul Heckel's Diff Algorithm

[Isolating Differences Between Files][paper]

Advantage over Other Algorithms

The diff output is more specific:

[I]f a whole block of text is moved, then all of it, rather than just the beginning and end, is detected as changed.

>The algorithm described here avoids these difficulties. It detects differences that correspond very closely to our intuitive notion of difference.