Skip to content

Instantly share code, notes, and snippets.

@JanX2
JanX2 / 00-dragndrop.swift
Created June 28, 2020 14:52 — forked from erica/00-dragndrop.swift
Building an OSX Drag and Drop Playground: Throw the dragndrop.swift into shared Sources and then test out the examples in individual playgrounds. Make sure the assistant is open and set to the timeline. I prefer vertical assistant stacking for this.
import Cocoa
// Support Foundation calls on String
public extension String { public var ns: NSString {return self as NSString} }
/// Custom Labeled Playground-Based Drag-and-Drop window
public class DropView: NSTextField {
// Default action handler
public var handler: ([String]) -> Void = { paths in Swift.print(paths) }
@JanX2
JanX2 / github_get_all_forks.sh
Last active December 12, 2023 14:04 — forked from joeytwiddle/github_get_all_forks.sh
Add all forks of the current repo as remotes
#!/usr/bin/env bash
set -e
# See also: https://github.com/frost-nzcr4/find_forks (same thing but in python)
origin_url="$(git config --get remote.origin.url | sed 's+.*: ++')"
full_repo_name="$(echo "$origin_url" | sed 's+.*github.com/++ ; s+\.git$++')"
forks_url="https://api.github.com/repos/${full_repo_name}/forks"
import Foundation
/// Adapted from https://stackoverflow.com/a/62112007
/// https://stackoverflow.com/questions/31778700/read-a-text-file-line-by-line-in-swift
extension URL {
/// Note: Only supports newline as the line break character.
func processLineByLine(processLine: @escaping (_ line: String) -> ()) {