Skip to content

Instantly share code, notes, and snippets.

@bxcodec
bxcodec / _struct_to_map.go
Last active Apr 24, 2021
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
}
@pokev25
pokev25 / install-tmux.sh
Last active May 14, 2021 — forked from rothgar/install-tmux
Install tmux 2.8 on centos 7
View install-tmux.sh
# Install tmux 2.8 on Centos
# install deps
yum install gcc kernel-devel make ncurses-devel
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
curl -LOk https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
tar -xf libevent-2.1.8-stable.tar.gz
cd libevent-2.1.8-stable
./configure --prefix=/usr/local
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 Jun 11, 2021 — 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 Jun 1, 2021
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 Jun 10, 2021
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);
}