Skip to content

Instantly share code, notes, and snippets.

View nhathm's full-sized avatar
🌴
On vacation

Hoàng Minh Nhật nhathm

🌴
On vacation
View GitHub Profile
@nhathm
nhathm / GetDataServerNonEscaping.swift
Created April 24, 2017 07:37
Sample about get data from server, this case will be failed because not using @escaping
//: Playground - noun: a place where people can play
// nhathm01247@gmail.com
import Foundation
import UIKit
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
class ServerConnection: NSObject {
@nhathm
nhathm / EscapingClosureSample.Swift
Created April 25, 2017 06:19
Sample closure escaping defination
func getDataFromServer(url: String, completion: @escaping (String?) -> ()) {
//
}
getDataFromServer(url: "http://0.0.0.0:8888/test") { (response) in
//
}
@nhathm
nhathm / EscapingClosureServerConnection.Swift
Created April 25, 2017 06:43
Sample function connect to server need to be escaping
//: Playground - noun: a place where people can play
// nhathm01247@gmail.com
import Foundation
import UIKit
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
class Worker: NSObject {
@nhathm
nhathm / docker-compose.yml
Created May 3, 2018 15:31 — forked from boiyama/docker-compose.yml
docker-compose.yml configuring GitLab with Container Registry, Pages, CI, Mattermost (enabled WebRTC), and some other options
version: '2'
services:
gitlab:
container_name: gitlab
image: gitlab/gitlab-ce:latest
restart: always
environment:
GITLAB_OMNIBUS_CONFIG: |
## GitLab configuration settings
##! Check out the latest version of this file to know about the different
@nhathm
nhathm / Swift-ArraySetDictionary.swift
Last active March 13, 2019 09:29
Swift - Array, Set, Dictionary
import Foundation
import UIKit
// Arrays are ordered collections of values.
// Sets are unordered collections of unique values.
// Dictionaries are unordered collections of key-value associations.
(print("\n=== ARRAY SECTION ===\n"))
// Create empty array of strings
var stringArray = [String]()
import Foundation
struct Student {
let firstName : String
let lastName : String
}
extension Student : Hashable {
static func == (lhs: Student, rhs: Student) -> Bool {
return lhs.firstName == rhs.firstName && lhs.lastName == rhs.lastName
let backslashString = "Hello, backslash \\"
// output: Hello, backslash \
let quotemarkString = "Hello, quote mark \""
// output: Hello, quote mark "
let rawStringInSwift5 = #"This is a sample about backslash \ and quote mark " in Swift 5"#
// output: This is a sample about backslash \ and quote mark " in Swift 5
let age = 18
let ageDescription = #"My age = \#(age)"# // Swift 4.2: \(age) => Swift 5: \#(age)
// output: My age = 18
let rawStringWithHashSymbol = ##"Sample raw string with # symbol"##
// output: Sample raw string with # symbol