Skip to content

Instantly share code, notes, and snippets.

View xsync.go
package xsync
import (
"context"
"fmt"
"runtime/debug"
)
// PanicGroup 并行执行多个协程并捕获所有 panic
// 使用方法如下
View grpc-unary-client.go
package main
import (
"bytes"
"context"
"crypto/tls"
"encoding/binary"
"fmt"
"io"
"net"
View monkey.go
package main
import (
"fmt"
"reflect"
"syscall"
"unsafe"
)
func a() int {
@taoso
taoso / gist:c85ed8841e162b8c85ce58557e7a9017
Created February 27, 2017 15:01
compile php for psysh debuging
View gist:c85ed8841e162b8c85ce58557e7a9017
env YACC=`brew --prefix bison`/bin/bison ./configure
--disable-all
--prefix=/tmp/php71
--enable-phar
--enable-zip
--enable-tokenizer
--enable-json
--enable-posix
--with-libedit
@taoso
taoso / epoll-example-pipe.c
Created January 17, 2017 16:24 — forked from AndreasVoellmy/epoll-example-pipe.c
epoll_ctl with EPOLLET on an already readable file
View epoll-example-pipe.c
// compile with: gcc epoll-example-pipe.c
#include <stdio.h>
#include <stdlib.h>
#include <sys/epoll.h>
#define MAXEVENTS 64
int
main (int argc, char *argv[])
@taoso
taoso / a.sh
Last active March 5, 2020 22:19
manually set openvpn route by script for Tunnelblick on macOS
View a.sh
#!/usr/bin/env php
# you should add the following two line in you ovpn.conf
# route-noexec # donot let openvpn set local route
# route-up a.sh # run a.sh under ~/Library/Application Support/Tunnelblick/Configurations/bilibili.tblk/Contents/Resources
<?php
$env = $_ENV;
$route = [];
@taoso
taoso / mms.md
Created July 13, 2016 07:35 — forked from erning/mms.md
多关键字的文本精确匹配搜索
View mms.md

多关键字的文本精确匹配搜索 (mss - Multi-String Search)

基本的要求是对给定的一个文本块进行关键字匹配,进行匹配的关键字是多个,而且可能非常多(成千上万),然后输出各个匹配到的关键字的位置。这可用用作关键字的高亮显示,当然也可用进行敏感词过滤。

参考linux命令行fgrep

功能

输入一段文本,输出匹配到的关键字在输入文本中的位置。

例如,关键词列表:

@taoso
taoso / gist:9443108
Created March 9, 2014 04:59
套接字提交POST请求发送报警信息
View gist:9443108
# -*- coding: utf-8 -*-
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM);
s.connect(('192.168.8.20', 3000))
m = '{"username":"test20","message":"测试"}'
mp = (
"POST /notice HTTP/1.0\r\n"
"Content-Type:application/json\r\n"
@taoso
taoso / gist:9426971
Created March 8, 2014 07:54
curl发送报警通知
View gist:9426971
# curl -H "Content-Type: application/json" -d '{"username":"test20","message":"测试"}' http://192.168.8.20:3000/notice -v
* Hostname was NOT found in DNS cache
* Trying 192.168.8.20...
* Connected to 192.168.8.20 (192.168.8.20) port 3000 (#0)
> POST /notice HTTP/1.1
> User-Agent: curl/7.35.0
> Host: 192.168.8.20:3000
> Accept: */*
> Content-Type: application/json
> Content-Length: 40
@taoso
taoso / gist:9382894
Last active August 29, 2015 13:57
cJSON解析字符串
View gist:9382894
#include <stdio.h>
#include <stdlib.h>
#include "cJSON.h"
void doit(char *text)
{
char *out;cJSON *json;
json=cJSON_Parse(text);
if (!json) {printf("Error before: [%s]\n",cJSON_GetErrorPtr());}