Skip to content

Instantly share code, notes, and snippets.

View jhonny-me's full-sized avatar
🍼
feeding AI

JohnnyGu jhonny-me

🍼
feeding AI
View GitHub Profile
@jhonny-me
jhonny-me / StringResource+Localization.swift
Created June 23, 2020 14:41
R.swift extension to support in-app switch
//
// StringResource+Localization.swift
// Core
//
// Created by Johnny Gu on 2020/6/22.
//
import Foundation
import Rswift
@jhonny-me
jhonny-me / datePicker.swift
Created April 12, 2017 03:11
UIDatePicker sample
//
// ViewController.swift
// demo
//
// Created by Johnny Gu on 05/12/2016.
// Copyright © 2016 Johnny Gu. All rights reserved.
//
import UIKit
struct YourUserDefaults {
...
func set(_ value: Any?, for key: String) {
// some encrypt work
...
UserDefaults.standard.set(ValueAfterEncrypt, forKey: key)
}
func object(for key: String) -> Any?{
let value = UserDefaults.standard.value(forKey: key)
struct YourUserDefaults {
...
func set(_ value: Any?, for key: String) {
// some encrypt work
...
UserDefaults.standard.set(ValueAfterEncrypt, forKey: key)
}
func object(for key: String) -> Any?{
let value = UserDefaults.standard.value(forKey: key)
@jhonny-me
jhonny-me / MLLabel.swift
Created January 10, 2017 07:10
Mutilple links in Label
//
// MLLabel.swift
// Starbucks
//
// Created by Johnny Gu on 09/01/2017.
// Copyright © 2017 Wiredcraft. All rights reserved.
//
import UIKit
@jhonny-me
jhonny-me / timer_break_retain.swift
Created January 4, 2017 09:15
Timer extension which breaks the retain cycle in Swift3
// coming form https://gist.github.com/onevcat/2d1ceff1c657591eebde, adapt swift3
private class Block<T> {
let f : T
init (_ f: T) { self.f = f }
}
extension Timer {
static func xxx_scheduledTimer(timeInterval ti: TimeInterval, repeats: Bool, block: ()->()) -> Timer {
return self.scheduledTimer(timeInterval: ti, target: self, selector: #selector(xxx_blcokInvoke), userInfo: Block(block), repeats: repeats)
}
@jhonny-me
jhonny-me / docker.md
Created October 8, 2016 15:11 — forked from loganwright/docker.md
Docker

Dockerfile

FROM ibmcom/swift-ubuntu:latest

# Install Vapor Toolbox
RUN curl -sL toolbox.vapor.sh | bash

# Set work dir to /vapor
WORKDIR /vapor
@jhonny-me
jhonny-me / index.html
Created February 26, 2016 01:48
obKREQ
<style>
body {
}
#container {
background-color: rgb(238,238,238);
margin: 60px 20px 20px 20px;
border-radius: 10px;
}
#imgContainer{