Skip to content

Instantly share code, notes, and snippets.

Avatar

boz14676

  • Beijing,China
View GitHub Profile
@bxcodec
bxcodec / _struct_to_map.go
Last active Aug 13, 2020
Golang Struct To Map Example By JSON tag
View _struct_to_map.go
/*
This function will help you to convert your object from struct to map[string]interface{} based on your JSON tag in your structs.
Example how to use posted in sample_test.go file.
*/
func structToMap(item interface{}) map[string]interface{} {
res := map[string]interface{}{}
if item == nil {
return res
}
View example.go
package main
import (
"database/sql/driver"
"encoding/json"
"github.com/jinzhu/gorm"
_ "github.com/lib/pq"
)
@ryerh
ryerh / tmux-cheatsheet.markdown
Last active Aug 14, 2020 — forked from MohamedAlaa/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表 & 简明教程
View tmux-cheatsheet.markdown

注意:本文内容适用于 Tmux 2.3 及以上的版本,但是绝大部分的特性低版本也都适用,鼠标支持、VI 模式、插件管理在低版本可能会与本文不兼容。

Tmux 快捷键 & 速查表 & 简明教程

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

@stupidbodo
stupidbodo / aes_encryption.go
Last active Jul 27, 2020
AES Encryption Example in Golang
View aes_encryption.go
// Playbook - http://play.golang.org/p/3wFl4lacjX
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
@mattetti
mattetti / multipart_upload.go
Last active Aug 14, 2020
Example of doing a multipart upload in Go (golang)
View multipart_upload.go
package main
import (
"bytes"
"fmt"
"io"
"log"
"mime/multipart"
"net/http"
"os"
@aeurielesn
aeurielesn / util.php
Created Jul 31, 2011
Decode Unicode strings in PHP
View util.php
<?php
#source: http://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-char
function replace_unicode_escape_sequence($match) {
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
}
function unicode_decode($str) {
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $str);
}
You can’t perform that action at this time.