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
| // A function that returns an object or nil if there's an error. | |
| - (NSObject*) doSomethingComplexAndReturnObject:(NSString*) input error:(NSError**) error { | |
| // do some work.. | |
| BOOL itWorked = YES; | |
| if (itWorked) { | |
| return [[NSObject alloc] init]; // Do better memory management than this please. | |
| } else { | |
| *error = [NSError errorWithDomain:@"com.mycompany.myapp" code:14 userInfo:[NSDictionary dictionaryWithObject:@"My error message" forKey:NSLocalizedDescriptionKey]]; |
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
| //`UITableViewCell` and `UICollectionViewCell` are `Reusable` by defaut | |
| //Use the extension method to dequeue an instance of the appropriate `Reusable` | |
| class MyVC: UITableViewDataSource { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| tableView | |
| .registerReusable(FooCell.self) | |
| .registerReusable(BarCell.self) | |
| } |
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 python | |
| # -*- coding: utf-8 -*- | |
| __author__ = 'Diego Garcia' | |
| import tornado.web | |
| import tornado.ioloop | |
| import oauth2.tokengenerator | |
| import oauth2.grant | |
| import oauth2.store.redisdb | |
| import oauth2.store.mongodb |
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
| # coding: utf-8 | |
| # | |
| # Copyright (c) Alexandr Emelin. BSD license. | |
| # All rights reserved. | |
| # | |
| """ | |
| class GithubAuthHandler(BaseHandler, auth.GithubMixin): | |
| x_site_token = 'application' |
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
| /* | |
| * Set up your Git configuration | |
| */ | |
| git config --global user.email "[email protected]" | |
| git config --global user.name "Your Name" | |
| git config --global core.editor "nano" |
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
| from hashlib import md5 | |
| from base64 import b64decode | |
| from base64 import b64encode | |
| from Crypto import Random | |
| from Crypto.Cipher import AES | |
| # Padding for the input string --not | |
| # related to encryption itself. | |
| BLOCK_SIZE = 16 # Bytes |
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
| #-*- coding: utf-8 -*- | |
| # Python 3.4 | |
| # author: http://blog.dokenzy.com/ | |
| # date: 2015. 4. 8 | |
| # References | |
| # http://www.imcore.net/encrypt-decrypt-aes256-c-objective-ios-iphone-ipad-php-java-android-perl-javascript/ | |
| # http://stackoverflow.com/questions/12562021/aes-decryption-padding-with-pkcs5-python | |
| # http://stackoverflow.com/questions/12524994/encrypt-decrypt-using-pycrypto-aes-256 |
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
| from hashlib import md5 | |
| from base64 import b64decode | |
| from base64 import b64encode | |
| from Crypto.Cipher import AES | |
| # Padding for the input string --not | |
| # related to encryption itself. | |
| BLOCK_SIZE = 16 # Bytes | |
| pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * \ |
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
| from zeep import Client, helpers | |
| client = Client('https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente?wsdl') | |
| resp = client.service.consultaCEP('06694720') | |
| resp = helpers.serialize_object(resp) | |
| resp = {k: resp[k] for k in resp} | |
| print(resp) | |
| client = Client('http://www.webservicex.com/globalweather.asmx?wsdl') | |
| resp = client.service.GetCitiesByCountry('New York') |
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 json, datetime | |
| class RoundTripEncoder(json.JSONEncoder): | |
| DATE_FORMAT = "%Y-%m-%d" | |
| TIME_FORMAT = "%H:%M:%S" | |
| def default(self, obj): | |
| if isinstance(obj, datetime.datetime): | |
| return { | |
| "_type": "datetime", | |
| "value": obj.strftime("%s %s" % ( |