作者归档:ning

一命二运三风水的现代解读

一命二运三风水,四积功德五读书,六名七相八敬神,九交贵人十养生。

这些可以用当代的解读办法,命运其实和后面的都相关,不能单独抛开了讲,单独认命运就是偷懒耍滑的理解,可以说命运是果,而其他是因,认识命运不仅要认识果,还要认识因。

我的解读如下:

一命:生来就有的的部分,比如你的出身无法改变,但是你可以改变你儿子女儿的出生,我相信“人活着的意义就是可以改变”;

二运:运气是量变到质变的过程,比如说究竟“会笑的人运气都不差”,还是“运气差的人都笑不出来”了呢?我相信“机会都给有准备的人”;

三风水:即环境,孟母三迁为了是学习的环境,买学区房是为了教育,买好点房子是为了自己家人心情舒畅身心通透。往大了看,风水还是地利,要寻找合适自己发展的土壤,贫瘠的土地是很难长出参天大树的,需要我们“人挪活”。

四积功德:即向善,没有人喜欢和恶人打交道,得道多助。毛说“政治工作就是将自己人搞得多多的,敌人搞得少少的”。国外说“人们追随你,是因为爱戴你”。众人拾柴火焰高,你利他越多,就越顺,越好运,“你是别人的贵人,别人也是你的贵人”,运自然改了。

五读书:学习是大多数人最快的也可能是唯一的实现生活改善、阶层跃迁,实现命运改变的办法。一个人我们说他能够看到老了,是因为他已经停止学习和进步了。

六名: 名即名字、名气、名声,现代可以解读为品牌。二十一实际什么最贵?是人才没错。怎么看一个人是不是人才呢?就是这个人的品牌。人的品牌怎么来?是靠平时积累来,品牌的特点是积累难,损害容易,钟南山非典因为敢发声,所以有品牌,但是可能会因为儿子的一条皮带而受到损害。“品牌只是所以有价值,就在于难”。个人平时的品牌就在于你对待他人,对待问题的处理方式,最终在其他人心中的印象。

七相:相貌,可以解读为注重包装,同名一样,“酒好也怕巷子深”。好的包装不仅可以让自己舒服,也可让别人愉悦,何乐而不为呢?

八敬神:可以解读为心存敬畏之心。对人敬畏,尊重任何人;对事敬畏,实事求是不做纸上谈兵之事;对天地敬畏,不做对社会有害之事。“心存敬畏者才能为人所敬畏”。

九交贵人:可以理解为远离小人,多交愿意学习,注重品德的人,你自然也成为爱学习品德高尚的人。与小人交往,不仅浪费时间,而且暗里里会降低了自己的期望和目标。

十养生:即注重健康。不仅健康是一切之本,且罗马不是一天建成的,少些急功近利,多些长期可持续。养生切莫道听途说,科学养生才叫养生,杜绝不良习惯—“要养生不要养蛊”。

多平台实时同步方案比较(cp,scp,rsync,DRBD,lsyncd,Syncthing,seafile,Nextcloud)

cp命令实现增量同步

可用于linux/mac,可以增量,不能跨机器。

使用-u参数实现增量,-r递归,使用实例

cp -ru dir1/* dir2/

详细参数

用法:cp [选项]... [-T] 源文件 目标文件
 或:cp [选项]... 源文件... 目录
 或:cp [选项]... -t 目录 源文件...
将源文件复制至目标文件,或将多个源文件复制至目标目录。

长选项必须使用的参数对于短选项时也是必需使用的。
  -a, --archive                 等于-dR --preserve=all
      --backup[=CONTROL         为每个已存在的目标文件创建备份
  -b                            类似--backup 但不接受参数
      --copy-contents           在递归处理是复制特殊文件内容
  -d                            等于--no-dereference --preserve=links
  -f, --force                   如果目标文件无法打开则将其移除并重试(当 -n 选项
                                        存在时则不需再选此项)
  -i, --interactive             覆盖前询问(使前面的 -n 选项失效)
  -H                            跟随源文件中的命令行符号链接
  -l, --link                    链接文件而不复制
  -L, --dereference             总是跟随符号链接
  -n, --no-clobber              不要覆盖已存在的文件(使前面的 -i 选项失效)
  -P, --no-dereference          不跟随源文件中的符号链接
  -p                            等于--preserve=模式,所有权,时间戳
      --preserve[=属性列表      保持指定的属性(默认:模式,所有权,时间戳),如果
                                        可能保持附加属性:环境、链接、xattr 等
  -c                           same as --preserve=context
      --sno-preserve=属性列表   不保留指定的文件属性
      --parents                 复制前在目标目录创建来源文件路径中的所有目录
  -R, -r, --recursive           递归复制目录及其子目录内的所有内容
      --reflink[=WHEN]          控制克隆/CoW 副本。请查看下面的内如。
      --remove-destination      尝试打开目标文件前先删除已存在的目的地
                                        文件 (相对于 --force 选项)
      --sparse=WHEN             控制创建稀疏文件的方式
      --strip-trailing-slashes  删除参数中所有源文件/目录末端的斜杠
  -s, --symbolic-link           只创建符号链接而不复制文件
  -S, --suffix=后缀             自行指定备份文件的后缀
  -t,  --target-directory=目录  将所有参数指定的源文件/目录
                                           复制至目标目录
  -T, --no-target-directory     将目标目录视作普通文件
  -u, --update                 copy only when the SOURCE file is newer
                                 than the destination file or when the
                                 destination file is missing
  -v, --verbose                explain what is being done
  -x, --one-file-system        stay on this file system
  -Z, --context=CONTEXT        set security context of copy to CONTEXT
      --help            显示此帮助信息并退出
      --version         显示版本信息并退出

scp命令实现跨机器增量同步

可用于linux/mac系统,可以增量,可以跨机器,跨机器通过ssh。

使用实例

scp user@host1:/dir/* /home/www/

详细参数

usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
           [-l limit] [-o ssh_option] [-P port] [-S program]
           [[user@]host1:]file1 ... [[user@]host2:]file2

-B  使用批处理模式(传输过程中不询问传输口令或短语) 
-C  允许压缩。(将-C标志传递给ssh,从而打开压缩功能) 
-p  保留原文件的修改时间,访问时间和访问权限。 
-q  不显示传输进度条。 
-r  递归复制整个目录。 
-v 详细方式显示输出。scp和ssh(1)会显示出整个过程的调试信息。这些信息用于调试连接,验证和配置问题。  
-c cipher  以cipher将数据传输进行加密,这个选项将直接传递给ssh。  
-F ssh_config  指定一个替代的ssh配置文件,此参数直接传递给ssh。 
-i identity_file  从指定文件中读取传输时使用的密钥文件,此参数直接传递给ssh。   
-l limit  限定用户所能使用的带宽,以Kbit/s为单位。    
-o ssh_option  如果习惯于使用ssh_config(5)中的参数传递方式,  
-P port  注意是大写的P, port是指定数据传输用到的端口号  
-S program  指定加密传输时所使用的程序。此程序必须能够理解ssh(1)的选项。

rsync 命令实现跨机器增量同步

可用于linux/mac系统,可以增量,可以跨机器,跨机器通过ssh。相对于scp推荐。可以显示进度、排除软链等。

用例

rsync -e "ssh -p22222" -avpgolr --progress  host:/dir/file /dir/file

详细参数


Usage: rsync [OPTION]... SRC [SRC]... DEST
  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST
  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST
  or   rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST
  or   rsync [OPTION]... [USER@]HOST:SRC [DEST]
  or   rsync [OPTION]... [USER@]HOST::SRC [DEST]
  or   rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect
to an rsync daemon, and require SRC or DEST to start with a module name.

Options
 -v, --verbose               increase verbosity
 -q, --quiet                 suppress non-error messages
     --no-motd               suppress daemon-mode MOTD (see manpage caveat)
 -c, --checksum              skip based on checksum, not mod-time & size
 -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
     --no-OPTION             turn off an implied OPTION (e.g. --no-D)
 -r, --recursive             recurse into directories
 -R, --relative              use relative path names
     --no-implied-dirs       don't send implied dirs with --relative
 -b, --backup                make backups (see --suffix & --backup-dir)
     --backup-dir=DIR        make backups into hierarchy based in DIR
     --suffix=SUFFIX         set backup suffix (default ~ w/o --backup-dir)
 -u, --update                skip files that are newer on the receiver
     --inplace               update destination files in-place (SEE MAN PAGE)
     --append                append data onto shorter files
     --append-verify         like --append, but with old data in file checksum
 -d, --dirs                  transfer directories without recursing
 -l, --links                 copy symlinks as symlinks
 -L, --copy-links            transform symlink into referent file/dir
     --copy-unsafe-links     only "unsafe" symlinks are transformed
     --safe-links            ignore symlinks that point outside the source tree
 -k, --copy-dirlinks         transform symlink to a dir into referent dir
 -K, --keep-dirlinks         treat symlinked dir on receiver as dir
 -H, --hard-links            preserve hard links
 -p, --perms                 preserve permissions
 -E, --executability         preserve the file's executability
     --chmod=CHMOD           affect file and/or directory permissions
 -A, --acls                  preserve ACLs (implies --perms)
 -X, --xattrs                preserve extended attributes
 -o, --owner                 preserve owner (super-user only)
 -g, --group                 preserve group
     --devices               preserve device files (super-user only)
     --copy-devices          copy device contents as regular file
     --specials              preserve special files
 -D                          same as --devices --specials
 -t, --times                 preserve modification times
 -O, --omit-dir-times        omit directories from --times
     --super                 receiver attempts super-user activities
     --fake-super            store/recover privileged attrs using xattrs
 -S, --sparse                handle sparse files efficiently
 -n, --dry-run               perform a trial run with no changes made
 -W, --whole-file            copy files whole (without delta-xfer algorithm)
 -x, --one-file-system       don't cross filesystem boundaries
 -B, --block-size=SIZE       force a fixed checksum block-size
 -e, --rsh=COMMAND           specify the remote shell to use
     --rsync-path=PROGRAM    specify the rsync to run on the remote machine
     --existing              skip creating new files on receiver
     --ignore-existing       skip updating files that already exist on receiver
     --remove-source-files   sender removes synchronized files (non-dirs)
     --del                   an alias for --delete-during
     --delete                delete extraneous files from destination dirs
     --delete-before         receiver deletes before transfer, not during
     --delete-during         receiver deletes during transfer (default)
     --delete-delay          find deletions during, delete after
     --delete-after          receiver deletes after transfer, not during
     --delete-excluded       also delete excluded files from destination dirs
     --ignore-errors         delete even if there are I/O errors
     --force                 force deletion of directories even if not empty
     --max-delete=NUM        don't delete more than NUM files
     --max-size=SIZE         don't transfer any file larger than SIZE
     --min-size=SIZE         don't transfer any file smaller than SIZE
     --partial               keep partially transferred files
     --partial-dir=DIR       put a partially transferred file into DIR
     --delay-updates         put all updated files into place at transfer's end
 -m, --prune-empty-dirs      prune empty directory chains from the file-list
     --numeric-ids           don't map uid/gid values by user/group name
     --timeout=SECONDS       set I/O timeout in seconds
     --contimeout=SECONDS    set daemon connection timeout in seconds
 -I, --ignore-times          don't skip files that match in size and mod-time
     --size-only             skip files that match in size
     --modify-window=NUM     compare mod-times with reduced accuracy
 -T, --temp-dir=DIR          create temporary files in directory DIR
 -y, --fuzzy                 find similar file for basis if no dest file
     --compare-dest=DIR      also compare destination files relative to DIR
     --copy-dest=DIR         ... and include copies of unchanged files
     --link-dest=DIR         hardlink to files in DIR when unchanged
 -z, --compress              compress file data during the transfer
     --compress-level=NUM    explicitly set compression level
     --skip-compress=LIST    skip compressing files with a suffix in LIST
 -C, --cvs-exclude           auto-ignore files the same way CVS does
 -f, --filter=RULE           add a file-filtering RULE
 -F                          same as --filter='dir-merge /.rsync-filter'
                             repeated: --filter='- .rsync-filter'
     --exclude=PATTERN       exclude files matching PATTERN
     --exclude-from=FILE     read exclude patterns from FILE
     --include=PATTERN       don't exclude files matching PATTERN
     --include-from=FILE     read include patterns from FILE
     --files-from=FILE       read list of source-file names from FILE
 -0, --from0                 all *-from/filter files are delimited by 0s
 -s, --protect-args          no space-splitting; only wildcard special-chars
     --address=ADDRESS       bind address for outgoing socket to daemon
     --port=PORT             specify double-colon alternate port number
     --sockopts=OPTIONS      specify custom TCP options
     --blocking-io           use blocking I/O for the remote shell
     --stats                 give some file-transfer stats
 -8, --8-bit-output          leave high-bit chars unescaped in output
 -h, --human-readable        output numbers in a human-readable format
     --progress              show progress during transfer
 -P                          same as --partial --progress
 -i, --itemize-changes       output a change-summary for all updates
     --out-format=FORMAT     output updates using the specified FORMAT
     --log-file=FILE         log what we're doing to the specified FILE
     --log-file-format=FMT   log updates using the specified FMT
     --password-file=FILE    read daemon-access password from FILE
     --list-only             list the files instead of copying them
     --bwlimit=KBPS          limit I/O bandwidth; KBytes per second
     --write-batch=FILE      write a batched update to FILE
     --only-write-batch=FILE like --write-batch but w/o updating destination
     --read-batch=FILE       read a batched update from FILE
     --protocol=NUM          force an older protocol version to be used
     --iconv=CONVERT_SPEC    request charset conversion of filenames
 -4, --ipv4                  prefer IPv4
 -6, --ipv6                  prefer IPv6
     --version               print version number
(-h) --help                  show this help (-h works with no other options)

DRBD 高性能网络磁盘同步

DRBD是linux的内核的存储层中的一个分布式存储系统,可用使用DRBD在两台Linux服务器之间共享块设备,共享文件系统和数据。
用于linux/mac,类似于一个网络RAID-1的功能,高性能。

rsync+inotify 实时增量同步

1、先安装好inotify包

  wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz  

tar zxf inotify-tools-3.14.tar.gz
cd inotify-tools-3.14

 ./configure --prefix=/usr/local/inotify-3.14

make && make install

2、创建监控脚本inotify.sh

#!/bin/bash
#para
host01=192.168.0.144  #rsync服务器地址
src=/backup        #本地监控的目录
dst=backup         #rsync服务器的模块名称
user=nowview      #rsync服务器的虚拟用户
rsync_passfile=/etc/rsyncd.password   #本地调用rsync服务的密码文件
inotify_home=/usr/local/inotify-3.14    #inotify的安装目录
#judge
if [ ! -e "$src" ] \
|| [ ! -e "${rsync_passfile}" ] \
|| [ ! -e "${inotify_home}/bin/inotifywait" ] \
|| [ ! -e "/usr/bin/rsync" ];
then
echo "Check File and Folder"
exit 9
fi
${inotify_home}/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' -e close_write,delete,create,attrib $src \
| while read file
do
#  rsync -avzP --delete --timeout=100 --password-file=${rsync_passfile} $src $user@$host01::$dst >/dev/null 2>&1
cd $src && rsync -aruz -R --delete ./  --timeout=100 $user@$host01::$dst --password-file=${rsync_passfile} >/dev/null 2>&1
done
exit 0

lsyncd 多机器实时同步文件神器

lsyncd 是一个支持实时、双向、多机器的多模式文件同步工具。

使用 Lua 语言封装了 inotify 和 rsync 工具,采用了 Linux 内核(2.6.13 及以后)里的 inotify 触发机制,然后通过 rsync 去差异同步,达到实时的效果。

Syncthing

支持Windows/linux/mac/android,采用go语言开发,提供多个平台的客户端。没有iOS客户端。

seafile

同样采用go开发,Seafile 是一款开源的企业云盘,注重可靠性和性能。支持 Windows, Mac, Linux, iOS, Android 平台。支持文件同步或者直接挂载到本地访问。

Nextcloud/ownCloud

采用PHP基于ownCloud开发,支持 Windows, Mac, Linux, iOS, Android 平台。

参考

论坛和社区如何防止垃圾文章和评论

在V2上看到被 spam 评论给弄疯了,如何有效的建立机器学习模型呢?,想起以前做论坛和信息发布平台的一些经历,也曾头痛过,总结自己以及网友的经验如下。

通过关键词库识别spam内容

如何建立关键词库

  • 人工方法收集词库;
  • 导入网上词库;
  • 收集历史内容,然后通过分词方式抽取词;
  • 使用网络上的开源spam机器学习方案;

如何运用关键词库

  • 匹配前利用正则表达式去空白
  • 使用正则表达式对整段内容运用关键词库进行多次匹配
  • 分词然后匹配词,因为分词通常不够精准,所以除非特殊情况不建议,效率上分词加词组匹配的时间不一定会比正则快

通过联系方式特征识别spam内容

如何识别联系方式

  • 数字联系方式:如④,肆等
  • 网址:.com等
  • 手机号、电话号等
  • 邮箱
  • 通讯软件:微信,咸鱼等

如何运用联系方式反spam

  • 正则表达式

通过用户身份识别spam内容

如何识别用户身份

  • 手机号认证
  • 邮箱认证
  • 微信,微博等第三方认证
  • ip地址识别
  • ip归属地识别
  • 手机归属地识别
  • 身份认证:身份证、人脸识别

如何运用身份识别反spam

  • 建立手机号,邮箱,IP,归属地黑名单
  • 注册、登录验证码
  • 答题识别
  • 邀请注册
  • 付费注册

通过操作特征识别spam内容

操作特征识别

  • 发布频率
  • 注册时间

如何运用操作特征识别反spam

  • 注册后一定时间内不允许发帖
  • 发帖消耗积分

识别后的处理

  • 过滤信息,进入待审核
  • 禁言用户(可设置时间)
  • 屏蔽账号(ip,手机号,邮箱等)
  • 屏蔽归属地(可以过一个月再打开)
  • 屏蔽所有用户发布信息(含用户名)

开源方案

商业方案

C++学习资料

电子书

纸质书

如何通过阅读源代码学习?

有选择的阅读

跟着大师学习,让你更接近大师,学习不好的代码,有可能被带进沟里,如何发现值得阅读的代码呢?

  • github star超过10K的
  • 开发参与人数超过5人的
  • 文档完善的(如有多语言版本、区分普通用户和开发者文档等)
  • 用户多的(issue规模可以看出,对应npm,composer,pypi的downloads等)
  • 发展时间等超过半年

阅读步骤

掌握正确的阅读步骤,能够让你少走弯路,起到磨刀不误砍柴工的作用。正确的方法应该是带着问题学习。

  • 运行软件:软件解决了什么问题?
  • 看用户说明书:软件有什么特点?
  • 看开发者文档:软件整体架构是怎样的?
  • 看代码组织结构:当前组织方式的优缺点?
  • 看代码的数据库结构:数据是如何存储的?
  • 针对特定问题解决办法深入学习:我的方式是什么?作者的方式是什么?有没有更好的解决办法?

学习的要点

  • 学习解决问题的思路和方法:思路就是思考的路径,了解他人的思路,我们就有可能能变得和他人一样聪明。思路是方向,方向对了事半功倍,方向错了事倍功半。比如“空间换时间”,“并行”等。
  • 学习编程的技巧:比如类、方法、变量命名,语言特性,设计模式等。
  • 学习软件架构的方法:即代码目录结构,数据存放,数据库设计,数据流,使用的第三方库等。
  • 学习软件的商业逻辑:如软件的界面,交互,用户体验,营销方法等。

Windows自动化打印Office文件(Word,PDF,Excel,PPT等)

Windows(C++)

WPF(.net C#)

Win10磁盘清理

临时文件

依此选择“c盘”》属性》磁盘清理

修改系统分页文件存储位置

我的电脑,右键,“高级系统设置”》“高级”》“性能”》“高级”》“虚拟内存”》修改C盘为无分页文件;

关闭休眠文件内存占用

开始菜单输入cmd,选择管理员身份运行"命令提示符",在命令提示符运行 powercfg -h off;

删除旧版windows备份文件

如果windows升级上来的,Windows.old备份文件也是可以删除的

Matplotlib使用中文字体(linux)

查看系统已有中文字体

fc-list :lang=zh

查询matplotlib默认配置示例

import matplotlib
matplotlib.matplotlib_fname()

查看当前系统matplotlib配置文件路径

import matplotlib
matplotlib.get_configdir()

全局修改

在系统如今下新增matplotlibrc文件,然后修改font.sans-serif,添加中文字体

font.sans-serif : WenQuanYi Micro Hei, Bitstream Vera Sans, ...

只修改当前程序

import matplotlib
matplotlib.rcParams['font.sans-serif'] = 'WenQuanYi Micro Hei'

参考

开源CRM/ERP比较

名称 语言 协议 提供外部API 项目地址
悟空 PHP/JAVA 商业 否(但是管理后台采用rest) https://gitee.com/wukongcrm/72crm
PSI PHP GPLv3 插件化ERP https://gitee.com/crm8000/PSI
SugarCRM PHP GPLv3 开源版本已不更新 https://sourceforge.net/projects/sugarcrm/
SuiteCRM PHP GPLv3 基于SugarCRM,目前仍在更新 https://github.com/salesagility/SuiteCRM
VtigerCRM PHP GPLv3 基于SugarCRM,开源版本已不更新
Odoo Python GPLv3 插件化ERP https://github.com/odoo/odoo
OFBiz Java Apache 未知 https://ofbiz.apache.org/

最后得出,
CRM完全免费用SuiteCRM,悟空收费中文支持好。
小型ERP选择Odoo,大公司ERP选择OFBiz。

《任正非传》读后感

如果本书能取一个副标题的话,可以是《论毛泽东思想在企业管理中的运用》

实时求是

  • 知错善改:华为多次危机都能避免,在于能够很快找到问题所在和解决办法
  • 破格提拔:不以年龄,经验,经历为界限(李一男等)
  • 没有调查就没有发言权:赴美考察,让听到炮声的人做决定
  • 知己知彼百战不殆:思科之争利用美国律师对付美国律师

与时俱进

  • 格局:中华有为
  • 技术上:世界先进
  • 管理上:国际化
  • 组织架构:多次变革
  • 华为基本法
  • 薪酬体系
  • 轮值上岗

群众路线

  • 敌人的敌人就是朋友:善于抓住阶段主要矛盾,团结一切可以团结的力量,如团结四大抵抗国外和邮电
  • 善用舆论:如思科之争,面对美国制裁