Faust 传感器


class MySensor(Sensor):
    
    def on_message_in(self, tp: faust.types.tuples.TP, offset: int, message: faust.types.tuples.Message) -> None:
        print('=======================')
        print(message)

    def on_stream_event_in(self, tp: faust.types.tuples.TP, offset: int, stream: faust.types.streams.StreamT, event: faust.types.events.EventT) -> None:
        print('#################')
        print(event)


app = faust.App(
    'ht_app',
    broker=settings.KAFKA_URL
)

app.sensors.add(MySensor())

ELK只LogStash配置

代办

[√] Grok 可选字段配置

如何解决:

%{TIMESTAMP_ISO8601:timestamp} \[(?<filename>.*?.py)\] \[func:(?<func>.*?)\] \[line:%{NUMBER:line}\] \[%{LOGLEVEL:log_evel}\] (\[transaction:(?<transid>.*?)\])?(\[file_path:(?<file_path>.*?)\])?(\[language:(?<lang>.*?)\])?%{GREEDYDATA:content}

上面的grok表达式中, transaction/file_path/language 三个字段都是可选字段

[ ] Logstash 接受 同一个 beat的不同不同输入并route到正确的es 的index中

如何解决

解决方法:

同一个beat发送过来的logs即使在不同的log文件,那么他们的log.file.path字段就可以作为区分的条件,可以按如下判断条件:

# Sample Logstash configuration for creating a simple
# Beats -> Logstash -> Elasticsearch pipeline.

input {
  beats {
    port => 5044
  }
}

# sample:
# %{TIMESTAMP_ISO8601:timestamp} \\[file:(?<filename>.*?.py)\\] \\[func:(?<func>.*?)\\] \\[line:%{NUMBER:line}\\] \\[%{LOGLEVEL:log_evel}\\] %{GREEDYDATA:content}
# contain optional fields
# %{TIMESTAMP_ISO8601:timestamp} \[(?<filename>.*?.py)\] \[func:(?<func>.*?)\] \[line:%{NUMBER:line}\] \[%{LOGLEVEL:log_evel}\] (\[transaction:(?<transid>.*?)\])?(\[file_path:(?<file_path>.*?)\])?(\[language:(?<lang>.*?)\])?%{GREEDYDATA:content}

filter {
  if ("test1" in [tags]) and ([log][file][path] == "/logs/main.log") {
    grok {
      match => { "message" => "%{TIMESTAMP_ISO8601:timestamp} \[file:(?<filename>.*?.py)\] \[func:(?<func>.*?)\] \[line:%{NUMBER:line}\] \[%{LOGLEVEL:log_evel}\] (\[transaction:(?<transid>.*?)\])?(\[file_path:(?<file_path>.*?)\])?(\[language:(?<lang>.*?)\])?%{GREEDYDATA:content}"}
    } 
  }
}

output {
  # stdout { codec => rubydebug }
  if ("test1" in [tags]) and ([log][file][path] == "/logs/main.log") {
    elasticsearch {
      hosts => ["192.168.56.102:9200"]
      index => "test1-%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
    #   #user => "elastic"
    #   #password => "changeme"
    }
  }
  
}

[] Logstash 接受不同beat的输入并route到正确的es的index

如何解决

解决方法

在路径: /var/logstash/www/logstash-7.8.1/config/pipelines.yml 添加yml文件,内容如下

- pipeline.id: test1
  path.config: "/var/logstash/www/config/logstash.conf"

如果有多个pipeline则配置多个pipeline配置文件

Matter-js 抛投响应

Matter-js的文档连接

https://brm.io/matter-js/docs/classes/Engine.html

Make image transparency

https://onlinepngtools.com/create-transparent-png

生成主场景

生成场景第二版

生成武器

生成被攻击对象

C2M的四大必要条件

曾鸣和宋斐在他们2012年的文章中曾经指出,生产组织要真正从厂商为中心转向以消费者为中心,是需要若干个条件的:

一是消费者需求的转变。传统的“小品种、大批量”的生产模式是与收入水平较低、以满足生活必须为目的的消费需求结合在一起的。由于消费者的必须消费大致上是类似的,对于个性的要求不是那么高,因而制造商进行竞争的关键就是要压成本、提效率,只要把最终的价格压下来,就能在市场上胜出。但是当消费者的收入进一步提升之后,他们的需求就会升级,从满足必须转向到对个性化的追求。在这个阶段,他们的需求就会多样化、长尾化,C2M等以消费者为中心的商业模式才会有真正的市场。

二是互联网技术的发展。即使消费者的需求发生了改变,开始对个性化有了诉求,如果不能及时捕捉这些需求,并将它们转给制造商,整个C2M的过程就无法完成。而要实现这一切,技术,尤其是互联网技术的发展显然是不可或缺的。

三是柔性化生产技术的普及。一旦制造商获取了消费者的需求,下面的任务就是要根据这些需求组织生产。但是,这一切的实现并不简单。如果消费者的需求过于多样化,商品品类过于繁多,制造商对于产品质量的把控就会变得十分困难。一旦在某个参数上出错,产品就可能难以满足消费者的需求。

四是社会化协作的实现。要实现商品从制造到销售的整个流程,单单依靠制造商显然是不行的,它还依靠采购、物流、分销等各个环节的支撑。一旦客户有了一个个性化的需求,制造商就要先根据需求实现采购,在进行生产后,还需要按照要求将产品交付物流,送到消费者手中。如果这些环节中的某一个不能实现,那么整个流程就可能无法运转。

Vagrant Config file

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
#disk = 'D:\\data\\temp\\secondDisk.vdi'
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "ubuntu/bionic64"
  config.disksize.size = "150GB"
  config.vm.synced_folder "D:\\projects", "/projects", type: "nfs"
  config.vm.network "private_network", ip: "192.168.56.20"
  
  config.vm.provider :virtualbox do |vb|
  #   # Don't boot with headless mode
  #   vb.gui = true
  #
  #   # Use VBoxManage to customize the VM. For example to change memory:
    vb.customize ["modifyvm", :id, "--memory", "4096", "--cpus", "2"]
  end

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
#	config.vm.provider "virtualbox" do |vb|
#		unless File.exist?(disk)
#			vb.customize ['createhd', '--filename', disk, '--variant', 'Fixed', '--size', 10 * 1024]
#		end
#		vb.memory = "1024"
#		vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', disk]
#	end
end





























ERROR: error while removing network 解决

ERROR: error while removing network: network cloudservices_default id 757495ac40c7aa62c6797f5fdb852bd80b91d0bb4ebb1bbc46

ded66be03cd3c6 has active endpoints

This is a stale endpoint case. Do you happen to have the error log when that container that was originally removed (which left the endpoint in this state).

BTW, if the container is removed, but the endpoint is still seen, then one can force disconnect the endpoint using docker network disconnect -f {network} {endpoint-name} . You can get the endpoint-name from the docker network inspect {network} command.

github里提问的回答原话

From <https://github.com/moby/moby/issues/17217>

网上的说法是此bug不常见,但是竟然被我碰到了,这个endpoint本来应该已经不存在了,但是不知道什么原因还存在着,二相关的容器已经被移除了。

这时需要用

docker network disconnect -f <container id>  <endpoint name>

来移除相关的endpoint。

Container id:报错是显示的一长串id就是了

Endpoint name: 就是用down命令shut不掉的那些容器的name

此命令需要执行多次,知道所有endpoint被移除为止。

然后只能用docker rm -f 命令来shut 容器, docker-compose down还是无法移除。

github oauth第三方登陆

官方文档地址

https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/#web-application-flow

通过token能操作的api列表

Git token 联合登陆(SSO)又两种方式:

– Web-base application

– Nonweb-base application (这种方式是受限的)

Nonweb-base的限制:

  • 只支持https模式,不支持ssh模式

说明:

Once you have a token, you can enter it instead of your password when performing Git operations over HTTPS.

For example, on the command line you would enter the following:

$ git clone https://github.com/username/repo.git
Username: your_username
Password: your_token

Personal access tokens can only be used for HTTPS Git operations. If your repository uses an SSH remote URL, you will need to switch the remote from SSH to HTTPS.

If you are not prompted for your username and password, your credentials may be cached on your computer. You can update your credentials in the Keychain to replace your old password with the token.

应用: 官方文档

在python里遍历文件夹

Python 里遍历文件夹的一个简单的用法,在这里记录一下而已。

Method of iter folder in python codes, record here

import os
import re


for root, _dir, _fiels in os.walk('c:\\data\\handback\\data'):
    result = re.search(r'.*[/\\](\d*)[/\\](\w{2}-\w{2})', root)
    if result:
        number = result.group(1)
        language_name = result.group(2)
        print('workbench %s language %s files %s' % (workbench_id, language_name, _fiels,))

刘备为啥掉粉了?

一天午饭后散步闲聊,同事突然问我,三国中你喜欢刘备还是曹操呢?我一时不知如何回答。同事很快自己回答说他喜欢曹操并且十分讨厌刘备。

这件事情过后我总是在想,我小时候无论是电视里的形象还是戏曲里的形象一向是宽厚仁义的,老百姓听戏或听先生说书无不是以蜀汉为自己的立场来听的。

我还记得小时候看央视版三国演义,前半段多数是看的热血沸腾,而到了关羽义释曹操时,剧中的关公骑在马上远望曹操,面容不再坚毅,眼神也没有了杀气,铜盔的护耳被风吹的飘忽起来,就觉得到了英雄迟暮的时候了。

再到败走麦城时,被五花大绑,须发都沾着雪花,眼神迷茫的回头看向西蜀的方向,那个时候心痛到忍不住流泪。

后来刘备为了报仇举兵伐吴却被火烧连营,白帝城托孤的时候,真的就是一个老人到了油尽灯枯的时候,即为了自己奋斗了一生的的事业无法达成的绝望,也有为了后人能顺利坐上自己的位置而担忧,尤其是临死时传给子孙的警句:勿以善小而不为,勿以恶小而为之。所谓人之将死其言也善,大概也算不上什么恶人吧。

不记得在什么地方看到过这样一种分析,说历史上其实也有过与曹魏为正统而鄙视刘备的西蜀政权的时代,并且是西晋、隋唐、北宋这样的大一统的强大王朝,大概这样的时代老百姓不至于流离失所,因此对于仁君并没有太大感觉吧。而已刘备的蜀汉为正统的时代有哪些呢?

首先东晋,然后是五代十国,最后是南宋、元、明清都以蜀汉为正统了。这样的局面可以这样去臆想一下,这些时代都是动荡的乱世,正是百姓思的明君的时候,刘备当然被作为一个皇帝的楷模而受到百姓的喜爱了。

后来的明清虽然不是都是乱世,但是大概是受到元朝戏曲小说的影响太深,也就没有转变过来吧。

这样说来,现在,尤其是近二十年来,刘备的粉丝越来越少,而曹操的人气水涨船高,难道不是现在中国百姓的生活安逸的一个佐证吗?