Skip to content

Instantly share code, notes, and snippets.

@iMega
iMega / gist:f9a69bba7a30048dc621811dcb090846
Created October 17, 2016 05:30
Список файла которое было закомичено
git diff-tree --no-commit-id --name-only -r fb587275b02b6ca5e4e12bef3dabfb7839039eb7 | grep ".php"
@iMega
iMega / port-forwarding-boot2docker
Last active February 23, 2017 12:01
Port Forwarding boot2docker parallels mac os x openarena
$ prlctl list --all | awk '{print $1}'
UUID
{e5e69367-7b17-4585-82a4-1e8d83813f09}
$ prlsrvctl net list
Network ID Type Bound To
Shared shared vnic0
$ prlsrvctl net info Shared
...
```
$ shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'
```
SET @tables = NULL;
SELECT GROUP_CONCAT(table_schema, '.', table_name)
INTO @tables
FROM information_schema.tables
WHERE table_schema = 'ippart';
SET @tables = CONCAT('DROP TABLE ', @tables);
PREPARE stmt FROM @tables;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
package mail
import "time"
type From []Mailbox
type Sender Mailbox
type ReplyTo []Address
func EqualWithDuration(t *testing.T, expected, actual interface{}, delta time.Duration) bool {
a := reflect.ValueOf(actual)
e := reflect.ValueOf(expected)
for i := 0; i < a.NumField(); i++ {
if a.Field(i).Type() == reflect.TypeOf(time.Time{}) {
assert.WithinDuration(t, e.Field(i).Interface().(time.Time), a.Field(i).Interface().(time.Time), delta)
} else {
assert.Equal(t, e.Field(i).Interface(), a.Field(i).Interface())
}
@iMega
iMega / spawn.lua
Created December 22, 2017 09:38 — forked from neomantra/spawn.lua
Using LuaJIT FFI, spawn a Linux command in the background.
-- Spawn a command in the background, optionally redirecting stderr and stdout
--
-- requiring this file returns a function(cmd_line, stdout_redirect, stderr_redirect)
--
-- `cmd_line` is the command with possible arguments
-- optional `stdout_redirect` is io.stdout, io.stderr, or a filename. default/nil is io.stdout
-- optional `stderr_redirect` is io.stdout, io.stderr, or a filename. default/nil is io.stderr
--
-- Example:
-- luajit -e 'require("spawn")("cat /etc/network/interfaces", "foo1", io.stdout)'
@iMega
iMega / use-opentracing
Created March 14, 2018 16:13
Как отслеживать все поведение распределенной транзакции?
## 系统执行一条SQL,到底慢在哪里?
如何跟踪一个分布式事务的所有行为?使用 [opentracing](http://opentracing.io/)! opentracing 是一个标准的分布式 tracing 的协议。支持 Go, JavaScript, Java, Python, Ruby, PHP, Objective-C, C++, C# 等等许多的语言(暂时没看到 rust 的库)。
[一些基本的概念](https://github.com/opentracing/specification/blob/master/specification.md#the-opentracing-data-model):一个 Trace 是由许多 Span 构成的一个有向无环图。Span 之间的边的关系叫做 Reference。
Span 里面的信息包括:操作的名字,开始时间和结束时间,可以附带多个 key:value 构成的 Tags(key必须是string,value可以是 string, bool 或者数字),还可以附带 Logs 信息(不一定所有的实现都支持),也是 key:value形式。
下面例子是一个 Trace,里面有8个 Span:
package grpc
import (
"math"
"time"
"github.com/davecgh/go-spew/spew"
"github.com/facebookgo/stack"
"github.com/grpc-ecosystem/go-grpc-middleware"
grpclogrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"