NodeJS request 使用方法

安装

npm install --save request

GET请求
var request = require(‘request’);
request(‘http://www.baidu.com’, function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body) // Show the HTML for the baidu homepage.
}
})
POST application/json
request({
url: url,
method: “POST”,
json: true,
headers: {
“content-type”: “application/json”,
},
body: JSON.stringify(requestData)
}, function(error, response, body) {
if (!error && response.statusCode == 200) {
}
});
POST application/x-www-form-urlencoded
request.post({url:’http://service.com/upload’, form:{key:’value’}}, function(error, response, body) {
if (!error && response.statusCode == 200) {
}
})
POST multipart/form-data
var formData = {
// Pass a simple key-value pair
my_field: ‘my_value’,
// Pass data via Buffers
my_buffer: new Buffer([1, 2, 3]),
// Pass data via Streams
my_file: fs.createReadStream(__dirname + ‘/unicycle.jpg’),
};
request.post({url:’http://service.com/upload’, formData: formData}, function (error, response, body) {
if (!error && response.statusCode == 200) {
}
})
formData可以直接放key-value格式的数据,也可以放buffer,或者是通过流描述的文件。

CentOS 6.3 下 curl: (35) SSL connect error 的问题

最近在调paypal API, 连接服务器 curl ssl 的时候会出现connect error
* Connected to api.sandbox.paypal.com (173.0.82.78) port 443 (#0)
* TLS disabled due to previous handshake failure
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* NSS error -12286
* Closing connection #0
* SSL connect error
curl: (35) SSL connect error
但是访问度娘的curl  https://www.baidu.com 又是正常的
其实是系统的 ssl 相关的包没有升级,执行升级命令即可
yum update -y nss curl libcurl

CentOS一个挂载网络磁盘的命令

安装cifs插件
yum -y install cifs*
挂载磁盘
mount -t cifs -o username=loginusername,password=’loginpassword’,iocharset=utf8 //192.168.100.8/upload  /mnt/upload
挂载状态
mount
卸载磁盘
umount /upload  –/upload

数据字典自动生成工具

DataDictionaryTool_0.2.1beta with dependencies.zip
这个工具能用宏自动自成一份 word 2003 文档, 因为用了宏,只支持word 2003。
先用MysqlAdmin (MySQLGUI Bench)将数据库导出成 sql 形式。就可以自动生成数据字典了。
效果如下:

DataDictionaryTool_0.2.1beta with dependencies

关于NuiTrack 的初始化 ColorSensor.GetOutputMode()数据异常

NuiTrack 的初始化时,必须先初始化DepthSensor,再初始化ColorSensor 的数据才正确,也许是SDK的BUG吧
public class NuiTest : MonoBehaviour
{
nuitrack.ColorSensor colorSensor;
nuitrack.DepthSensor depthSensor;
void Start()
{
nuitrack.Nuitrack.Init();
depthSensor = nuitrack.DepthSensor.Create();//////////////////// 没有这句话下面的数据是乱的
colorSensor = nuitrack.ColorSensor.Create();
Debug.Log(“CSLX:” + colorSensor.GetOutputMode().XRes + “,Y:” + colorSensor.GetOutputMode().YRes);
nuitrack.Nuitrack.Run();
}
void OnDestroy()
{
colorSensor.Release();
depthSensor.Release();
nuitrack.Nuitrack.Release();
Debug.Log(“Closing”);
}
}
 
先提交到官网吧
https://community.nuitrack.com/t/colorsensor-create-before-depthsensor-would-make-something-dirty/909

博客搬迁成功

终于将博客移出新浪云了,WordPress 的导入与导出功能实在太赞,直接导出成xml 中间文件再导入进新的WordPress 里就行了。
主题是一直用的ProwerV6主题的主题,迁移过来的时候因为版本问题费了小点劲。
为什么不换?因为真的喜欢这种简约风格的主题啊 ,友情@一下 prower.cn    ProwerV6
Anyway,自从新浪云的MySQL服务各种坑以后,云豆一下两下跑得飞快,限制了云豆嘛,大部分时间是不能访问的,比阿里云/腾讯云还要贵,真的是很蛋疼,拜托,你那是半阉割的PaaS云好不好。
终于清静了,可以再次更新自己的博客了

Linux下查找文件内容

find ../../../ -name “*.php” -type f -print| xargs grep -i “the key is wrong”

腾讯云挂载Linux云盘

使用“fdisk -l”命令查看数据盘相关信息。
使用“df -h”命令,无法看到未分区和格式化的数据盘。
fdisk /dev/vdb
Linuxgeshi-2.png

使用“fdisk -l”命令,即可查看到,新的分区vdb1已经创建完成。

mkfs.ext3 /dev/vdb1
mkdir /log
mount /dev/vdb1 /log
echo ‘/dev/vdb1 /log ext3 defaults 0 0’ >> /etc/fstab

Java 服务器CPU占用100%

最近项目的Java服务器在GC时出现了问题,top查看CPU一直占用100%。找原因的步骤如下:
1、top找到进程ID
2、top -p 【1步的pid】 -H  找到吃满CPU的线程ID
3、jstack 【1步的pid】 > jstack.log
4、printf  %0x 【1步的pid】 找到线程ID的十六进制
5、vi jstack.log 用/ 查找十六进制的线程ID可以找到对应的线程信息
如果第3步有问题可能需要su 提权。
 

Derby 数据库的Continuum 在管理员帐号被锁定时的操作

1.) export DERBY_HOME=`cygpath -wa /cygdrive/c/Programme/derby/10.4.2.0`
2.) export
CLASSPATH=$DERBY_HOME\\lib\\derby.jar\;$DERBY_HOME\\lib\\derbytools.jar
3.) export PATH=`cygpath -ua $DERBY_HOME`/bin:$PATH
4.) ij.bat
4a.) connect
‘jdbc:derby:/usr/local/continuum/data/databases/users’;
4b.) select * from sa.jdouser;
4c.) update sa.jdouser set encoded_password = ‘<some other user’s password>’
where username = ‘admin’;
4d.) update sa.jdouser set count_failed_login_attempts = 0 where username =
‘admin’;
4e.) commit;
4f.) exit;