新老用户都可能遇到陷阱。下面我们列出频繁出现的问题,以及如何解决。 在 Freenode IRC #nginx 频道,我们经常看到这些问题。
[TOC]
最常见的是有人试图从其他指南拷贝配置片段。并非所有的指南是错误的,但绝大部分是有问题的。
| #include <stdio.h> | |
| #include <string.h> | |
| #include <securec.h> | |
| #define HELLOWORLD "helloworld" | |
| #define HELLOWORLD1 "helloworld1" | |
| int main() | |
| { | |
| char name[sizeof(HELLOWORLD)] = HELLOWORLD; | |
| char name1[sizeof(HELLOWORLD1)] = HELLOWORLD1; | 
新老用户都可能遇到陷阱。下面我们列出频繁出现的问题,以及如何解决。 在 Freenode IRC #nginx 频道,我们经常看到这些问题。
[TOC]
最常见的是有人试图从其他指南拷贝配置片段。并非所有的指南是错误的,但绝大部分是有问题的。
Testing of Xen vPMU filter options.
Three tests are executed on a simple program (noploop, which runs NOP in a loop). The first two show Linux "perf stat" summaries, and the third tests specific counters: the IPC ones, an architectural one, and a few extras. Which of these will work depends on the filter mode.
I'll begin by showing off and on, the current modes, and then the new modes: ipc and arch.
root@lgud-bgregg:~> xl dmesg | grep vpmu
| package main | |
| import ( | |
| "errors" | |
| "log" | |
| "runtime" | |
| "sync/atomic" | |
| "time" | |
| ) | 
| /* | |
| * This program is free software: you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation, either version 3 of the License, or | |
| * (at your option) any later version. | |
| */ | |
| #include <arpa/inet.h> | |
| #include <linux/if_packet.h> | |
| #include <stdio.h> | 
| <!-- Get NumLock on keypad to work on osx for G80-3494, Realforce and so on --> | |
| <!-- By https://groups.google.com/d/msg/osx-karabiner/-2ns5XVXXdQ/kDGIKVSztjwJ --> | |
| <item> | |
| <name>Map NumLock to OSX NumLock function</name> | |
| <identifier>private.pc_numlock_to_mac_numlock</identifier> | |
| <autogen>__KeyToKey__ KeyCode::KEYPAD_CLEAR, KeyCode::VK_IOHIKEYBOARD_TOGGLE_NUMLOCK</autogen> | |
| </item> | 
| #!/usr/bin/expect -f | |
| set timeout 10; # set timeout to -1 to wait forever | |
| set hda "obj/kern/kernel.img" | |
| # spawn qemu -nographic -hda $hda -serial "file:jos.out" -monitor null -no-reboot | |
| spawn qemu -nographic -hda $hda -monitor null -no-reboot | |
| # interact | |
| expect { | 
On naming and cache
There are only two hard things in Computer Science: cache invalidation and naming things.
-- Phil Karlton
On reusing code
There are two "rules of three" in [software] reuse:
a. It is three times as difficult to build reusable components as single use components, and
b. a reusable component should be tried out in three different applications before it will be sufficiently general to accept into a reuse library.
| # `sudo' is needed on Debian | |
| lsof -n -i4TCP:7777 | 
| perl -e '@r = ("A".."Z", 0..9); foreach (1..shift) { print join "", @r[ map { rand @r } 1..16 ], "\n" }' -- 8 | |
| # perl -e 'print join "", ("A".."Z")[ map { rand @("A".."Z") } 1..shift ], "\n"' -- 16 |