Skip to content

Instantly share code, notes, and snippets.

View drosenstark's full-sized avatar

Dan Rosenstark drosenstark

View GitHub Profile
@drosenstark
drosenstark / dansWorkflowyModsDark.css
Created July 6, 2017 14:52
Dan's Workflowy Mods, Dark
/*
* Name: Workflowly Dark
* Author: Froyok
*/
body
{
background-color: #121212;
color:white;
}
@drosenstark
drosenstark / git-stash-pick
Created June 8, 2017 21:52
Choose a git stash to apply (or other operation)
#!/usr/bin/env ruby
#git-stash-pick by Dan Rosenstark
# can take a command, default is apply
command = ARGV[0]
if !command
command = "apply"
puts "Using git stash #{command}.\nYou can choose a different command, e.g., git stash-pick pop"
end
ARGV.clear
@drosenstark
drosenstark / git-branch-pick
Last active March 6, 2019 17:01
Choose a Git Branch for any operation
#!/usr/bin/env ruby
#git-branch-pick by Dan Rosenstark
require 'io/console'
# can take a command, default is checkout
command = ARGV[0]
updateSubmodules = false
if !command
command = "checkout"
puts "Using git #{command}.\nYou can choose a different command, e.g., git branch-pick \"branch -D\""
// FastTimer.swift
// ConfusionUtilFramework
//
// Created by Dan Rosenstark on 5/4/17.
// Copyright © 2017 Confusion Studios LLC. All rights reserved.
import UIKit
// a faster timer than NSTimer, drop in replacement for
// just one of the methods... it's not precise but it works...
@objc(FastTimer)
import UIKit
// Copyright 2017 Dan Rosenstark dr2050.com
// See http://stackoverflow.com/a/28570282/8047, too
class GameLoop : NSObject {
var doSomething: () -> ()!
var displayLink : CADisplayLink!
init(doSomething: @escaping () -> ()) {
@drosenstark
drosenstark / MergeIntervals.swift
Last active April 1, 2017 20:47
Ye Old Merge Intervals Question, Solved from Scratch (including non-sorted version)
// MergeOverlappingIntervals in Swift 3.1
// Created by Dan Rosenstark on 4/1/17.
// Copyright © 2017 Confusion Studios LLC. All rights reserved.
import XCTest
extension CountableClosedRange {
// returns the more inclusive range or nil if there's no union
func union(with range: CountableClosedRange) -> CountableClosedRange? {
if overlaps(range) {
@drosenstark
drosenstark / NSObjectOverrides.swift
Created March 28, 2017 18:40
Overriding NS Method in Swift 3 (Playground Page)
//: [Previous](@previous)
// http://stackoverflow.com/questions/33696489/overriding-ns-methods-in-swift
import UIKit
var str = "Hello, playground"
//: [Next](@next)
extension NSObject {
func NSLocalizedString(key: String, comment: String) -> String {
return "yes we have localized an NSObject"
@drosenstark
drosenstark / BinarySearchTests.swift
Last active March 29, 2017 18:57
Binary Search in Swift (as a single-file Unit Test)
// BinarySearchTests.swift
// BinarySearchTests
//
// Created by Dan Rosenstark on 3/27/17.
// Copyright © 2017 Confusion Studios LLC. All rights reserved.
import XCTest
@testable import SwiftAlgos
class BinarySearchTests: XCTestCase {
@drosenstark
drosenstark / LockingWithSwiftAndGCD.swift
Created March 20, 2017 20:58
Locking Demo with GCD and Swift (Playground)
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
// CHANGE THIS TO TRUE FOR the lock queue to be used
let useLocks = false
var counter : Int = 0
@drosenstark
drosenstark / DRTimer.swift
Last active May 9, 2018 05:33
A drop-in Swift replacement for NSTimer: faster and lighter weight using GCD
// DRTimer.swift
// ConfusionUtilFramework
//
// Created by dan on 5/4/17.
// Copyright © 2017 Confusion Studios LLC. All rights reserved.
//
import UIKit
// a faster timer than NSTimer, drop in replacement for
// just one of the methods... it's not precise but it works...