This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 Confusion Studios LLC | |
// by Dan Rosenstark | |
import Foundation | |
/// Extension on DispatchQueue? for Testing | |
/// If you don't have a DispatchQueue, run immediately (on current queue) | |
extension Optional where Wrapped : DispatchQueue { | |
public func asyncIfNotNil(execute block: @escaping ()->()) { | |
if let self = self { | |
self.async(execute: block) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "NSArray+Filter.h" | |
@implementation NSArray (Filter) | |
- (NSArray *) filteredArrayUsingBlock:(BOOL (^)(id obj))block { | |
NSIndexSet *const filteredIndexes = [self indexesOfObjectsPassingTest:^BOOL (id _Nonnull obj, NSUInteger idx, BOOL *_Nonnull stop) { | |
return block(obj); | |
}]; | |
return [self objectsAtIndexes:filteredIndexes]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Workflowy Images and iFrames | |
// use image:http://example.com/image.png and iframe:http://example.com/somePlace.html in your note text for Workflowy | |
// @namespace http://confusionstudios.com | |
// @version 1.1 | |
// @author Dan Rosenstark (DR2050) | |
// @match https://workflowy.com/* | |
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js | |
// @require https://code.jquery.com/ui/1.12.0/jquery-ui.js | |
// @require https://cdn.rawgit.com/noelboss/featherlight/1.5.0/release/featherlight.min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name WorkflowyPlus Refac | |
// @namespace http://confusionstudios.com | |
// @version 0.2 | |
// @author Wizmann, DR2050 | |
// @match https://workflowy.com/* | |
// @grant none | |
// ==/UserScript== | |
/* jshint -W097 */ | |
'use strict'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name WorkflowyPlus Refac 2 | |
// @namespace http://confusionstudios.com | |
// @version 0.2 | |
// @author Wizmann, DR2050 | |
// @match https://workflowy.com/* | |
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js | |
// @grant none | |
// ==/UserScript== | |
/* jshint -W097 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class GameLoop : NSObject { | |
var doSomething: () -> ()! | |
var displayLink : CADisplayLink! | |
var frameInterval : Int! | |
init(frameInterval: Int, doSomething: () -> ()) { | |
self.doSomething = doSomething |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
func permute(_ s: String) -> [String] { | |
var arr = Array(s) | |
var permutations = [[Character]]() | |
permute(&arr, 0, &permutations) | |
return permutations.map { String($0) } | |
} | |
func permute<T>(_ arr: inout [T], _ k: Int, _ result: inout [[T]]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# swiftWatchAndRun | |
if [ $# -ne 1 ]; then | |
echo "Use like this:" | |
echo " $0 filename-to-watch" | |
exit 1 | |
fi | |
if which fswatch >/dev/null; then | |
echo "Watching swift file $1" | |
while true; do fswatch --one-event $1 >/dev/null && echo "----------------"; echo `date +"%m-%d-%y %I:%M%p"`; echo "----------------" && swift $1; sleep 0.1; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pbpaste > /tmp/shellpaste.sh | |
echo "Execute this?" | |
cat /tmp/shellpaste.sh | |
echo | |
read -p "Press enter to run it..." | |
bash /tmp/shellpaste.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class func drawHollowCircle(circleColor: UIColor, rect: CGRect, startAngle: CGFloat = 1, endAngle: CGFloat = 360, outerRingProportion: CGFloat = 1, innerRingProportion: CGFloat = 0.5, drawShadow : Bool) { | |
//// Variable Declarations | |
let startAngleCalced: CGFloat = -startAngle + 270 | |
let endAngleCalced: CGFloat = -endAngle + 270 | |
let innerRingDiameter: CGFloat = rect.size.width * innerRingProportion | |
let innerRingOffset: CGFloat = 0.5 * (rect.size.width - innerRingDiameter) | |
let innerRingRect = CGRectMake(innerRingOffset, innerRingOffset, innerRingDiameter, innerRingDiameter) | |
let outerRingDiameter: CGFloat = rect.size.width * outerRingProportion | |
let outerRingOffset: CGFloat = 0.5 * (rect.size.width - outerRingDiameter) |