Skip to content

Instantly share code, notes, and snippets.

@lengocgiang
lengocgiang / reflectcode.go
Created August 30, 2017 07:31
reflect code
// old
func getPreferredProductRefIdsFromContactProgress(contactProgress models.ContactProgress) []int {
if !contactProgress.IsEmpty() {
enterInfo := contactProgress.EnterInfo
enterInfoMap := make(map[string]interface{})
json.Unmarshal([]byte(enterInfo), &enterInfoMap)
if enterInfoMap["product_ref_ids"] != nil {
value := reflect.ValueOf(enterInfoMap["product_ref_ids"])
fmt.Println(value.Kind(), enterInfoMap["product_ref_ids"])
var rawData string
@lengocgiang
lengocgiang / animation.swift
Created December 3, 2017 09:52
addSubview and removeFromSuperview animation in Swift 4.0
# addSubview
UIView.transition(with: self.view, duration: 0.25, options: [.transitionCrossDissolve], animations: {
self.view.addSubview(view)
}, completion: nil)
# removeFromSuperview
UIView.transition(with: self.view, duration: 0.25, options: [.transitionCrossDissolve], animations: {
subview.removeFromSuperview()
}, completion: nil)
@lengocgiang
lengocgiang / time_format.go
Created August 28, 2018 11:14
format with string
package ivimage
import (
"fmt"
"testing"
"time"
)
func TestImage_Save(t *testing.T) {
// Please dont change value, you should change format