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
######################### | |
# This gist is meant to be used to install everything needed to get up and running with the Ionic Framework on Windows using Chocolatey (http://chocolatey.org) | |
# Read "How to use this Gist File" section below for instructions. | |
######################### | |
######################### | |
# NOTE : for those familiar with Chocolatey, there are a couple of custom packages used as part of the install that are not published and are waiting on maintainers to make updates to their packages. | |
######################### |
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
//start scanning when the Scan button is pushed down (touch down) | |
- (IBAction)startScanning:(id)sender { | |
if(![self.session isRunning]) | |
{ | |
[self.barcodeScanAreaView.layer addSublayer:_prevLayer]; | |
[_session startRunning]; | |
[self.barcodeScanAreaView bringSubviewToFront:_highlightView]; //isn't necessary at this point because the line gets removed before anyone sees it. Could be useful if there was a delay before shutting down the view and recording the scan | |
} | |
} | |
//stop scanning when the button is pushed up (inside button) (touch up inside) |
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
// AppDelegate.swift -------------------------------------------------------------------------------------------- | |
//Add this stuff to AppDelegate (in addition to whatever is already in there) to enable Firebase and the auth-specific URL handlers | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
//setup firebase |
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
public class SomeContainerOfThings | |
{ | |
List<IThing> Things {get;set;} | |
//old - performed at O(N^2) | |
IEnumerable<IThing> GetThingsAlsoIn(SomeContainerOfThings other) | |
{ | |
return this.Things.Where(thisThing => other.Things.Any(otherThing => thisThing.Name == otherThing.Name)); | |
} | |
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 CalendarPicker extends React.Component { | |
constructor() { | |
var randomId = CustomFramework.guid(); //get a GUID from the framework that will be the ID for the legacy calendar control | |
this.state = {controlId: randomId, value: null}; //we'll set value later based on legacy control events (see below) | |
} | |
render() { | |
//On initial render, put an empty div with a unique ID on the DOM. | |
//The control will be inserted inside this container. |
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
{ | |
"users" : { | |
"user1" : { | |
"posts" : { | |
"post1" : { | |
"title" : "blah", | |
"body" : "more blah", | |
"tags" : {"boring" : true, "lame" : true} | |
}, | |
"post2" : { |
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
func posts(forTag tagKey: String, completionBlock: (([Post]) -> ()) { | |
let userId = FIRAuth.auth().currentUser?.uid | |
let ref = FIRDatabase.database().reference() | |
let dispatchGroup = DispatchGroup() | |
var posts = [Post]() //I can put all the posts here as I retrieve them | |
ref.child("users").child(userId!).child("tags").child(tagKey).observeSingleEvent(of: .value, with: {(tagSnapshot) in | |
let tag = Tag(fromSnapshot: tagSnapshot) |
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 | |
typealias ReturnCompletionBlock<T> = (T?) -> () | |
//yes, this is a closure with a closure as a parameter | |
typealias AsyncListElementFunction<T> = (ReturnCompletionBlock<T>) -> () | |
class AsyncListBuilder<T> { | |
var elementFunctions = [AsyncListElementFunction<T>]() |
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
//1) Have a protocol that serves as a placeholder for something that is observing updates- mainly so you can unsubscribe from updates later when you no longer need them | |
protocol UpdateObserving { | |
func unsubscribe() | |
} | |
//1a) Implement that protocol for Firebase. It needs a ref that can unsubscribe and a handle to the specific subscription |
OlderNewer