Skip to content

Instantly share code, notes, and snippets.

View evangwt's full-sized avatar
🎯
Focusing

evangwt

🎯
Focusing
View GitHub Profile
#!/bin/bash
usage ()
{
cat <<UsageHERE
boot2docker-fwd -- Helper function to quickly manage port forwards between the boot2docker-vm and the host
Usage: boot2docker-fwd [ -n RULE_NAME ] [ -h HOST_PORT ] [ -p {tcp|udp} ] [ -i HOST_IP ] GUEST_PORT
or boot2docker-fwd -d RULE_NAME
or boot2docker-fwd -l
or boot2docker-fwd -A
@evangwt
evangwt / example.php
Created January 21, 2016 07:04 — forked from dimzon/example.php
Persisting PHP sessions into mongodb (allows NLB without affinity)
<?php
// all default values
MongoSessionPersistence::create()
->connect()
->register();
// connect to concrete server/db
MongoSessionPersistence::create()
->connect('mongodb://mongo_server:27017', 'databaseName')
->useLifeTime(60*60) // lifetime=1 hour
@evangwt
evangwt / eval-hello.sh
Created March 31, 2019 14:07 — forked from bpo/eval-hello.sh
Redis Lua examples
redis-cli EVAL "$(cat hello.lua)" 0
package model
import (
"strings"
uuid "github.com/satori/go.uuid"
)
// BaseUUID auto gen uuid xorm base model
type BaseUUID struct {
@evangwt
evangwt / timestamp.go
Last active January 19, 2021 06:22
xorm timestamp
package common
import (
"fmt"
"time"
)
// Timestamp 自定义时间戳类型,支持Mysql的TIMESTAMP,DATETIME,DATE类型
type Timestamp int64
@evangwt
evangwt / go_routine_leak.go
Created June 1, 2019 01:29
go routine leak
package main
import (
"fmt"
"log"
"runtime"
"strconv"
"strings"
"sync"
"time"
@evangwt
evangwt / download.js
Created March 18, 2020 06:16
download file by axios with post
function download() {
let token = '';
let data = {id: id};
new Promise((resolve, reject) => {
axios({
url: `/`,
method: 'POST',
headers: {'X-USER-TOKEN': token}, // custom token
data: data, // json object
responseType: 'blob', // important!
@evangwt
evangwt / ddns.go
Created January 12, 2021 02:08 — forked from wendal/ddns.go
golang的dns缓存, 含流量统计
package ddns
import (
"log"
"net"
"sync"
)
var (
dnsLock = &sync.Mutex{}