Skip to content

Instantly share code, notes, and snippets.

:shipit:
:;]

lee nhatlee

:shipit:
:;]
Block or report user

Report or block nhatlee

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nhatlee
nhatlee / ScreenshotDetector
Last active Feb 26, 2019
ScreenshotDetector
View ScreenshotDetector
import UIKit
import Photos
/// A class that detects when the user has taken a screenshot and provides it via a delegate callback.
@available(iOS 9.0, *)
open class ScreenshotDetector: NSObject {
/// An error encountered when detecting and retreiving a screenshot.
public enum Error: Swift.Error {
@nhatlee
nhatlee / LinkedList
Last active Feb 13, 2019
Linkedlist Recursive Reverse
View LinkedList
class Node {
var data: Int
var next: Node?
// init(_ data: Int) {
// self.data = data
// }
init?(_ values: Array<Int>) {
var valuesCopy = values
if valuesCopy.count == 0 {
@nhatlee
nhatlee / StreamReader.swift
Created Jan 16, 2019 — forked from sooop/StreamReader.swift
Read a large text file line by line - Swift 3
View StreamReader.swift
import Foundation
class StreamReader {
let encoding: String.Encoding
let chunkSize: Int
let fileHandle: FileHandle
var buffer: Data
let delimPattern : Data
var isAtEOF: Bool = false
View gist:3459ee5b971b9a6fe2576b594ad113b1
-(UIImage*)mmg_imageScaledToFitSize:(CGSize)fitSize
{
// Create a vImage_Buffer from the CGImage
CGImageRef sourceRef = self.CGImage;
vImage_Buffer srcBuffer;
vImage_CGImageFormat format = {
.bitsPerComponent = 8,
.bitsPerPixel = 32,
.colorSpace = NULL,
.bitmapInfo = (CGBitmapInfo)kCGImageAlphaFirst,
View MirrorsPlayground.swift
protocol DogBreed {
typealias Level = Int
var breedName: String { get set }
var size: Level { get set }
var health: Level { get set }
var adaptability: Level { get set }
var intelligence: Level { get set }
var dogType: DogType { get set }
View ValidationViewController.swift
import UIKit
import RxSwift
import RxCocoa
let requiredUserNameLength = 5
let requiredPasswordLength = 5
let limitUserNameLength = 20
class ValidationViewController: UIViewController {
@nhatlee
nhatlee / array_structure.swift
Created Aug 1, 2018 — forked from austinzheng/array_structure.swift
A horrendous example of custom pattern matching in Swift
View array_structure.swift
// Playground - noun: a place where people can play
import Cocoa
enum Wildcard : NilLiteralConvertible {
case Single
case FromBeginning
case ToEnd
case Range(Int)
case Literal(Int)
View ExpressionBalanced.Swift
import UIKit
let openBrackets: [Character] = ["(", "{", "["]
let closedBrackets: [Character] = [")", "}", "]"]
func ~=<T: Equatable>(pattern: [T], value: T) -> Bool {
return pattern.contains(value)
}
func isExpressionBalanced(_ expression: String) -> Bool {
@nhatlee
nhatlee / UIView+Extension.swift
Created Jul 16, 2018 — forked from bishalg/UIView+Extension.swift
Swift UIView Extension for Inspectable CornerRadius, BorderWidth and BoarderColors etc
View UIView+Extension.swift
//
// UIView+Extension.swift
//
// Created by Bishal Ghimire on 4/30/16.
// Copyright © 2016 Bishal Ghimire. All rights reserved.
//
import UIKit
//
@nhatlee
nhatlee / genpass.swift
Created Jul 8, 2018 — forked from brennanMKE/genpass.swift
Generate a password with Swift
View genpass.swift
#!/usr/bin/env xcrun swift
import Foundation
public typealias CharactersArray = [Character]
public typealias CharactersHash = [CharactersGroup : CharactersArray]
public enum CharactersGroup {
case Letters
case Numbers
You can’t perform that action at this time.