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
// Assumes a long running process where the session keys need to be renewed or possibly even re-created | |
var session: Session = authorization.renewSession() ?: authorization.createSession() | |
val retryPolicy = RetryPolicy.builder<Any>() | |
.handle(ExpiredTokenError::class.java, InvalidTokenError::class.java) | |
.withDelay(Duration.ofSeconds(1)) | |
.withMaxRetries(1) | |
.onRetry { | |
authorization.renewSession()?.let { | |
println("Re-authorization of session succeeded") |
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
#!/usr/bin/env bash | |
# Root folder | |
echo "Largest folders at /" | |
du -hs /* 2>&1 | grep -v 'permitted' | sort -hr | grep '^\s\?\d\+\(\.\d\+\)\?G' | |
# /private/var temp | |
echo "Largest temporary folders" | |
du -hs $TMPDIR../C/* 2>&1 | grep -v 'permitted' | sort -hr | grep '^\s\?\d\+\(\.\d\+\)\?G' |
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 | |
git branch --merged | sed '$d' >/tmp/merged-branches && \ | |
vi /tmp/merged-branches && xargs git branch -d </tmp/merged-branches |
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 (C) 2015 Jake Wharton | |
* Modified work Copyright 2019 Phil Olson | |
* Modified work Copyright 2020 Sean Soper | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 |
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
{"instruction": {"missed": 5572, "covered": 100, "ratio": 0.017946877243359655, "ratioStr": "2%"}, "branch": {"missed": 363, "covered": 100, "ratio": 0.27548209366391185, "ratioStr": "28%"}, "line": {"missed": 561, "covered": 100, "ratio": 0.17825311942959002, "ratioStr": "18%"}, "complexity": {"missed": 400, "covered": 100, "ratio": 0.25, "ratioStr": "25%"}, "method": {"missed": 179, "covered": 100, "ratio": 0.5586592178770949, "ratioStr": "56%"}, "class": {"missed": 42, "covered": 57, "ratio": 1.3571428571428572, "ratioStr": "136%"}, "total": "44%", "color": "yellow"} |
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
# use color, even if piping to a another program | |
--color | |
# sort files | |
--sort-files | |
# only search with case sensitivity if there is mixed case | |
--smart-case | |
# follow symlinks |
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
#!/usr/bin/env bash | |
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -D |
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
var distributedThruTestFlight: Bool { | |
if let sandboxReceiptHasSuffix = Bundle.main.appStoreReceiptURL?.path.hasSuffix("sandboxReceipt"), | |
sandboxReceiptHasSuffix == true { | |
return true | |
} | |
return false | |
} |
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
// Latest snapshot, 01-11-2016, seems to have fixed the missing SEEK_END pointer yet | |
// made NSData(contentsOfFile:) a missing symbol on Linux | |
func contents(path: String) -> String? { | |
let fp: UnsafeMutablePointer<FILE> = fopen(path, "r") | |
defer { fclose(fp) } | |
fseek(fp, 0, SEEK_END) | |
let fileSize = ftell(fp) | |
rewind(fp) |
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
/** | |
* Promise.first | |
* Get the result of the first Promise that passes | |
* If none of the Promises pass then it is rejected | |
* Doesn’t short-circuit like Promise.race | |
* Requires ES6 | |
*/ | |
if (Promise.first === undefined) { | |
Promise.first = (promises) => { |
NewerOlder