Skip to content

Instantly share code, notes, and snippets.

LOGFILE="$HOME/Desktop/xcode-pre-action.txt" ;
print_pwd () { echo "pwd: $(pwd)" >> $LOGFILE ; }
bump_version () { agvtool bump ; }
echo "" > $LOGFILE ;
echo "Build Pre-Action" >> $LOGFILE
print_pwd ;
echo "PROJECT_DIR: $PROJECT_DIR" >> $LOGFILE ;
echo "cd into project directory" >> $LOGFILE ;
@twhitt14
twhitt14 / TextArrayTransformToJavaScriptArray.md
Last active October 29, 2020 04:35
Take a plain old text array like "This, that, the other" and turn it into "["This", "that", "the other"]". Also displays nothing if the source cell is blank, rather than showing an error.

=IF(NOT(EQ({Source_Cell_ID},"")), CONCATENATE("[", TEXTJOIN(", ", true, ARRAYFORMULA(char(34)&TRIM(SPLIT({Source_Cell_ID},","))&char(34))), "]"), "")

func updateOutline(isShowing: Bool, animated: Bool) {
let toColor: UIColor = isShowing ? .systemBlue : .clear
let toWidth: CGFloat = isShowing ? 2 : 0
let animationDuration = 0.2
if animated {
let borderColorAnimation: CABasicAnimation = CABasicAnimation(keyPath: "borderColor")
borderColorAnimation.fromValue = layer.borderColor
borderColorAnimation.toValue = toColor.cgColor
borderColorAnimation.duration = animationDuration
@twhitt14
twhitt14 / annotated.js
Last active June 20, 2020 03:40 — forked from jed/LICENSE.txt
generate random UUIDs
function b(
a // placeholder
){
return a // if the placeholder was passed, return
? ( // a random number from 0 to 15
a ^ // unless b is 8,
Math.random() // in which case
* 16 // a random number from
>> a/4 // 8 to 11
).toString(16) // in hexadecimal
// Put this in a playground
import UIKit
import PlaygroundSupport
let wrapperView = UIView(frame: CGRect(x: 0, y: 0, width: 400, height: 160))
wrapperView.backgroundColor = .lightGray
let roundedCornerView = UIView(frame: CGRect(x: 50, y: 50, width: 300, height: 60))
roundedCornerView.backgroundColor = .white
// Run in an Xcode Playground
let prices: [Double] = [6,0,-1,10]
let prices2: [Double] = []
let prices3: [Double] = [1]
let prices4: [Double] = [6,0,-1,10,11,12,1,5,200,-2,200,32,-322,0,124,432,-1,-1000,1]
func solution(prices: [Double]) -> Double {
// the idea is to find the max between two key differences in the array:
// Run in an Xcode Playground
let prices: [Double] = [6,0,-1,10,11,12,1,5,200,-2,200]
func solution(prices: [Double]) -> Double {
var possibleOutcomes: [Double] = []
prices.enumerated().forEach { tuple in
let index = tuple.offset
let initialPrice = tuple.element
let pricesAfterInvestment = prices.suffix(from: index)
// Run in an Xcode Playground
let input = ")(()("
let input2 = "))()))("
let input3 = "))))(((("
let input4 = ")))()(()()(("
let input5 = "(()())"
let input6 = ""
let input7 = "()"
function createUUID(a){return a?(a^Math.random()*16>>a/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,createUUID)}
var url = '';
function callback() {
console.log(this.responseText);
}
var xhr = new XMLHttpRequest();
xhr.addEventListener("load", callback);
xhr.open("GET", url);
xhr.send();