Skip to content

Instantly share code, notes, and snippets.

View nRewik's full-sized avatar

Nutchaphon Rewik nRewik

View GitHub Profile
@nRewik
nRewik / test.json
Last active December 3, 2020 06:40
TestJa
{
"3.2.4": "https://github.com/EkoCommunications/EkoMessagingSDK/releases/download/3.2.4/EkoChat.zip",
"3.2.5": "https://github.com/EkoCommunications/EkoMessagingSDK/releases/download/3.2.5/EkoChat.zip",
"3.2.6": "https://github.com/EkoCommunications/EkoMessagingSDK/releases/download/3.2.6/EkoChat.zip",
"3.2.7": "https://github.com/EkoCommunications/EkoMessagingSDK/releases/download/3.2.7/EkoChat.zip",
"4.0.0": "https://github.com/EkoCommunications/EkoMessagingSDK/releases/download/4.0.0/EkoChat.zip",
"4.2.0": "https://github.com/EkoCommunications/EkoMessagingSDK/releases/download/4.2.0/EkoChat.zip",
"4.3.0": "https://github.com/EkoCommunications/EkoMessagingSDK/releases/download/untagged-9c8ca455a4d43a293107/ekochat-4.3.0-dev.zip"
}
{
"todo": [
{
"id": "0cd7190c-c99b-4716-a6ab-e36432aca084",
"title": "non labore quam",
"description": "Est enim dolor. Vitae cumque doloremque voluptas. Ex autem voluptas neque facilis deserunt eius fugit possimus molestias.",
"userId": "94375b4e-b500-4264-883f-81e920fccc58",
"createdAt": "2019-10-16T10:30:11.563Z"
},
{
{
"todo": [
{
"id": "ffcedd58-bf77-4e90-a153-32e6723b16c4",
"title": "deleniti sapiente ut",
"description": "Ut odit sequi iste. Quaerat veritatis officia. Quas doloribus velit dolorem laborum totam.",
"userId": "d29a3b73-732d-4218-b9e2-9dc3b1c5c59b",
"createdAt": "2020-06-30T07:08:06.932Z"
},
{
@nRewik
nRewik / 0_EqualWidthVStackChildren.md
Last active April 20, 2024 04:26
SwiftUI - Make the children in VStack equal width, and expand dynamically

Problem

Begin with VStack that contain texts as children.

struct TestView: View {
    
    var body: some View {
        VStack(alignment: .trailing) {
            Text("Hello, World!")
import UIKit
let text = "Saw yet kindness too replying whatever marianne. Old sentiments resolution admiration unaffected its mrs literature. (https://www.google.com/), Situation admitting promotion at or to perceived be. Mr acuteness we as estimable enjoyment up. An held late as felt know."
let font = UIFont.preferredFont(forTextStyle: .body)
let highlightFont = UIFont.preferredFont(forTextStyle: .headline)
let attributedText = NSMutableAttributedString(string: text, attributes: [
.font : font
])

Keybase proof

I hereby claim:

  • I am nrewik on github.
  • I am nrewik (https://keybase.io/nrewik) on keybase.
  • I have a public key ASA5UgYMoNUfaxy7wRAk2xm85HAyTz_7wYbTiX52ZZyv9go

To claim this, I am signing this object:

@nRewik
nRewik / TransformTransitioning.swift
Last active October 2, 2018 14:26
view controller transition from origin view to another view controller.
//: Playground - noun: a place where people can play
import UIKit
import XCPlayground
extension UIView{
var snapshot: UIImage{
UIGraphicsBeginImageContextWithOptions(bounds.size, false, 0);
@nRewik
nRewik / Rule.swift
Created October 20, 2015 14:06
A rule-based string validator
//: Playground - noun: a place where people can play
import UIKit
import XCPlayground
public typealias Validator = String -> Bool
public typealias ValidatorTransformer = Validator -> Validator
public typealias ValidatorCombiner = ( Validator , Validator ) -> Validator
public enum Rule{
@nRewik
nRewik / chainingRequestCallback.swift
Created September 10, 2015 13:37
an example of request chaining using NSURLSession Callback
// 1. login post request
NSURLSession.sharedSession().dataTaskWithRequest(loginRequest){ data , res , err in
// let token = data...
// we have token.
let getCurrentUserURL = NSURL(string: getUserDataURL + "?token=\(token)")!
// 2. get current user data
NSURLSession.sharedSession().dataTaskWithURL(getCurrentUserURL){ data , res , err in
// we have user data, and we get currentUserID
@nRewik
nRewik / PromiseTaskExample.swift
Created September 10, 2015 13:28
an example of how to create an async promise task
func getUserData(#token: String) -> Promise<User>{
return Promise<User>{ fulfill, reject in
let task = NSURLSession.sharedSession().dataTaskWithURL(self.getCurrentUserURL){ data , res , err in
if let err = err{
return reject(err)
}
let user = User(data: data)
return fulfill(user)
}
task.resume()