分类: 软件

  • 威联通配置开机启动项

    添加启动项目

    挂载特殊分区

    mkdir /tmp/config
    mount $(/sbin/hal\_app --get\_boot\_pd port\_id=0)6 /tmp/config
    

    新增启动脚本

    vi /tmp/config/autorun.sh
    

    加入开机时需要执行的命令,比如启动ZeroTier加入网络的配置

    cd /share/CACHEDEV1_DATA/.qpkg/ZeroTier/ && zerotier-cli join xxx 
    

    增加可执行权限

    chmod +x /tmp/config/autorun.sh
    

    取消挂载

    umount /tmp/config
    

    打开自启动开关

    自启动开关位于:控制台 -> 系统 -> 硬件 -> 一般设置 -> 勾选 启动时运行用户定义的进程

    参考资料

    https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup

  • Windows客户端frp设置开机自启动

    新建文件frps.vbs,编辑

    Set ws = CreateObject("Wscript.Shell") ws.run "cmd /c d:\frp\frpc.exe -c d:\frp\frpc.ini",vbhide
    

    将 frps.vbs 文件放到启动目录

  • PhpStorm配置Xdebug调试

    xdebug 安装

    打开 https://xdebug.org/wizard.php 复制phpinfo的信息到文本框,会返回安装指导:

    Tailored Installation Instructions
    
    Summary
    
    Xdebug installed: no
    Server API: FPM/FastCGI
    Windows: no
    Zend Server: no
    PHP Version: 5.6.9
    Zend API nr: 220131226
    PHP API nr: 20131226
    Debug Build: no
    Thread Safe Build: no
    Configuration File Path: /usr/local/php/etc
    Configuration File: /usr/local/php/etc/php.ini
    Extensions directory: /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226
    Instructions
    
    Download xdebug-2.5.1.tgz
    Unpack the downloaded file with tar -xvzf xdebug-2.5.1.tgz
    Run: cd xdebug-2.5.1
    Run: phpize (See the FAQ if you don't have phpize.
    
    As part of its output it should show:
    
    Configuring for:
    ...
    Zend Module Api No:      20131226
    Zend Extension Api No:   220131226
    If it does not, you are using the wrong phpize. Please follow this FAQ entry and skip the next step.
    
    Run: ./configure
    Run: make
    Run: cp modules/xdebug.so /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226
    Edit /usr/local/php/etc/php.ini and add the line
    zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
    Restart the webserver
    If you like Xdebug, and thinks it saves you time and money, please have a look at the donation page.
    

    xdebug 配置

    编辑php.ini文件,加入

    [Xdebug]  
    ;指定Xdebug扩展文件的绝对路径  
    zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
    ;允许远程IDE调试
    xdebug.remote_enable        = true
    ;通知 PHP 开启调试的标识
    xdebug.idekey = PHPSTORM
    ;远程主机
    xdebug.remote_host          = 192.168.xxx.xxx
    ;xdebug.remote_port         = 9000 ;默认端口 9000
    

    配置参数选项附录

    配置参数选项 参数值类型与默认值    参数选项描述
    xdebug.auto_trace   boolean类型,默认值=0 是否在脚本运行之前自动调用相关追踪函数。
    xdebug.cli_color    integer类型,默认值=0 该参数自2.2版本开始引入。如果值=1,当处于CLI模式或连接虚拟控制台时,Xdebug将高亮显示var_dumps()和堆栈输出,;在Windows中,这需要安装ANSICON工具。如果值=2,不管是否处于CLI模式或连接虚拟控制台,Xdebug都会高亮显示var_dumps()或堆栈输出;这种情况下,你可能会看到转义后的代码。
    xdebug.collect_assignments  boolean类型,默认值=0 该参数自2.1版本开始引入。用于控制是否为函数跟踪添加变量赋值功能。
    xdebug.collect_includes boolean类型,默认值=1 控制是否在跟踪文件中写入include()、include_once()、require()、require_once()等函数中用到的文件名。
    xdebug.collect_params   integer类型,默认值=0 
    控制在调用函数时,是否收集传递给函数的参数信息。如果参数值过大,这可能会占用大量的内存;不过,在Xdebug 2中不会出现该问题,因为Xdebug 2将相关数据写入磁盘中,而不是占用内存。
    
    如果值=0,则不显示任何信息。
    如果值=1,只显示类型和大小信息,例如:string(6)、array(8)。
    如果值=2,将显示类型和大小,以及全部信息的工具提示。
    如果值=3,将显示变量的全部内容。
    如果值=4,将显示变量的全部内容和变量名。
    
    xdebug.collect_return   boolean类型,默认值=0 控制是否在追踪文件中写入函数调用的返回值。
    xdebug.collect_vars boolean类型,默认值=0 控制是否收集指定作用域中的变量信息。由于需要反向工程PHP的操作码数组,因此Xdebug的分析速度可能比较慢。
    xdebug.coverage_enable  boolean类型,默认值=1 该参数自2.2版本开始引入。控制是否允许通过设置内部结构来启用代码覆盖率功能。
    xdebug.default_enable   boolean类型,默认值=1 当发生异常或错误时,是否默认显示堆栈信息。
    xdebug.dump.*   string类型,默认值=Empty  这里的*可以是COOKIE, FILES, GET, POST, REQUEST, SERVER, SESSION中的任意一个。用于指定发生错误时是否显示超全局变量数组中的索引变量信息。比如,你想要显示请求的IP地址和请求方式,可以设置为
    xdebug.dump.SERVER=REMOTE_ADD,REQUEST_METHOD
    多个索引变量用英文逗号隔开,如果要输出其中的所有变量,可以直接用*,例如:
    xdebug.dump.GET=*
    xdebug.dump_globals boolean类型,默认值=1 控制是否显示通过xdebug.dump.*定义的所有超全局变量的信息。
    xdebug.dump_once    boolean类型,默认值=1 如果出现多个错误,控制超全局变量信息是在所有错误中显示,还是只在第一个错误中显示。
    xdebug.dump_undefined   boolean类型,默认值=1 控制是否显示超全局变量中未定义的值。
    xdebug.extended_info    integer类型,默认值=1 是否强制进入PHP解析器的"extended_info"模式,这将允许Xdebug以远程调试器对文件或行添加断点。开启此模式将拖慢脚本的允许速度,该参数只能在php.ini中设置。
    xdebug.file_link_format string类型,默认值=,  自2.2版本开始引入。用于指定堆栈信息中用到的文件名称的链接样式,这允许IDE通过设置链接协议,直接点击堆栈信息中的文件名称,即可快速打开指定的文件。例如:ZendStudio://%f@%l(%f表示文件路径,%f表示行号)。
    xdebug.force_display_errors integer类型,默认值=0 自2.3版本开始引入。是否强制显示错误信息。
    xdebug.force_error_reporting    integer类型,默认值=0 自2.3版本开始引入。是否强制显示所有错误级别的信息。
    xdebug.halt_level   integer类型,默认值=0 自2.3版本开始引入。指定出现那些错误级别的错误时,中止程序运行。例如:xdebug.halt_level=E_WARNING|E_NOTICE|E_USER_WARNING|E_USER_NOTICE(也仅支持上述4种错误级别)。
    xdebug.idekey   string类型,默认值=*complex*  指定传递给DBGp调试器处理程序的IDE Key。
    xdebug.manual_url   string类型,默认值=http://www.php.net 仅2.2.1以下版本可用,用于指定从函数堆栈和错误信息链接到的帮助手册的基本URL。
    xdebug.max_nesting_level    integer类型,默认值=100   指定递归的嵌套层级数。
    xdebug.overload_var_dump    boolean类型,默认值=1 自2.2版本开始引入,当php.ini中的html_error设为1时,Xdebug是否默认使用自身的改进版本来重载var_dump()。
    xdebug.profiler_append  integer类型,默认值=0 当多个请求映射到相同文件时,指定是覆盖之前的调试信息文件还是追加内容到该文件中。
    xdebug.profiler_enable  integer类型,默认值=0 指定是否启用Xdebug的性能分析,并创建性能信息文件。
    xdebug.profiler_output_dir  string类型,默认值=/tmp   指定性能分析信息文件的输出目录
    xdebug.profiler_output_name string类型,默认值=cachegrind.out.%p  指定性能分析信息文件的名称
    xdebug.remote_enable    boolean类型,默认值=0 是否开启远程调试
    xdebug.remote_handler   string类型,默认值=dbgp   指定远程调试的处理协议
    xdebug.remote_host  string类型,默认值=localhost  指定远程调试的主机名
    xdebug.remote_log   string类型,默认值=   指定远程调试的日志文件名
    xdebug.remote_mode  string类型,默认值=req    可以设为req或jit,req表示脚本一开始运行就连接远程客户端,jit表示脚本出错时才连接远程客户端。
    xdebug.remote_port  integer类型,默认值=9000  指定远程调试的端口号
    xdebug.trace_options    integer类型,默认值=0 指定对于之后的请求,追踪文件是追加内容还是覆盖之前内容。
    xdebug.trace_output_dir string类型,默认值=/tmp   指定追踪文件的存放目录
    xdebug.trace_output_name    string类型,默认值=trace.%c   指定追踪文件的名称
    

    PhpStorm 配置

    先配置一个 server(一定要配置目录映射),打开
    菜单栏->File->Settings->Languages & Frameworks->PHP->Server
    开启一下 9000 端口 的监听,打开
    菜单栏->Run->Start Listing for PHP Debug Connections

    调试

    chrome 可以安装一个插件xdebug helper,需要调试的页面打开debug,会设置一个cookie来自动加调试标识。
    在代码中打断点,访问浏览器,phpstorm 就会跳出一个调试栏,显示调试信息。

  • Vagrant使用NFS共享文件夹

    windows下默认虚拟机共享文件夹的方式因为磁盘IO效率太低,打开网站都需要好几秒,可以让windows支持NFS方式共享文件夹给vagrant虚拟机来解决问题

    安装vagrant插件

    1. $vagrant plugin install vagrant-winnfsd

    (更多…)

  • Virtualbox虚拟机Linux Guest的Additions安装方法

    如果是windows做Guest,直接单击菜单栏 “Insert Guest Additions CD Image… ” 就可以将 Additions CD 自动加载到Guest里的虚拟光驱里,但是Linux是不行的,因为Linux需要root权限才可以mount CD Image。

    做法是在Guest里打开终端,输入:
    sudo mount /dev/sr0  /media/cdrom
    把sr0挂载到 /media/cdrom 里,如果没有cdrom,可以先mkdir一个,挂载到其他位置也可以。

    然后查看一下
    [web@doco6-lamp ~ ]$ ls /mnt/cdrom
    32Bit        autorun.sh  runasroot.sh              VBoxWindowsAdditions-amd64.exe
    64Bit        cert        VBoxLinuxAdditions.run    VBoxWindowsAdditions.exe

    AUTORUN.INF  OS2         VBoxSolarisAdditions.pkg  VBoxWindowsAdditions-x86.exe

    里面有 VBoxLinuxAdditions.run 这一项,直接运行即可。

    sudo sh ./VBoxLinuxAdditions.run

    尝试 sh ./VBoxLinuxAdditions.run 报错:

      Installing the Window System drivers …fail!
      (Could not find the X.org or XFree86 Window System.)

    搜到以下命令:
    sudo apt-get install xserver-xorg xserver-xorg-core

    以上是重装过程,全部解决。

    安装后,reboot一下就可以了。

  • SVN命令忽略文件/文件夹的方法

    1. svn propedit svn:ignore dir

    注意:dir为忽略路径(可以cd到某个目录,用.表示当前目录),因为不能循环执行,所以子目录也要重设,如果报错请看下面

    2. 打开的文件就是忽略列表文件了(默认是空的),每一行是一项,在该文件中输入忽略的文件,保存退出

    如果在svn propedit svn:ignore .时报错:svn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR are set, and no ‘editor-cmd’ run-time configuration option was found

    (更多…)

  • Sublime Text

    下载安装

    插件

    可通过此插件来安装安装其他插件

    安装方法:快捷键ctrl+` 或者 View > Show Console 菜单打开控制器

    sublime text 3 复制以下安装

    import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
    

    sublime text 2 复制以下安装

    import urllib2,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else None; print('Error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh != h else 'Please restart Sublime Text to finish installation')
    

    安装完成之后,我们摁下“shift + ctrl + p”呼出面板,输入cp选命令执行即可
    (更多…)

  • 用sublime text2新建文件快速生成HTML头部信息

    sublime text 安装插件 Emmet 就有了快速生成文件头的功能,而且更强大
    输入下边加粗的缩写,然后Tab,就OK了 (更多…)

  • Notepad++TextFX插件的一些常用命令

    1. 为代码增加行号
    选择要增加行号的文本(选择时会提示“No text selected”)
    点击TextFX —> TextFX Tools —> Insert Line Numbers

    2. 删除程序行号或者首字
    选择相应的文本
    点击TextFX —> TextFX Tools —> Delete Line Numbers or First word

    (更多…)