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
def productExceptSelf2(self, nums): | |
""" | |
:type nums: List[int] | |
:rtype: List[int] | |
""" | |
aryRes = [] | |
for index in range(len(nums)): | |
#print nums[:index], nums[index+1:] | |
product_left = reduce(lambda x,y:x*y,nums[:index]) if(nums[:index]!=[]) else 1 | |
product_right = reduce(lambda x,y:x*y,nums[index+1:]) if(nums[index+1:]!=[]) else 1 |
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
def productExceptSelf3(self, nums): | |
""" | |
:type nums: List[int] | |
:rtype: List[int] | |
""" | |
size = len(nums) | |
ary_left = [1] * size | |
ary_right = [1] * size | |
ary_res = []` |
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 "ViewController.h" | |
@interface ViewController (){ | |
UIViewController *anotherView; | |
} | |
@end | |
@implementation ViewController |
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
// | |
// ViewController.swift | |
// Testviewcontoller | |
// | |
// Created by Ben Liu on 14/4/17. | |
// Copyright © 2017 Ben Liu. All rights reserved. | |
// | |
import UIKit |
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
// Make a phone call | |
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:12125551212"]]; | |
// Open an url using default brower Safari | |
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.arkilis.me"]] | |
// Send an email by calling Email app | |
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:[email protected]"]]; | |
// Send a SMS |
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
// Make a phone call | |
UIApplication.shared.openURL(URL(string: "tel:12125551212")!) | |
// Open an url using default brower Safari | |
UIApplication.shared.openURL(URL(string: "http://www.arkilis.me")!) | |
// Send an email by calling Email app | |
UIApplication.shared.openURL(URL(string: "mailto:[email protected]")!) | |
// Send a SMS |
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 UIKit | |
extension UIColor { | |
convenience init(hex: String) { | |
let scanner = Scanner(string: hex) | |
scanner.scanLocation = 0 | |
var rgbValue: UInt64 = 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
labelPrice.textColor = UIColor.init(hex: "0000FF") |
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/UIKit.h> | |
@interface UIColor (HexColor) | |
+ (UIColor *)colorFromHexString:(NSString *)hexString; | |
@end |
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
+ (UIColor *)colorFromHexString:(NSString *)hexString { | |
unsigned rgbValue = 0; | |
NSScanner *scanner = [NSScanner scannerWithString:hexString]; | |
[scanner setScanLocation:1]; // bypass '#' character | |
[scanner scanHexInt:&rgbValue]; | |
return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0]; | |
} |