Skip to content

Instantly share code, notes, and snippets.

View ohtwo's full-sized avatar
🌙
° ☾ ☆ ¸. ¸ ★ :.  . • ○ ° ★

Kang Byeonghak ohtwo

🌙
° ☾ ☆ ¸. ¸ ★ :.  . • ○ ° ★
View GitHub Profile
@ohtwo
ohtwo / appDelegate.swift
Last active August 29, 2015 14:23
Setup push notifications in Swift
/**
* How to setup push notifications in Swift
* http://stackoverflow.com/questions/24899257/how-to-setup-push-notifications-in-swift
*/
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
//
// AppDelegate.swift
// pushtest
//
// Created by sawapi on 2014/06/08.
// Copyright (c) 2014年 sawapi. All rights reserved.
//
// iOS8用
import UIKit
@ohtwo
ohtwo / dispatch_once.swift
Last active September 8, 2015 03:38 — forked from kristopherjohnson/dispatch_once.swift
Example of using dispatch_once() in Swift
import Foundation
var token: dispatch_once_t = 0
func test() {
dispatch_once(&token) {
println("This is printed only on the first call to test()")
}
println("This is printed for each call to test()")
}
@ohtwo
ohtwo / DynamicTableViewController.swift
Last active November 18, 2015 02:00
Resizable Table Footer View
/*
* Solution - https://github.com/daveanderson/TableViewHeader
*/
class DynamicTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@ohtwo
ohtwo / NSDate+RFC3339.swift
Created November 19, 2015 06:49 — forked from algal/NSDate+RFC3339.swift
NSDate+RFC3339
extension NSDate {
var stringFormattedAsRFC3339: String {
return rfc3339formatter.stringFromDate(self)
}
class func dateFromRFC3339FormattedString(rfc3339FormattedString:String) -> NSDate?
{
/*
NOTE: will replace this with a failible initializer when Apple fixes the bug
that requires the initializer to initialize all stored properties before returning nil,
@ohtwo
ohtwo / ioslocaleidentifiers.csv
Created January 22, 2016 12:25 — forked from jacobbubu/ioslocaleidentifiers.csv
iOS Locale Identifiers
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
ml_IN Malayalam (India)
ro_MD Romanian (Moldova)
@ohtwo
ohtwo / lazyVariable.swift
Last active May 9, 2016 02:08
Lazy Variable without Capturing
lazy var icon: UIImage = { [unowned self] in
guard let iconName = self.iconName, icon = UIImage(named: iconName) else {
return UIImage()
}
return icon
}
import Foundation
public struct Meter {
fileprivate var value: Double
public init(_ value: Double) {
self.value = value
}
public init(_ value: Int) {
@ohtwo
ohtwo / gmsmarker.swift
Last active October 27, 2020 01:19
GMSMarker with Drop Shadow
import Foundation
import GoogleMaps
func getShadowMarker() -> GMSMarker {
let marker = GMSMarker()
let image = UIImageView(image: UIImage(named: "marker"))
marker.iconView = image
marker.iconView?.contentMode = .center
marker.iconView?.bounds.size.width *= 2
@ohtwo
ohtwo / fonts.swift
Created May 3, 2017 06:42
fonts.swift
// Fonts
for family in UIFont.familyNames
{
print("\(family)")
for names in UIFont.fontNames(forFamilyName: family)
{
print("== \(names)")
}
}