作者归档:xinlu

JAVASCRIP全局错误捕获

Audit JavaScript execution errors by logging the errors.

window.addEventListener('error', function(e) {
    var errorText = [
        e.message,
        'URL: ' + e.filename,
        'Line: ' + e.lineno + ', Column: ' + e.colno,
        'Stack: ' + (e.error && e.error.stack || '(no stack trace)')
    ].join('\n');

    // Example: log errors as visual output into the host page.
    // Note: you probably don’t want to show such errors to users, or
    //       have the errors get indexed by Googlebot; however, it may
    //       be a useful feature while actively debugging the page.
    var DOM_ID = 'rendering-debug-pre';
    if (!document.getElementById(DOM_ID)) {
        var log = document.createElement('pre');
        log.id = DOM_ID;
        log.style.whiteSpace = 'pre-wrap';
        log.textContent = errorText;
        if (!document.body) document.body = document.createElement('body');
        document.body.insertBefore(log, document.body.firstChild);
    } else {
        document.getElementById(DOM_ID).textContent += '\n\n' + errorText;
    }

    // Example: log the error to remote service.
    // Note: you can log errors to a remote service, to understand
    //       and monitor the types of errors encountered by regular users,
    //       Googlebot, and other crawlers.
    var client = new XMLHttpRequest();
    client.open('POST', 'https://example.com/logError');
    client.setRequestHeader('Content-Type', 'text/plain;charset=UTF-8');
    client.send(errorText);
});

ruby-rails的自启动脚本

必须设置HOME的环境变量,否则会报错【后续有测试发现不设置HOME变量时,也是可以正常运行的,但为了安全起见,还是设置吧】。
如下:

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

正确的写法如下:

*/3 * * * * HOME=/home/waypal && source $HOME/.bash_profile && rvm use 'ruby 2.4.1@default'  --create && eval `rvm env` && $HOME/waypalers.cn/waypal/current/run-waypal.sh start

ubuntu16.04配置vsftp

root@iZ2zecha351f36ej19ygkyZ:~# mkdir /home/uftp
root@iZ2zecha351f36ej19ygkyZ:~# useradd -d /home/uftp -s /bin/bash uftp
root@iZ2zecha351f36ej19ygkyZ:~# passwd uftp
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
root@iZ2zecha351f36ej19ygkyZ:~# chown uftp:uftp /home/uftp
root@iZ2zecha351f36ej19ygkyZ:~# echo uftp > /etc/vsftpd.user_list
root@iZ2zecha351f36ej19ygkyZ:~# cat  /etc/vsftpd.user_list
uftp
root@iZ2zecha351f36ej19ygkyZ:~# vi /etc/vsftpd.conf
在vsftpd.conf的尾部添加如下配置:
chroot_local_user=YES
allow_writeable_chroot=YES
write_enable=YES
userlist_file=/etc/vsftpd.user_list
userlist_enable=YES
userlist_deny=NO
------------------------------------------
root@iZ2zecha351f36ej19ygkyZ:~# systemctl restart vsftpd



如果报错”:服务器发回了不可路由的地址。使用服务器地址代替”,需要修改FTP的被动模式为主动模式。

俞敏洪老师的13条领导力的原则

①愿景原则:清楚使命、明确愿景、坚定信念、激励成员
②目标原则:战略制定、分解步骤、目标衔接、战术跟上
③团队原则:价值一致、能力多样、跨代结合、充分授权
④回避原则:杜绝私事、严防宠幸、任人唯贤、远离家族
⑤齐心原则:统一思想、避免派系、内部齐心、外部树信
⑥商道原则:确定大势、弄清形势、厚积薄发、稳步多元
⑦痛点原则:洞察需求、破解痛点、不拘形式、直达关键
⑧专注原则:垂直深挖、集中兵力、甩开对手、形成壁垒
⑨变革原则:组织变革、模式变革、思维变革、科技变革
⑩底线原则:底线共识、坚持原则、不存侥幸、心安理得
⑪德行原则:问心无愧、知行合一、独善其身、兼济天下
⑫成长原则:读书有用、行成长路、交良师友、做谦虚人
⑬退身原则:奠定文化、布局人才、功成身退、海阔天高

按文件创建日期进行同步

#!/bin/bash

time_now=`ssh -l root 172.17.101.163 "date +%s"`
rooms=`ssh -l root 172.17.101.163 "ls /home/waypal/volume/kms/kms-media"`
for room in $rooms
do
   read -t 5 -p "continue ? [y/n default y]" answer
   answer=${answer:-y}
   echo "you choise:$answer"
   if [ $answer != y ];then
      exit;
   fi

   echo "/home/waypal/volume/kms/kms-media/$room"
   time_lastchanged=`ssh -l root 172.17.101.163 "stat -c %Y /home/waypal/volume/kms/kms-media/$room"`
   time_ago=$[ $time_now - $time_lastchanged ]
   if [ $time_ago -gt 3600 ];then
       #echo "$time_now,$time_lastchanged,$time_ago"
       rsync -av --progress -e ssh root@172.17.101.163:/home/waypal/volume/kms/kms-media/$room  $HOME/waypalers.cn/waypal/shared/resources/records && ssh root@172.17.101.163 "rm -r /home/waypal/volume/kms/kms-media/$room";
   fi
done