This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <sys/types.h> | |
#include <sys/time.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <arpa/inet.h> | |
#include <string> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 坑一、js的基本类型有那些? | |
number string boolean object null undefined | |
typeof null //===>"object" | |
//这只能说是最初的JavaScript实现的bug,而现在标准就是这样规范的. | |
//V8曾经修正并实现过typeof null=== "null",但最终证明不可行.http://wiki.ecmascript.org/doku.php?id=harmony:typeof_null | |
// 坑二、NaN isNaN | |
isNaN('a') //===>true | |
isNaN('09') //===>false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var auto_increase = function(){ | |
var id=0; | |
return function(){return ++id;} | |
}(); | |
// 1 | |
auto_increase(); | |
// 2 | |
auto_increase(); | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 创建/打开 只允许一个进程进行P操作的信号量,并等待它 | |
static bool s_wait_sem() | |
{ | |
const key_t SEM_KEY = 0xA001FFFF; | |
int semid = semget(SEM_KEY, 1, IPC_CREAT|IPC_EXCL|0666); | |
if (semid >= 0) | |
{ | |
// 计算机重启后,首次启动进程 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* FPOperation: 浮点数操作 | |
* 优点:自动计算原数据精确位数 | |
* @param {Number} x | |
* @param {Number} y | |
* @param {String} operator | |
**/ | |
function FPOperation(x, y , operator) { | |
if (!operator) { | |
return ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 密码强度等级验证 | |
*/ | |
function valid_strong_password (password) { | |
if (password.length < 6 || parseInt(password) == password || /^[a-zA-Z]+$/.test(password) || /^[^a-zA-Z0-9]+$/.test(password)) { | |
return 0; | |
} | |
if (/^.{6,7}$/.test(password) || !/[0-9]/.exec(password) || !/[a-z]/.exec(password) || !/[A-Z]/.exec(password)) { | |
return 1; |
NewerOlder