Linux命令行编辑按键

在使用shell时,可以使用左右箭头来编辑命令行,并且通过上下箭头来查看之前的命令。这是Linux系统的标准操作。
但使用ctrl键来代替箭头键会更加方便。

  • CTRL-B, 左移光标
  • CTRL-F, 右移光标
  • CTRL-P, 查看上一条命令(或上移光标)
  • CTRL-N, 查看下一条命令(或下移光标)
  • CTRL-A, 移动光标至行首
  • CTRL-E, 移动光标至行尾
  • CTRL-W, 删除前一个词
  • CTRL-U, 删除从光标至行首的内容
  • CTRL-K, 删除从光标至行尾的内容
  • CTRL-Y, 粘贴已删除的文本

Nginx配置反向代理404

今天用Nginx配置到Node.js和Hexo的反向代理,发现除了 / 可以访问,其他都404,我很纳闷啊。
搜遍各种资料都无用。
后来发现是我配置文件里多了一句
try_files uriuri/ =404;
蛋疼,浪费我一晚上。终于可以睡了。

JavaScript回锅笔记

  1. Variables created without the keyword var, are always global, even if they are created inside a function.
  2. A closure is a function having access to the parent scope, even after the parent function has closed.
  3. A JavaScript function can be invoked without being called.
  4. Accessing a function without () will return the function definition:.

    <script>
    function toCelsius(f) {
        return (5/9) * (f-32);
    }
    document.getElementById("demo").innerHTML = toCelsius;
    </script>

    输出:
    function toCelsius(f) { return (5/9) * (f-32); }

  5. Avoid String, Number, and Boolean objects. They complicate your code and slow down execution speed.
  6. If you assign a value to a variable that has not been declared, it will automatically become a GLOBAL variable, even if it is executed inside a function. Do NOT create global variables unless you intend to.
  7. In HTML, the global scope is the window object: All global variables belong to the window object.
  8. Your global variables (or functions) can overwrite window variables (or functions).
    Any function, including the window object, can overwrite your global variables and functions.
  9. W3Schools JavaScript Reference HTML DOM Events
  10. You can also break up a code line within a text string with a single backslash:

    document.getElementById("demo").innerHTML = "Hello \
    Dolly!";

    (The \ method is not a ECMAScript (JavaScript) standard.Some browsers do not allow spaces behind the \ character.)

  11. Integers (numbers without a period or exponent notation) are considered accurate up to 15 digits. The maximum number of decimals is 17, but floating point arithmetic is not always 100% accurate:
  12. In JavaScript, all data types have a valueOf() and a toString() method.
  13. JavaScript counts months from 0 to 11. January is 0. December is 11.
  14. Bit operators work on 32-bit numbers.
  15. The constructor property returns the constructor function for all JavaScript variables.
  16. The unary + operator can be used to convert a variable to a number:
  17. 5 + null // returns 5 because null is converted to 0
    "5" + null // returns "5null" because null is converted to "null"
    "5" + 2 // returns 52 because 2 is converted to "2"
    "5" - 2 // returns 3 because "5" is converted to 5
    "5" * "2" // returns 10 because "5" and "2" are converted to 5 and 2
  18. Complete JavaScript RegExp Reference
  19. Hoisting is JavaScript’s default behavior of moving all declarations to the top of the current scope (to the top of the current script or the current function).
  20. Do not use tabs (tabulators) for indentation. Different editors interpret tabs differently.
  21. Avoid global variables, avoid new, avoid ==, avoid eval()

JavaScript里的奇葩语法

排名不分先后。

  1. "1234"+5的结果是"12345", 而"1234"-4的结果却是1230. 4+"1234"的结果是"41234", 而4-"1234"的结果是NaN.
  2. true==2的结果是false, false==2的结果也是false.
  3. typeof null的结果是"object".
  4. 对于str.slice(start, end),如果参数大于等于0,则结果不包括end指示的字符;如果参数小于0,则结果不包括start指示的字符.
  5. var x = 0.2 + 0.1; // x will be 0.30000000000000004
  6. typeof NaN; // returns "number"
    var x = NaN + "5"; var y = Infinity + "3"; // x will be "NaN5", and y will be "Infinity3"
  7. 0 < Number.MIN_VALUE // true
  8. var txt = "";
    var person = ["23", "12f", 2];
    var x;
    for (x in person) {
    txt += typeof x + " ";
    }

    最成txt为string string string

UEFI启动模式修复ubuntu引导

今天在移动硬盘上安装ubuntu,却把引导装错了,导致本机ubuntu引导不了。
开始尝试用grub-install修复却发现无法成功。

使用
$ sudo fdisk -l
发现一个奇怪的分区(其实以前也发现,但没注意),Name是EFI system partition.
挂载之,发现有个文件夹叫BOOT,遂感觉有问题。
又在EFI目录下发现有个文件夹ubuntu,其中有个文件grub.cfg,内容大概是这样的:

search.fs_uuid b6fcadd1-32ba-4448-acb0-7e66595ee3a1 root hd1,gpt2 
set prefix=(root)'/boot/grub'
configfileprefix/grub.cfg

至此,我发现端倪了,hd1,gpt2应该是定位到移动硬盘的系统去了,本机的系统应该是hd0,gpt8(依具体情况而定),我把前面的uuid改了、后面改成hd0,gpt8后。
重启系统。真棒,我的ubuntu回来了。

后记: 后来在网上查EFI,然后引出了UEFI什么的,具体我还没看,故标题可能有误。

Ubuntu 16.04 无线模块不能加载

升级ubuntu 16.04 LTS后,无线突然不能用了。
运行

$ sudo lshw -C network

后发现无线网卡是unclaim(ed)
我以为是驱动问题,寻求各大偏方,安了无数次驱动,均不能解。
后发现在insmod的时候,总出现

insmod: ERROR: could not insert module wl.ko: Required key not available-

于网搜之,高人指点,

这样的话,问题就很可能出在bios里面的secure boot了。你到bios里面去找到一个secure boot的东西,把它disable掉。

至此,遂解,wl模块能正确加载了,无线也可以用了。

但我还是不知道怎么回事,知道的麻烦告诉我一声。

何以知时间流逝

就是看见弟弟已升入高中,
上课打牌,翘课,上网。
在我印象里他还是个小孩子。
看着聊天记录里的,
“呵呵”,
表情,
追剧,
我才醒悟,他高一了,
就像三年前的我。
由是知,
时间流逝。

丙申年正月初十
于绵阳中学