Skip to content

Instantly share code, notes, and snippets.

View im-wmkong's full-sized avatar
🤔

Weimin Kong im-wmkong

🤔
  • Beijing, China
  • 13:38 (UTC +08:00)
View GitHub Profile
package validator
import (
"errors"
"reflect"
"strings"
"github.com/gin-gonic/gin/binding"
"github.com/go-playground/locales/zh"
ut "github.com/go-playground/universal-translator"
package response
import (
"errors"
"net/http"
"exceptions"
"github.com/gin-gonic/gin"
)
package exceptions
import (
"errors"
"net/http"
)
const separator = 1000
var (
@im-wmkong
im-wmkong / casbin.go
Last active September 14, 2024 08:21
package casbin
import (
"errors"
"net/http"
"strconv"
"strings"
"github.com/casbin/casbin/v2"
gormadapter "github.com/casbin/gorm-adapter/v3"
@im-wmkong
im-wmkong / gorm_query_builder.go
Last active July 19, 2024 08:19
Golang gorm query builder
package querybuilder
import (
"context"
"fmt"
"gorm.io/gorm"
)
// use:
@im-wmkong
im-wmkong / lib.js
Last active September 7, 2022 06:20
const sort = unsorted => Object.keys(unsorted).sort().reduce((result, key) => (result[key] = unsorted[key], result), {});
const flatten = list => Object.keys(list).reduce((result, key) => result.concat(list[key]), []);
const groupBy = (arr, key) => arr.reduce((result, item) => ((result[item[key]] = result[item[key]] || []).push(item), result), {});
const only = (arr, keys) => arr.map(item => keys.filter(key => key in item).reduce((result, key) => (result[key] = item[key], result), {}));
const fuzzy = (data, key) => data[Object.keys(data).find(element => element.includes(key))];
<?php
/**
* Tap class
*
* @author WmKong<im.wmkong@gmail.com>
*/
class Tap
{
/**
<?php
/**
* Collection class
*
* @author WmKong<im.wmkong@gmail.com>
*/
class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable, Serializable
{
/**
<?php
/**
* ArrayStore class
*
* @author WmKong <im.wmkong@gmail.com>
*/
class ArrayStore implements ArrayAccess
{
/**
<?php
/**
* Redis 分布式锁
*
* @author WmKong <im.wmkong@gmail.com>
*/
class Lock
{
/**