Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Looking for work

Kare Morstol kareman

💭
Looking for work
View GitHub Profile
@kareman
kareman / prepare-xcode-project.bash
Created Jan 18, 2015
Prepare an Xcode project for Git version control.
View prepare-xcode-project.bash
#!/bin/bash -x
# create the ignore file
cat > .gitignore <<_EOF_
# Xcode
#
.DS_Store
build/
*.pbxuser
!default.pbxuser
View SwiftShell header.swift
import Foundation
class NSFileHandle {
}
struct String {
}
protocol Streamable {
}
@kareman
kareman / listallexecutablesinpath.swift
Last active Aug 29, 2015
Lists all executables currently available in PATH, using the SwiftShell framework (http://github.com/kareman/SwiftShell)
View listallexecutablesinpath.swift
#!/usr/bin/env swiftshell
import SwiftShell
/*
let directories = environment["PATH"]!.split(":")
for directory in directories {
run("find \"\(directory)\" -type f -perm +ugo+x -print") |> writeTo(standardoutput)
}
@kareman
kareman / trash.swift
Last active Apr 14, 2020 — forked from brentdax/trash.swift
Swift 3 script for sending files and folders to the trash, using the SwiftShell framework from https://github.com/kareman/SwiftShell .
View trash.swift
#!/usr/bin/env swiftshell
/*
* Released under the MIT License (MIT), http://opensource.org/licenses/MIT
*/
import SwiftShell
import Dispatch
import Cocoa
@kareman
kareman / Queue.swift
Last active Jul 31, 2020
A standard queue (FIFO - First In First Out) implemented in Swift. Supports simultaneous adding and removing, but only one item can be added at a time, and only one item can be removed at a time. Using the "Two-Lock Concurrent Queue Algorithm" from http://www.cs.rochester.edu/research/synchronization/pseudocode/queues.html#tlq, without the locks.
View Queue.swift
//
// Queue.swift
// NTBSwift
//
// Created by Kåre Morstøl on 11/07/14.
//
// Using the "Two-Lock Concurrent Queue Algorithm" from http://www.cs.rochester.edu/research/synchronization/pseudocode/queues.html#tlq, without the locks.
// should be an inner class of Queue, but inner classes and generics crash the compiler, SourceKit (repeatedly) and occasionally XCode.
You can’t perform that action at this time.