introduce-docker

这篇文章是只是简单的入门,所以这里会教你怎么可以简单的上手。比如以前完全没有用过 docker,现在要跑一个服务要用docker来跑。

什么是docker

以下是docker官网的介绍

……

Continue reading

vim函数feedkeys使用说明

很多人在使用feedkeys函数的时候会得取不预期的输出,怎么折腾也搞不明白为什么会得到 这样的结果。这篇文章来给大家解疑一下。

feedkeys函数文档

feedkeys({string} [, {mode}])				*feedkeys()*
		Characters in {string} are queued for processing as if they
		come from a mapping or were typed by the user.
		By default the string is added to the end of the typeahead
		buffer, thus if a mapping is still being executed the
		characters come after them.  Use the 'i' flag to insert before
		other characters, they will be executed next, before any
		characters from a mapping.
		The function does not wait for processing of keys contained in
		{string}.
		To include special keys into {string}, use double-quotes
		and "\..." notation |expr-quote|. For example,
		feedkeys("\<CR>") simulates pressing of the <Enter> key. But
		feedkeys('\<CR>') pushes 5 characters.
		If {mode} is absent, keys are remapped.
		{mode} is a String, which can contain these character flags:
		'm'	Remap keys. This is default.
		'n'	Do not remap keys.
		't'	Handle keys as if typed; otherwise they are handled as
			if coming from a mapping.  This matters for undo,
			opening folds, etc.
		'i'	Insert the string instead of appending (see above).
		'x'	Execute commands until typeahead is empty.  This is
			similar to using ":normal!".  You can call feedkeys()
			several times without 'x' and then one time with 'x'
			(possibly with an empty {string}) to execute all the
			typeahead.  Note that when Vim ends in Insert mode it
			will behave as if <Esc> is typed, to avoid getting
			stuck, waiting for a character to be typed before the
			script continues.
		'!'	When used with 'x' will not end Insert mode. Can be
			used in a test when a timer is set to exit Insert mode
			a little later.  Useful for testing CursorHoldI.

		Return value is always 0.

说明文档说了这个函数的使用方式,但是对于大部分人,只理解了一部分,帮而会产生很多 不解的行为。这个函数会把参数中的{string}当前是用户输入的。默认的,它会把string 的内容放到预输入的buffer(下面直接引用说明文档中的typeahead buffer)中。 对于不解行为,主要都是由这个typeahead buffer产生了。这个typeahead buffer并不是我 们所熟悉的vim与文档内容关联的buffer,下面会对它进行详细的说明。很多人认为,只要 一调用feedkeys,它就立刻产生作用。例如下面这个例子:

……

Continue reading

prometheus丢数据调试与处理

influxdb数据旁路一份到prometheus后,prometheus的图有时延时很大,主要是在业务忙的 时候,闲的时候是可以处理到数据的。而influxdb的数据是可以正常显示的。而且这时牛逼 的google并帮不了忙,各种关键字去搜索都找不到相关的问题。

……

Continue reading

Golang直接操作共享内存

Golang不使用cgo,直接操作共享内存。

前言

故事起源于要搭一个高性能的日志中心。当然使用了elk这一套。但是,对于logstash来说, 它主要使用的是文件日志的方式了捕捉log。而写文件日志的话会非常慢。对于实时日志要 处理滚动的日志更是这样,每次检查是否需要流动日志,然后打开日志,然后写入,然后 关闭,当然这中间可以优化。这一切都是那么慢,发起了n个系统调用,硬盘寻道等。这时 候想到了用共享内存来通信。

……

Continue reading