Skip to content

Instantly share code, notes, and snippets.

View zaneclaes's full-sized avatar

Zane Claes zaneclaes

View GitHub Profile
//
// Detect's the user's mobile client
// If it is a matched client, creates a referral item in parse and returns a redirect URL for the AppStore
//
function createReferral($params = array()) {
require_once '../cms/Mobile_Detect.php';
$detect = new Mobile_Detect;
$ios_url = 'https://itunes.apple.com/us/app/aftermath-pvp-guilds-strategy/id702615597?ls=1&mt=8';
$clients = array('iPhone'=>$ios_url,
//
// Detect's the user's mobile client
// If it is a matched client, creates a referral item in parse and returns a redirect URL for the AppStore
//
function createReferral($params = array()) {
require_once '../cms/Mobile_Detect.php';
$detect = new Mobile_Detect;
$ios_url = 'https://itunes.apple.com/us/app/aftermath-pvp-guilds-strategy/id702615597?ls=1&mt=8';
$clients = array('iPhone'=>$ios_url,
__weak typeof (self) wself = self;
[self runRequest:request handler:^(NSError *err) {
__strong typeof (wself) sself = wself;
__weak typeof(sself) wself2 = sself;
[sself runSecondRequest:data handler:^(NSError *err) {
__strong typeof (wself2) sself2 = wself2;
[sself2 doStuff];
}];
}];
@zaneclaes
zaneclaes / SNFirebase.h
Created May 4, 2014 15:37
This Firebase helper class uses transient Firebase objects, so that each object is never used for more than a single transaction. It also prevents Firebase crashes by creating mutable deep copies. The observe method also does sanity checking.
//
// SNFirebase.h
// SharedNotes
//
// Created by Zane Claes on 4/12/14.
// Copyright (c) 2014 inZania LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Firebase/Firebase.h>
//
// SNFirebase.m
// SharedNotes
//
// Created by Zane Claes on 4/12/14.
// Copyright (c) 2014 inZania LLC. All rights reserved.
//
#import "SNFirebase.h"
//
// SNFirebase.m
// SharedNotes
//
// Created by Zane Claes on 4/12/14.
// Copyright (c) 2014 inZania LLC. All rights reserved.
//
#import "SNFirebase.h"
//
// SNFirebase.m
// SharedNotes
//
// Created by Zane Claes on 4/12/14.
// Copyright (c) 2014 inZania LLC. All rights reserved.
//
#import "SNFirebase.h"
#import <Firebase/Firebase.h>
- (void)choosePaymentInstrument:(BBPaymentInstrument*)instrument {
NSAssert(instrument.paymentInstrumentId, @"instrument must have an ID");
NSString *endpoint = [NSString stringWithFormat:@"/trip_invoices/%d",(int)self.tripInvoice.tripInvoiceId.integerValue];
NSDictionary *params = @{@"op":@"add",@"path":@"/payment_instrument_id",@"value":instrument.paymentInstrumentId};
[self showLoadingView:NO blocking:NO];
[[BBAPI V2] patch:endpoint withParams:params onSuccess:^(id object) {
[self dismissLoadingView];
[self.tableView triggerPullToRefresh];
} onFailure:^(NSError *e) {
NSNumber *limitParam = (limit) ? @(limit) : @50;
NSNumber *offsetParam = (offset) ? @(offset) : @0;
NSDictionary *params = @{@"_format": @"v1_legacy",
(host ? @"host_id" : @"guest_id") : [BBUser activeUser].userId ?: @(0),
@"offset" : offsetParam,
@"items_per_page" : limitParam,
@"include_pending" : includePending ? @"true" : @"false",
@"include_checkpoint" : includeCheckpoint ? @"true" : @"false"
};
module Api
module V2
class TripInvoicesPresenter < BasePresenter
def initialize(trip_invoice, current_user)
@trip_invoice = trip_invoice
@current_user = current_user
end
def to_json_default
invoice_items = @trip_invoice.trip_invoice.trip_invoice_items.map do |item|