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
last_commit=$(git rev-parse --short HEAD)$([[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] && echo "*") | |
CFBundleVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE") | |
buildNum=${CFBundleVersion##*.} | |
buildNum=$((buildNum + 1)) | |
CFBundleVersion=$last_commit"."$USER"."buildNum | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $CFBundleVersion" "$INFOPLIST_FILE" |
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 | |
files=/ci_scripts/*.plist | |
for f in $files | |
do | |
echo Processing $f "..." | |
productName="$(/usr/libexec/plistbuddy -c Print:ProductName: "$f")" | |
echo $productName |
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
@implementation UIImage (ForceLoading) | |
- (void) forceLoad | |
{ | |
const CGImageRef cgImage = [self CGImage]; | |
const int width = CGImageGetWidth(cgImage); | |
const int height = CGImageGetHeight(cgImage); | |
const CGColorSpaceRef colorspace = CGImageGetColorSpace(cgImage); |
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
@implementation AVAssetExportSession (Testing) | |
- (void) exportSynchronously | |
{ | |
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); | |
[self exportAsynchronouslyWithCompletionHandler:^{ | |
dispatch_semaphore_signal(semaphore); | |
}]; | |
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); | |
dispatch_release(semaphore); |
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.UIGestureRecognizerSubclass | |
class ForcePanGestureRecognizer : UIPanGestureRecognizer { | |
private(set) var force = CGFloat(0) { | |
didSet { | |
if force > maxForce { | |
maxForce = force | |
} | |
} |
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
CGAffineTransform CGAffineTransformFromRectToRect(CGRect fromRect, CGRect toRect) | |
{ | |
CGSize scale = CGSizeMake(toRect.size.width / fromRect.size.width, toRect.size.height / fromRect.size.height); | |
CGRect scaledFromRect = CGRectMake(fromRect.origin.x * scale.width, fromRect.origin.y * scale.height, | |
fromRect.size.width * scale.width, fromRect.size.height * scale.height); | |
CGSize translation = CGSizeMake(fromRect.origin.x - scaledFromRect.origin.x, fromRect.origin.y - scaledFromRect.origin.y); | |
return CGAffineTransformMake(scale.width, 0.0, 0.0, scale.height, translation.width, translation.height); | |
} |
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
/** | |
* Similar to [groupBy] or [partition], except an arbitrary amount of predicates can be returned. | |
* Think [partition] for > 2 predicates. | |
* | |
* | |
* @return [List] with size n for predicates where all items will satisfy one of the predicates, | |
* or size n + 1 for n predicates, where there will be remaining items after condition check. | |
* | |
* @throws [IndexOutOfBoundsException] If using declaration deconstruction where val count is > possible return size. | |
* |
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 -e | |
HOST=${1:-cloudflare.com} | |
FILENAME=${2:-${HOST%%.*}} | |
# For file naming, see https://support.ssl.com/Knowledgebase/Article/View/19/0/der-vs-crt-vs-cer-vs-pem-certificates-and-how-to-convert-them | |
# For HTTP Public Key Pinning (HPKP), see https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning | |
CERTIFICATE_PEM="${FILENAME}_certificate.ascii.crt" | |
CERTIFICATE_DER="${FILENAME}_certificate.crt" | |
PUBKEY_PEM="${FILENAME}_pubkey.ascii.key" |