Skip to content

Instantly share code, notes, and snippets.

View burritofanatic's full-sized avatar

Will burritofanatic

  • Los Angeles, California
View GitHub Profile
@burritofanatic
burritofanatic / CreditCard.Swift
Created January 28, 2016 06:57
Optional Binding
if let creditCardAccount = checkingOnly.creditCardAccount {
print(creditCardAccount)
} else {
print("The guy has no credit card")
}
// The guy has no credit card
if let bothProductCreditCardAccount = bothProducts.creditCardAccount {
let checkingOnly = BankAccount(checkingAccount: "12345", creditCardAccount: nil)
let bothProducts = BankAccount(checkingAccount: "12345", creditCardAccount: "109876")
let checkingOnly = BankAccount(checkingAccount: "12345", creditCardAccount: nil)
let bothProducts = BankAccount(checkingAccount: "12345", creditCardAccount: "109876")
print(bothProducts.checkingAccount)
// 12345
print(bothProducts.creditCardAccount)
// Optional("109876")
print(bothProducts.creditCardAccount!)
class BankAccount {
let checkingAccount: String
let creditCardAccount: String?
init(checkingAccount: String, creditCardAccount: String?) {
self.checkingAccount = checkingAccount
self.creditCardAccount = creditCardAccount
}
}
@burritofanatic
burritofanatic / gist:d4dadf96188e51c66517
Created June 7, 2015 02:15
Multi-Part Upload to GAE For Images
UIImage* importedImage = [info valueForKey:UIImagePickerControllerOriginalImage];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"https://snap-picafy.appspot.com/upload_url" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
[manager POST:[responseObject valueForKey:@"uploadURL"] parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
NSData* imageData = UIImagePNGRepresentation(importedImage);
[formData appendPartWithFileData:imageData name:@"file" fileName:@"imageSample" mimeType:@"image/png"];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Response: %@", responseObject);
@burritofanatic
burritofanatic / gist:cc4e3689eb680eb81a3e
Created June 7, 2015 02:14
Multi-Part Upload to GAE For Images
UIImage* importedImage = [info valueForKey:UIImagePickerControllerOriginalImage];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"https://snap-picafy.appspot.com/upload_url" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
[manager POST:[responseObject valueForKey:@"uploadURL"] parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
@burritofanatic
burritofanatic / gist:973b82375b10f3fa68bc
Last active August 29, 2015 14:22
Google App Engine Photo Upload Using Blobstore - Python
import webapp2
import jinja2
import os
from google.appengine.ext import blobstore
from google.appengine.ext.webapp import blobstore_handlers
from models import UserPicfayAsset
import json
jinja_environment = jinja2.Environment(autoescape=True,
loader=jinja2.FileSystemLoader(