This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"+__ruleListOf_自动切换": { | |
"color": "#99dd99", | |
"defaultProfileName": "direct", | |
"format": "AutoProxy", | |
"matchProfileName": "代理服务", | |
"name": "__ruleListOf_自动切换", | |
"profileType": "RuleListProfile", | |
"revision": "195bd5b4617", | |
"sourceUrl": "https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"errors" | |
"fmt" | |
"sync" | |
"time" | |
) | |
const ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./configure --prefix=/opt/websuite/nginx \ | |
--conf-path=/opt/config/nginx/nginx.conf \ | |
--modules-path=/opt/websuite/nginx/modules \ | |
--error-log-path=/opt/logs/nginx/error.log \ | |
--http-log-path=/opt/logs/nginx/access.log \ | |
--pid-path=/opt/run/nginx --user=websuite \ | |
--group=websuite \ | |
--with-file-aio \ | |
--with-http_ssl_module \ | |
--with-http_v2_module \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gotin | |
import ( | |
"errors" | |
"reflect" | |
"sort" | |
) | |
var ( | |
ErrUnSupportHaystack = errors.New("haystack must be slice, array or map") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func IsIpv4(s string) bool { | |
var p [IPv4len]byte | |
for i := 0; i < IPv4len; i++ { | |
if len(s) == 0 { | |
// Missing octets. | |
return false | |
} | |
if i > 0 { | |
if s[0] != '.' { | |
return false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type eventGenerator struct { | |
eventCh chan int | |
ctx context.Context | |
cancel context.CancelFunc | |
} | |
func NewEventGenerator(ctx context.Context) *eventGenerator { | |
// better to get context from others place, even this is a most up level controller | |
// because you can use `context.Background()` as argument if this is the most up level one | |
ctx, cancel := context.WithCancel(ctx) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package roundrobin | |
// RR: 基于 权重round robin算法的接口 | |
type RR interface { | |
Next() interface{} | |
Add(node interface{}, weight int) | |
RemoveAll() | |
Reset() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 发起一个自定义请求 | |
* @param string $url | |
* @param string $method | |
* @param array $options | |
* @param array $headers | |
* @param array $vars | |
* @return HttpResponse|string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
netsh interface portproxy add v4tov4 listenport=3333 connectaddress=172.17.30.42 connectport=3306 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 使用 snowflake 算法生成递增的分布式唯一ID. | |
* 该算法支持 15 条业务线,4 个数据中心,每个数据中心最多 128 台机器,每台机器每毫秒可生成 4096 个不重复ID. | |
*/ | |
class Snowflake | |
{ | |
const SEQUENCE_BITS = 12; | |
const MILLISECOND_BITS = 39; | |
const BUSINESS_ID_BITS = 4; | |
const DATA_CENTER_ID_BITS = 2; |