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
using UnityEngine; | |
/** | |
* A camera to help with Orthagonal mode when you need it to lock to pixels. Desiged to be used on android and retina devices. | |
*/ | |
public class PixelPerfectCam : MonoBehaviour { | |
/** | |
* The target size of the view port. | |
*/ | |
public Vector2 targetViewportSizeInPixels = new Vector2(480.0f, 320.0f); | |
/** |
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 XCTest | |
struct SampleCodable: Codable { | |
let sampleVariable1: String | |
let sampleVariable2: String | |
let cAPPEDVariable3: String | |
let sample: String | |
} | |
class PascalJSONCoding: XCTestCase { |
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 DependencyContainer { | |
static let shared = DependencyContainer() | |
private var types: [String: Any] = [:] | |
func registerType<T: Any>(_ type: T.Type, named name: String? = nil, creator: @escaping (String) -> T) { | |
let key = name ?? String(describing: type) | |
types[key] = creator | |
} |
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 BitField = function(){}; | |
BitField.isSet = function(i, flag){ | |
return (i & flag) === flag; | |
} | |
BitField.setFlag = function(i, flag){ | |
return i | flag; | |
} | |
BitField.removeFlag = function(i, flag){ | |
return i & ~flag; | |
} |
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 | |
public protocol Observable: class { | |
associatedtype ObservableTarget = AnyObject | |
func add(observer: ObservableTarget) | |
func remove(observer: ObservableTarget) | |
func dispatch(_ handler: (ObservableTarget) -> ()) | |
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 ReSwift | |
public protocol MiddlewareProcessor { | |
typealias GetStateFunction = () -> Any? | |
func preprocess(dispatch: DispatchFunction, action: Action, getState: GetStateFunction) | |
func postprocess(dispatch: DispatchFunction, action: Action, getState: GetStateFunction) | |
} | |
public extension MiddlewareProcessor { | |
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
/* | |
Works with the alpha channel of an image to determine if there is collision with alpha | |
@parameter image - the image to check coordinate with. | |
@parameter sampling - (0.1-1.0) The percentage to downsample the image. Helps with performance and memory. Default 0.5 | |
@parameter threshhold - (0.0-1.0) the threshhold to set the alpha for a hit. default 0.2 | |
*/ | |
var PixelLevelCollision = function(image, sampling, threshhold){ | |
var self = this; | |
if(sampling === undefined){ |
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
extension Sequence { | |
func walk(_ childSelector: (Element) -> [Element], handler: (Element) -> Void) { | |
for item in self { | |
handler(item) | |
let children = childSelector(item) | |
if children.count > 0 { | |
children.walk(childSelector, handler: handler) | |
} | |
} |
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
extension Sequence { | |
func recursiveFlatten(_ childSelector: (Element) -> [Element]) -> [Element] { | |
var output: [Element] = [] | |
for item in self { | |
output.append(item) | |
let newItems = childSelector(item) | |
if newItems.count > 0 { | |
output += newItems.recursiveFlatten(childSelector) | |
} |
NewerOlder