Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem) Dim oAttachment As Outlook.Attachment Dim sSaveFolder As String sSaveFolder = "Z:\gzb\" For Each oAttachment In MItem.Attachments oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName Next End Sub
1、選項-信任中心-信任中心設置-電子郵件安全性,勾選下方的兩個運行腳本的checkbox
2、選項-信任中心-信任中心設置-宏設置,需要選擇啟動所有宏,默認是第二項
3.新創建規則的時候沒有選項“運行腳本”
開始->regedit
HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Security
修改 EnableUnsafeClientMailRules值
如果沒有,就手動創建一個
右邊空白處,右鍵新建一個DWORD值,取名為EnableUnsafeClientMailRules,值設置為1
重啟outlook
]]>java.lang.RuntimeException: Error grabbing Grapes -- [download failed: log4j#log4j;1.2.17!log4j.jar(bundle)]
刪掉grapes目錄重新下載
Caught: java.lang.NoClassDefFoundError: Unable to load class org.xxxx due to missing dependency Lorg/slf4j/Logger;
classpath 中沒有加載上log4j,不識別~換成絕對目錄
]]>curl -s get.sdkman.io | bash source "$HOME/.sdkman/bin/sdkman-init.sh" sdk install groovy groovy -version]]>
idea運行groovy包這個錯,其實忽略不影響使用,強迫癥可以通過如下方式解決:
Help -> Edit Custom Properties... -> 首次需要create配置文件
增加idea.no.launcher=true到配置文件中。
# custom IntelliJ IDEA properties idea.no.launcher=true
增加完配置后重啟idea即可。
]]>pip install ta-lib
直接安裝會報錯
talib/_ta_lib.c:526:10: fatal error: 'ta-lib/ta_defs.h' file not found #include "ta-lib/ta_defs.h" ^ 1 error generated. error: command 'clang' failed with exit status 1 ----------------------------------------
原因是需要先安裝TA-Lib擴展庫,然后再執行pip命令。
Mac OS X
$ brew install ta-lib
Windows
下載ta-lib-0.4.0-msvc.zip 然后解壓到 C:\ta-lib
https://sourceforge.net/projects/ta-lib/files/ta-lib/0.4.0/ta-lib-0.4.0-msvc.zip/download?use_mirror=jaist
windows下報錯 Unable to find vcvarsall.bat
訪問 https://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib 下載對應版本的包直接安裝,cp后面是版本號。
pip install TA_Lib?0.4.17?cp35?cp35m?win_amd64.whl
]]>開啟https首先需要有域名證書,大多都是要收費的,個人站在使用let‘s encrypt的免費證書就可以。
本站的證書效果:
生成辦法:
第一步 下載域名證書工具
wget https://dl.eff.org/certbot-auto --no-check-certificate chmod +x ./certbot-auto ./certbot-auto -n
第二步 生成證書,只需修改郵箱 網站根目錄 域名就可以了。
執行生成證書命令前需要在nginx支持網站所有權驗證
2.1 增加隱藏目錄訪問
location ~ /.well-known { allow all; }
2.2 生成域名證書
./certbot-auto certonly --email tougao@nginx.cn --agree-tos --no-eff-email --webroot -w /home/www/nginx/ -d www.4693749.com
第三步 修改nginx 配置支持https方式訪問
上一步生成的證書
/etc/letsencrypt/live/www.4693749.com/fullchain.pem
/etc/letsencrypt/live/www.4693749.com/privkey.pem
server { server_name nginx.cn; return 301 $scheme://www.4693749.com$request_uri; } server { server_name www.4693749.com; root /home/www/nginx/; return 301 http://www.4693749.com$request_uri; error_log logs/nginx.error.log; index index.php; location /doc { index index.html; } location / { # This is cool because no php is touched for static content. # include the "?$args" part so non-default permalinks doesn't # break when using query string try_files $uri $uri/ /index.php?$args; } location ~* \.(log)$ { log_not_found off; } include location.conf; include agent_deny.conf; access_log /home/logs/nginx/default.log access; error_page 404 /404.html; } server { listen 443 ssl; server_name www.4693749.com; root /home/www/nginx/; ssl_certificate /etc/letsencrypt/live/www.4693749.com/fullchain.pem; #前面生成的證書,改一下里面的域名就行 ssl_certificate_key /etc/letsencrypt/live/www.4693749.com/privkey.pem; #前面生成的密鑰,改一下里面的域名就行 ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5"; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; error_log logs/nginx.error.log; index index.php; location /doc { index index.html; } location / { # This is cool because no php is touched for static content. # include the "?$args" part so non-default permalinks doesn't # break when using query string try_files $uri $uri/ /index.php?$args; } location ~* \.(log)$ { log_not_found off; } include location.conf; include agent_deny.conf; access_log /home/logs/nginx/default.log access; error_page 404 /404.html; }
第四步 定時更新證書
crontab 中增加定時任務,每15天更新一次證書
Let's Encrypt證書是有效期90天的,需要我們自己手工更新續期才可以
0 3 */15 * * /root/certbot-auto renew --disable-hook-validation --renew-hook "/etc/init.d/nginx reload"]]>
社區版可以使用mcafee開發的審計功能插件libaudit_plugin.so,這個插件可以用在mysql 5.1以后的版本,使用時請下載對應的版本。
https://bintray.com/mcafee/mysql-audit-plugin/release#files
解壓拷貝libaudit_plugin.so到mysql的插件目錄:
查看MySQL的插件目錄:
> show variables like 'plugin_dir'; +---------------+------------------------------+ | Variable_name | Value | +---------------+------------------------------+ | plugin_dir | /usr/local/mysql/lib/plugin/ | +---------------+------------------------------+
復制庫文件到MySQL庫目錄下:
# cp audit-plugin-mysql-5.7-1.1.4-725/lib/libaudit_plugin.so /usr/local/mysql/lib/plugin/
# chmod a+x libaudit_plugin.so
進入mysql命令窗口,安裝插件:
> install plugin audit soname 'libaudit_plugin.so';
Query OK, 0 rows affected (0.06 sec)
查看mysql當前已經加載了哪些插件:
> show plugins; +----------------------------+----------+--------------------+--------------------+---------+ | Name | Status | Type | Library | License | +----------------------------+----------+--------------------+--------------------+---------+ | binlog | ACTIVE | STORAGE ENGINE | NULL | GPL | | mysql_native_password | ACTIVE | AUTHENTICATION | NULL | GPL | | sha256_password | ACTIVE | AUTHENTICATION | NULL | GPL | | MyISAM | ACTIVE | STORAGE ENGINE | NULL | GPL | | PERFORMANCE_SCHEMA | ACTIVE | STORAGE ENGINE | NULL | GPL | | InnoDB | ACTIVE | STORAGE ENGINE | NULL | GPL | | INNODB_TRX | ACTIVE | INFORMATION SCHEMA | NULL | GPL | | INNODB_LOCKS | ACTIVE | INFORMATION SCHEMA | NULL | GPL | ………… | MRG_MYISAM | ACTIVE | STORAGE ENGINE | NULL | GPL | | MEMORY | ACTIVE | STORAGE ENGINE | NULL | GPL | | CSV | ACTIVE | STORAGE ENGINE | NULL | GPL | | BLACKHOLE | ACTIVE | STORAGE ENGINE | NULL | GPL | | partition | ACTIVE | STORAGE ENGINE | NULL | GPL | | FEDERATED | DISABLED | STORAGE ENGINE | NULL | GPL | | ARCHIVE | ACTIVE | STORAGE ENGINE | NULL | GPL | | ngram | ACTIVE | FTPARSER | NULL | GPL | | rpl_semi_sync_master | ACTIVE | REPLICATION | semisync_master.so | GPL | | rpl_semi_sync_slave | ACTIVE | REPLICATION | semisync_slave.so | GPL | | AUDIT | ACTIVE | AUDIT | libaudit_plugin.so | GPL | +----------------------------+----------+--------------------+--------------------+---------+
查看版本:
> show global status like '%audit%'; +------------------------+-----------+ | Variable_name | Value | +------------------------+-----------+ | Audit_protocol_version | 1.0 | | Audit_version | 1.1.4-725 | +------------------------+-----------+
開啟Audit功能:
> SET GLOBAL audit_json_file=ON;
Query OK, 0 rows affected (0.00 sec)
執行任何語句(默認會記錄任何語句,有語法錯誤的不會記錄),然后去mysql數據目錄查看mysql-audit.json文件(默認為該文件)。
插入一些數據,查看一下mysql-audit.json文件信息(json格式),如下:
復制代碼
{ "msg-type": "activity", "date": "1510038432019", "thread-id": "43", "query-id": "1891", "user": "root", "priv_user": "root", "ip": "", "host": "localhost", "connect_attrs": { "_os": "linux-glibc2.5", "_client_name": "libmysql", "_pid": "4009", "_client_version": "5.7.9", "_platform": "x86_64", "program_name": "mysql" }, "pid": "4009", "os_user": "root", "appname": "mysql", "rows": "1", "cmd": "insert", "objects": [ { "db": "part", "name": "e", "obj_type": "TABLE" } ], "query": "insert into e values (9898,'smart','james')" }
可以查看插件有哪些可配置的參數:
mysql> SHOW GLOBAL VARIABLES LIKE '%audi%';
其中我們需要關注的參數有:
1. audit_json_file
是否開啟audit功能(0為關閉)。
2. audit_json_log_file
記錄文件的路徑和名稱信息(默認放在mysql數據目錄下.json文件)。
3. audit_record_cmds
audit記錄的命令,默認為記錄所有命令。可以設置為任意dml、dcl、ddl的組合。如:audit_record_cmds=select,insert,delete,update。還可以在線設置set global audit_record_cmds=NULL。(表示記錄所有命令)
4. audit_record_objs
audit記錄操作的對象,默認為記錄所有對象( 審計哪些數據庫),可以用SET GLOBAL audit_record_objs=NULL設置為默認。也可以指定為下面的格式:audit_record_objs=,test.*,mysql.*,information_schema.*。
5. audit_whitelist_users
用戶白名單。
詳細的參數說明,可以直接訪問官方說明:
https://github.com/mcafee/mysql-audit/wiki/Configuration
最后為了保證重啟數據庫,配置不丟失,修改my.cnf 配置文件,將下面的配置添加到[mysqld]中,所以在配置文件中my.cnf加入參數:
audit_json_file=on #保證mysql重啟后自動啟動插件
plugin-load=AUDIT=libaudit_plugin.so #防止刪除了插件,重啟后又會加載
audit_record_cmds='insert,delete,update,create,drop,alter,grant,truncate' #要記錄哪些命令語句,因為默認記錄所有操作;
保存重啟即可看到效果。
mysql審計插件卸載
直接執行 UNINSTALL PLUGIN AUDIT 卸載會報錯:
> uninstall plugin AUDIT; ERROR 1148 (42000): Uninstall AUDIT plugin disabled > set audit_uninstall_plugin=on; ERROR 1238 (HY000): Variable 'audit_uninstall_plugin' is a read only variable
需要在 my.cnf 中 [mysqld] 下添加 audit_uninstall_plugin=1,重啟mysql。重啟完畢后執行兩次 UNINSTALL PLUGIN AUDIT; 即可卸載。
> UNINSTALL PLUGIN AUDIT; ERROR 1620 (HY000): Uninstall AUDIT plugin must be called again to complete > UNINSTALL PLUGIN AUDIT; Query OK, 0 rows affected, 1 warning (0.01 sec)
卸載完成后需要從 my.cnf 中刪除 audit_uninstall_plugin=1 ,否則下次mysql啟動會報錯:[ERROR] /data/mysql/bin/mysqld: unknown variable 'audit_uninstall_plugin=1'
]]>$ curl -v https://www.264.cn/shengqi/ --user-agent "Mozilla/5.0" --silent
* timeout on name lookup is not supported
* Trying 47.52.250.55...
* TCP_NODELAY set
* Connected to www.264.cn (47.52.250.55) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
CApath: none
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
} [5 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* Unknown SSL protocol error in connection to www.264.cn:443
* Curl_http_done: called premature == 1
* stopped the pause stream!
* Closing connection 0
pip install pypiwin32
python解決ModuleNotFoundError: No module named 'win32api'
安裝完pypiwin32報找不到win32api,需要重啟動解釋器
]]>Nginx 是世界上最受歡迎的web服務器,許多大流量的主機都采用Nginx作為服務器。在大多數場景下作為web服務器的Nginx比Apache更加節省資源,它也可當作反向代理服務器。
本文主要介紹如何在ubuntu16.04上安裝Nginx
開始以前,你需要有一個安裝好的ubuntu16.04,并且你需要有一個擁有sudo權限的非root普通用戶。
Ubuntu默認的源中就有Nginx,所以安裝是比較簡單的。
首先,更新apt源,以便軟件是最新的,然后就可以安裝nginx:
執行這兩個命令之后,apt-get就會安裝好Nginx和它依賴的軟件。
開始測試Nginx前,我們需要配置防火墻,以便允許外界訪問nginx服務。Nginx在安裝的時候使用ufw注冊自己作為一個服務,這樣對nginx的訪問就會變得很容易。
顯示所有ufw應用的配置:
sudo ufw app list
你可以得到一個配置的輸出列表:
Available applications: Nginx Full Nginx HTTP Nginx HTTPS OpenSSH
我們可以看到,有三個Nginx的配置:
一般來說我們應該配置最嚴的限制,因為本文我們還沒有配置SSL,所以我們只打開80端口。
我們執行:
sudo ufw allow 'Nginx HTTP'
驗證修改狀態:
sudo ufw status
我們可以看到HTTP是被打開的:
Status: active To Action From -- ------ ---- OpenSSH ALLOW Anywhere Nginx HTTP ALLOW Anywhere OpenSSH (v6) ALLOW Anywhere (v6) Nginx HTTP (v6) ALLOW Anywhere (v6)
安裝完成后,Ubuntu 16.04 會自動啟動 Nginx. 我們可以使用systemd
?檢查運行狀態:
systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: <span class="highlight">active (running)</span> since Mon 2016-04-18 16:14:00 EDT; 4min 2s ago Main PID: 12857 (nginx) CGroup: /system.slice/nginx.service ├─12857 nginx: master process /usr/sbin/nginx -g daemon on; master_process on └─12858 nginx: worker process
服務已經正常啟動,當然最好的確認方法是通過訪問web頁面的方式。
如果我們能訪問到默認加載頁就證明啟動成功了。
如果你不知道服務器的ip可以使用如下命令:
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
有了IP之后,在瀏覽器里輸入:
http://server_domain_or_IP
你就能看到Nginx的默認加載頁了:
現在我們已經有nginx在運行了,我們可以再試一些管理命令:
停止nginx:
sudo systemctl stop nginx
啟動nginx:
sudo systemctl start nginx
重啟nginx:
sudo systemctl restart nginx
修改配置文件后,平滑加載配置命令(不會斷開用戶訪問):
sudo systemctl reload nginx
默認,nginx是隨著系統啟動的時候自動運行。如果你不想開機啟動,那么你可以禁止nginx開機啟動:
sudo systemctl disable nginx
重新配置nginx開機自動啟動:
sudo systemctl enable nginx
現在我們已經管理nginx了,接下來可以熟悉一下nginx的目錄結構和一些重要的文件:
/var/www/html
: 網站文件存放的地方, 默認只有我們上面看到nginx頁面,可以通過改變nginx配置文件的方式來修改這個位置。/etc/nginx
: nginx配置文件目錄。所有的nginx配置文件都在這里。/etc/nginx/nginx.conf
: Nginx的主配置文件. 可以修改他來改變nginx的全局配置。/etc/nginx/sites-available/
: 這個目錄存儲每一個網站的"server blocks"。nginx通常不會使用這些配置,除非它們陪連接到 ?sites-enabled
?目錄 (see below)。一般所有的server block 配置都在這個目錄中設置,然后軟連接到別的目錄 。/etc/nginx/sites-enabled/
: 這個目錄存儲生效的 "server blocks" 配置. 通常,這個配置都是鏈接到 sites-available目錄中的配置文件
/etc/nginx/snippets
: 這個目錄主要可以包含在其它nginx配置文件中的配置片段。重復的配置都可以重構為配置片段。/var/log/nginx/access.log
: 每一個訪問請求都會記錄在這個文件中,除非你做了其它設置。/var/log/nginx/error.log
: 任何Nginx的錯誤信息都會記錄到這個文件中。