Skip to content

Instantly share code, notes, and snippets.

View hyukhur's full-sized avatar

Hyuk Hur hyukhur

View GitHub Profile
@hyukhur
hyukhur / Disable.swift
Created May 10, 2017 06:20
Suger function to remove ! mark.
protocol Disable {
var not: Bool { get }
}
extension Bool: Disable {
var not: Bool {
return !self
}
}
@hyukhur
hyukhur / iterateEnum.swift
Created May 10, 2017 08:00
Iterate All cases at a enum.
// Swift 3.1
func iterateEnum<T: Hashable>(_: T.Type) -> AnyIterator<T> {
var i = 0
return AnyIterator {
let next = withUnsafeBytes(of: &i) { $0.load(as: T.self) }
if next.hashValue != i { return nil }
i += 1
return next
}
@hyukhur
hyukhur / UIButton+Extensions.swift
Created October 23, 2017 03:02
Sugary Button. - its appearance could be disable but be able to be tapped to show alert view.
// its appearance could be disable but be able to be tapped to show alert view.
private extension UIControlState {
private static let localScope = UIControlState.application.rawValue | 0x0000FF00
static var normalState = UIControlState(rawValue: localScope | 1 << 1)
static var blockingState = UIControlState(rawValue: localScope | 1 << 2)
}
extension UIButton {
var isBlocked: Bool = false {
didSet {
@hyukhur
hyukhur / luhn_check_sum.swift
Created November 9, 2017 08:01
luhn check sum
func luhnCheckSum(number stringWithoutSpaces: String) -> Bool {
guard let _ = Int(stringWithoutSpaces) else { return false }
var even = 0
var sum = 0
for char in stringWithoutSpaces.reversed() {
guard let decimals = Int(String(char)) else { continue }
let added: Int = decimals * ( 1 << (even & 1) )
even = even + 1
sum = sum + added % 10 + added / 10
}
@hyukhur
hyukhur / XCTestExtension.swift
Created December 1, 2017 02:43
XCTests runs the UIApplication while it tested. It cause the root view controller's 'viewDidLoad' function it can be change test environments.
let isRunningTests: Bool = ProcessInfo.processInfo.environment["XCInjectBundleInto"] != nil
{
"profile": [{
"name" : "Hank Hur",
"picturePath" : "https://media.licdn.com/dms/image/C4D03AQHi1G39gRz6Vw/profile-displayphoto-shrink_200_200/0?e=1576713600&v=beta&t=kpja3bEO_nm8mA0_fNZkAl0iVmQ-LB_pLNv2TUSwZiQ",
"headline" : "Individual Lead Developer",
"location" : "Vancouver, BC, Canada",
"summary" : "12 year experienced iOS engineer and Java engineer"
}],
"about" : [{
"description" : "I'm looking for a great, enthusiastic engineering team to work for that will provide me with challenging, interesting work that I can learn from and contribute to. I'd like to get a chance to contribute more to iOS and back-end integration.\n I launched a group SNS app which reached 2M+ users in 3 months. I built everything from the lower layer like network and log-in to the higher layer like UI components and everything in between. I led an iOS team in SNS part which has 90M+ active users in a month in LINE the messenger. I suggested building an integrated image c
import React, { createContext, useContext, useReducer } from "react";
export default (reducer, actionTypes, initialState = {}) => {
const StateContext = createContext([{}, () => {}]);
const StateProvider = ({ children }) => {
const reduced = useReducer(
(state, action) => reducer(state, action, actionTypes),
initialState
);
return (
//
// Color+Additions.swift
// EasyDrugs
//
// Created by Hyuk Hur on 2020-11-16.
//
import SwiftUI
extension Color {