PhantomJS 在 Windows 下实现网站自动截图

1. phantomjs 介绍

基于 Javascript 驱动的命令行webkit引擎,轻量级,安装简单,开发快速,渲染速度较快,无界面的 webkit 浏览器。 phontomjs 跟一般浏览器一样可以加载网页,但不同的是它不会把网页显示出来,在加载网页后它会提供一系列的 Javascript API 给程式人员使用,包括 DOM 元件的控制﹑CSS 的选择器﹑JSON﹑HTML5 的 Canvas 和 SVG 。
Continue reading PhantomJS 在 Windows 下实现网站自动截图

Git “Could not read from remote repository.Please make sure you have the correct access rights.”解决方案

我们在使用 git push 或 clone 或其他命令的时候,有时候会遇到这类问题,如图:

fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

出现这个问题是因为没有在 github 账号添加 SSH key Continue reading Git “Could not read from remote repository.Please make sure you have the correct access rights.”解决方案

What is Going On

超感猎杀 Sense8 S01E04 43'11'00' What's Up Continue reading What is Going On

不使用 PHP 内置函数 使用方法写一个字符串反转的函数

<?php
function str_rev($str){
    for($i = 0;true;$i++){
        if(!isset($str[$i])){
            break;
        }
    }
    $return = "";
    for($j=$i-1;$j>=0;$j--){
        $return .= $str[$j];
    }
    return $return;
}
echo str_rev('abcdefg');

输出:

gfedcba

重点:字符串可以当数组来使用。

字符串中的字符可以通过一个以0为开始的,用类似数组结构中的方括号包含对应的数字来查找和修改,比如 $str[42], 可以把 字符串想像数组 。

跳出循环,使用 isset() 来判断。

不使用 array_merge() 实现多个数组的合并

<?php
function array_mer(){
    $return = [];
    $array = func_get_args();
    foreach($array as $arr){
        if(is_array($arr)){
            foreach($arr as $val){
                $return[] = $val;
            }
        }
    }
    return $return;
}
var_dump(array_mer([1],[1,2],[3,5]));

输出:

array(5) {
  [0]=>
  int(1)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(5)
}

重点:func_get_args() 动态获取参数的函数

Atom: 配置编辑器运行 Python

学习 Python,如果你喜欢用 IDE ,可以试一下 Pycharm,社区版可以免费使用。或者也可以直接用个简单的文本编辑软件,比如 Atom。安装个 script 包,就可以直接在编辑器里运行 Python 代码了。

安装 Python

在系统上先安装一下 Python,用系统包管理工具可以很方法安装 Python,Windows 用 Chocolatey,macOS 用 Homebrew。

macOS 用户:

macOS 系统自带 Python 2,我们可以再用 Homebrew 安装一个 Python 3 。

brew install python3

完成以后可以使用 python3 这个命令行工具。

Windows 用户:

choco install python
Continue reading Atom: 配置编辑器运行 Python