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 urllib2, re | |
def find_email(url): | |
hdr = {'User-Agent': 'Mozilla/5.0'} | |
req = urllib2.Request(url, headers=hdr) | |
try: | |
f = urllib2.urlopen(req) | |
s = f.read() | |
emails = re.findall(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}",s) | |
return emails |
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 ViewController: UIViewController { | |
func pickImage(fromSource sourceType: UIImagePickerControllerSourceType) { | |
guard UIImagePickerController.isSourceTypeAvailable(sourceType) else { return } | |
let imagePickerController = UIImagePickerController() | |
imagePickerController.sourceType = sourceType | |
imagePickerController.delegate = self | |
present(imagePickerController, animated: true, completion: nil) |
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 | |
import RxSwift | |
let cars = Observable.from(["Nissan", "Ford", "BMW"]) | |
let tanks = Observable.from(["Tiger II", "T-44", "Panther"]) | |
let bikes = Observable.from(["Ducati", "Honda", "Kawasaki"]) | |
let landVehicles = Observable.of(cars, tanks, bikes).merge() | |
landVehicles.subscribe(onNext: { print($0) }) |
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 RxSwift | |
func submit(number: Int) { | |
let validateAndPerformServiceCallIfSuccessful = performValidation(numberThatShouldBeEven: number) | |
.flatMap { () -> Observable<Void> in | |
print("Validated successfully") | |
return performServiceCall() // For any .next events from performValidation, perform the service call | |
} | |
// By subscribing, validation is performed and the service call is executed for any .next events from performValidation |
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 UIKit | |
struct ImageStore { | |
static func delete(imageNamed name: String) { | |
guard let imagePath = ImageStore.path(for: name) else { | |
return | |
} | |
try? FileManager.default.removeItem(at: imagePath) |
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
int main(int argc, char *argv[]) { | |
@autoreleasepool { | |
@try { | |
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); | |
} @catch (NSException *exception) { | |
#if DEBUG | |
NSLog(@"\n\n********************"); | |
NSLog(@"UNHANDLED EXCEPTION:"); | |
NSLog(@"%@", exception); | |
NSLog(@"Stack trace: %@", [exception callStackSymbols]); |
NewerOlder