This file contains hidden or 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
// Type-Erasure | |
// - seealso: [AnyIterator](https://github.com/apple/swift/blob/2fe4254cb712fa101a220f95b6ade8f99f43dc74/stdlib/public/core/ExistentialCollection.swift.gyb#L45) | |
// MARK: remove `Equatable` if not needed | |
public protocol Protocol: Equatable { | |
// MARK: `Protocol` requirements | |
associatedtype AssociatedType | |
func methodOfProtocol() -> Self.AssociatedType | |
} |
This file contains hidden or 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
<#extension/struct/class#> <#Type#>: ExCodable { | |
static let <#keyMapping#>: [KeyMap<<#SelfType#>>] = [ | |
KeyMap(\.<#property#>, to: <#"key"#>), | |
<#...#> | |
] | |
init(from decoder: Decoder) throws { | |
try decode<#Reference#>(from: decoder, with: Self.<#keyMapping#>) | |
} | |
func encode(to encoder: Encoder) throws { | |
try encode(to: encoder, with: Self.<#keyMapping#>) |
This file contains hidden or 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 | |
set -Eeuo pipefail | |
trap cleanup SIGINT SIGTERM ERR EXIT | |
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) | |
usage() { | |
cat <<EOF | |
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...] |
This file contains hidden or 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
Base64 = { | |
// @param n Number, 6 bits, e.g. 0b111111 | |
// @return String, a char, e.g. "/" | |
encode6Bits: function(n) { | |
n = Math.min(Math.max(0, n), 63); | |
if (n >= 0 && n <= 25) return String.fromCharCode("A".charCodeAt(0) + n); // ["A", "Z"] | |
else if (n >= 26 && n <= 51) return String.fromCharCode("a".charCodeAt(0) + n - 26); // ["a", "z"] | |
else if (n >= 52 && n <= 61) return String.fromCharCode("0".charCodeAt(0) + n - 52); // ["0", "9"] | |
else if (n == 62) return "+"; | |
else /* if (n == 63) */ return "/"; |
This file contains hidden or 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
Base64 = Base64 || { | |
// @param n Number, 6 bits, e.g. 0b111111 | |
// @return String, a char, e.g. "/" | |
encode6Bits: function(n) { | |
n = Math.min(Math.max(0, n), 63); | |
if (n >= 0 && n <= 25) return String.fromCharCode("A".charCodeAt(0) + n); // ["A", "Z"] | |
else if (n >= 26 && n <= 51) return String.fromCharCode("a".charCodeAt(0) + n - 26); // ["a", "z"] | |
else if (n >= 52 && n <= 61) return String.fromCharCode("0".charCodeAt(0) + n - 52); // ["0", "9"] | |
else if (n == 62) return "+"; | |
else /* if (n == 63) */ return "/"; |
This file contains hidden or 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/Foundation.h> | |
// VARIABLE must be a variable declaration (NSString *foo) | |
// VALUE is what you are checking is not nil | |
// WHERE is an additional BOOL condition | |
#define iflet(VARIABLE, VALUE) \ | |
ifletwhere(VARIABLE, VALUE, YES) | |
#define ifletwhere(VARIABLE, VALUE, WHERE) \ |
This file contains hidden or 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 ruby | |
require 'optparse' | |
require 'pathname' | |
require 'open3' | |
# This tool checks an input path for all static libraries *.a files | |
# and makes sure they were built with the most modern ObjC ABI version. | |
# Parse command line options. |
This file contains hidden or 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
Pod::Spec.new do |s| | |
s.name = 'POD_NAME' | |
s.version = '1.0.0' | |
s.license = { :type => 'MIT', :file => 'LICENSE' } | |
s.summary = 'Example of pod which installs a run script into the Xcode project (first target)' | |
s.homepage = 'https://github.com/phatblat/POD_NAME' | |
s.authors = { 'Ben Chatelain' => '[email protected]' } | |
s.source = { :git => 'https://github.com/phatblat/POD_NAME.git', :tag => s.version.to_s } | |
s.ios.deployment_target = '6.0' |
This file contains hidden or 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
# Get project directory path | |
current_pwd="$PWD" | |
project_dir=`cd "../../"; pwd` | |
cd "$current_pwd" | |
# Get .xcodeproj file path (yes I know it's not a file) | |
project_file=`find "$project_dir" -maxdepth 1 -name "*.xcodeproj" | tail -1` |
This file contains hidden or 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
/*! | |
* Javascript library - $class v0.2 | |
* http://github.com/iwill/ | |
*/ | |
/** | |
* typeOf with Object.prototype.toString + instanceof | |
* #see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString#Description | |
*/ | |
function typeOf(obj) { |