Skip to content

Instantly share code, notes, and snippets.

View arkilis's full-sized avatar
🎯
Focusing

Ben arkilis

🎯
Focusing
View GitHub Profile
@arkilis
arkilis / lc238_solution3
Created March 30, 2016 23:33
lc238_solution3
def productExceptSelf3(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
size = len(nums)
ary_left = [1] * size
ary_right = [1] * size
ary_res = []`
@arkilis
arkilis / viewContoller_4_methods_oc.m
Last active April 13, 2017 22:52
viewContoller_4_methods_oc
#import "ViewController.h"
@interface ViewController (){
UIViewController *anotherView;
}
@end
@implementation ViewController
@arkilis
arkilis / viewContoller_4_methods_swift.swift
Last active April 13, 2017 23:09
viewContoller_4_methods_swift
//
// ViewController.swift
// Testviewcontoller
//
// Created by Ben Liu on 14/4/17.
// Copyright © 2017 Ben Liu. All rights reserved.
//
import UIKit
@arkilis
arkilis / iOS_URL_Schemes_oc.m
Created April 14, 2017 00:14
iOS URL Schemes Objective-C
// 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:arkilis@gmail.com"]];
// Send a SMS
@arkilis
arkilis / iOS_URL_Schemes_swift.swift
Last active April 14, 2017 00:16
iOS URL Schemes Swift
// 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:arkilis@gmail.com")!)
// Send a SMS
@arkilis
arkilis / use_swift_extension.swift
Created April 21, 2017 22:34
Use Swift Extension
labelPrice.textColor = UIColor.init(hex: "0000FF")
@arkilis
arkilis / UIColor+HexColor.h
Created April 21, 2017 22:35
UIColor+HexColor.h
#import <UIKit/UIKit.h>
@interface UIColor (HexColor)
+ (UIColor *)colorFromHexString:(NSString *)hexString;
@end
@arkilis
arkilis / UIColor+HexColor.m
Created April 21, 2017 22:36
UIColor+HexColor.m
+ (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];
}
@arkilis
arkilis / category_use.m
Created April 21, 2017 22:37
use category
#import "UIColor+HexColor.h"
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = [UIColor colorFromHexString:@"#0080FF"];
}
@arkilis
arkilis / swift_extension.swift
Last active April 22, 2017 21:53
swift_extension
import Foundation
import UIKit
extension UIColor {
convenience init(hex: String) {
let scanner = Scanner(string: hex)
scanner.scanLocation = 0
var rgbValue: UInt64 = 0