02 2012 档案

javascript的函数定义的区别
摘要:javascript中函数定义通常有两种方法: 1. 普通的函数定义:function f1 (){} 2. 变量式函数定义:var f2 = function(){} 还有一种定义方法是new Function,由于这种方法并不常用,这里就不做解释了。 那这两种定义方法有什么不同呢?难道仅仅只是样子不同而已嘛?当然不是这样,我们来看个具体的例子吧,大家觉得以下代码的执行结果是什么?if (1 === 1) { tellAlert();} else{ function tellAlert(){ alert('hello'); }} 执行结果是:会提示“hello”... 阅读全文

posted @ 2012-02-29 20:02 lengyuhong 阅读(1983) 评论(7) 推荐(1)

mongodb部署
摘要:一、简单启动举例:./mongod --dbpath /var/lib/mongodb/ --port 12345这中方法相对比较简单,这里不做具体的阐述,查看下面的文档即可http://www.mongodb.org/display/DOCS/Starting+and+Stopping+Mongo二、master-slave 1. 运行脚本脚本:$ cd ~/apps$ wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-1.8.3.tgz$ tar zxvf mongodb-linux-x86_64-1.8.3.tgz$ m. 阅读全文

posted @ 2012-02-21 18:05 lengyuhong 阅读(2274) 评论(0) 推荐(0)

Nodejs读写文件
摘要:nodejs对文件的读写还是相当灵活的,可以根据不同的场景来选择不同的方法,具体可以参见:Nodejs fs 一.直接操作文件 最简单的两个fs.readFile和fs.writeFile 举例:这个程序的功能是将一个比较大json格式的文件转换成你想自己要格式的文件。var fs = require('fs');fs.readFile('./json.json',function(err,data){ if(err) throw err; var jsonObj = JSON.parse(data); var space = ' '; var 阅读全文

posted @ 2012-02-18 20:50 lengyuhong 阅读(17612) 评论(6) 推荐(5)

从V8引擎编程理解javascript执行环境
摘要:一、V8简介 google code上对它的解释如下: V8 is Google's open source JavaScript engine. V8 is written in C++ and is used in Google Chrome, the open source browser from Google. V8 implements ECMAScript as specified inECMA-262, 5th edition, and runs on Windows (XP or newer), Mac OS X (10.5 or newer), and Linu.. 阅读全文

posted @ 2012-02-17 00:06 lengyuhong 阅读(4545) 评论(1) 推荐(2)

学习笔记 《鸟哥的私房菜——软件安装:源码和Tarball》
摘要:文章原文:http://linux-vbird.bluedata.org/linux_base/0520source_code_and_tarball.htm#library_dyna_sta重点学习内容:一、 源码的编译: 特别注意-l 和-L两个参数,在使用到外部函数库时是非常重要的。[guest@test guest]# gcc sin.c -lm -L/lib -L/usr/lib # 特别注意,那个 -lm 可以拆开成两部份来看, # -l 是『加入某个函式库(library)』的意思,而m 则是 libm.so 这个函式库,其中, lib 与附档名(.a 或 .so)不需要写 #. 阅读全文

posted @ 2012-02-09 23:22 lengyuhong 阅读(597) 评论(0) 推荐(0)

HTTP中的URL长度限制
摘要:由于之前的一个web项目中,要用get方法去获取数据,但结果时常报错,经过仔细排查才发现原来url长度超过了限制,通过缩短url和发送多次请求的方法解决了该问题,之后在网上查了些资料,发现这个问题还是内藏玄机,要比自己想的复杂。 首先,其实http 1.1 协议中对url的长度是不受限制的,协议原文: The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource theyserve,... 阅读全文

posted @ 2012-02-04 21:45 lengyuhong 阅读(39189) 评论(0) 推荐(4)