分类归档:未分类

在Windows Mobile(CE)中如何利用jsoncpp解析和创建json

1984680060886856011
在java和苹果的开发中碰到json串时有现成的类或库可以用,但在windows mobile就没有这么幸运了,幸好我们有jsonCPP。

jsonCPP是一个非常好的开源的json解析和创建的API,json官方都推荐的。

首先在VS2008创建一个对话框的工程,把jsonCPP源代码目录的文件加入到工程中 然后设置头文件位置 添加测试代码,即可测试了, 1、测试创建json串

Json::Value root;//表示一个json格式的对象
Json::Value arrayObj;
Json::Value item;

for(int i=0;i<10;i++)
{
item[“key”]=i;
arrayObj.append(item);
}
root[“key1”]=“value1”;
root[“key2”]=“value2”;
root[“array”]=arrayObj;

// std::string out=root.toStyledString(); // 格式化输出
Json::FastWriter write;
std::stringout=write.write(root);// 非格式化输出

2、测试完整解析

Json::Reader reader;
Json::Value root;
bool parsingSuccessful = reader.parse(Cstring2string(m_jsonValue), root );
if( parsingSuccessful )
{
CString strResult;
printValueTree(strResult,root);
m_jsonResult = strResult;
UpdateData(FALSE);
}

read more

JsonCpp 做成Mobile(WinCE)可以使用的库

6597743767285738420
jsoncpp是一个开源的用于解析和创建json的c++的API(关于JSON的格式可以参考:http://www.entlib.net/?p=646)。官网为:http://sourceforge.net/projects/jsoncpp 下载后,可以看到在目录jsoncpp-src-0.5.0\makefiles\vs71下有关于json使用的例子工程,库工程,但是这是用于win桌面操作系统的,没有用于WINDOWS mobile的版本。以下就一步一步做一个可以在mobile下使用的jsoncpp库。 在VS2008中新建一个项目,智能设备的dll库

现在一般都用mobile6.1,因此选择mobile6的SDK,删除mobile5SDK

使用静态mfc的库,否则需要自己拷贝需要的动态mfc库,很麻烦,就用默认的吧

将jsonCPP的源代码添加到工程中 我是将jsoncpp的src下面的lib_json的6个文件拷贝到本工程源代码目录中,然后再添加,当然你可以放在别的地方。 添加完后的工程: 工程配置做如下修改: 4个CPP文件不使用预编译头 指定头文件所在的目录,就是jsoncpp的include目录 这里添加预处理器JSON_DLL_BUILD是为了引出类到库中,因为jsoncpp用的是类,不需要使用def文件来引出,而是需要用微软定义的一个编译保留字指示__declspec(dllexport)。当然在使用这个库的mobile应用程序中需要JSON_DLL这个预处理器定义 可以参考jsoncpp的inlcude目录下的config.h文件。 最后需要修改一处编译错误,这是因为mobile中没有这个函数造成的,只需要注释掉相应的代码即可

Fixed:CKEditor with jQuery.ui.dialog (modal=true)

放到任意位置
例如 保存到文件 jquery.ui.dialog.fix.js 引入即可

	$.widget("ui.dialog", $.ui.dialog, {
		/*! jQuery UI - v1.10.2 - 2013-12-12
		 *  http://bugs.jqueryui.com/ticket/9087#comment:27 - bugfix
		 *  http://bugs.jqueryui.com/ticket/4727#comment:23 - bugfix
		 *  allowInteraction fix to accommodate windowed editors
		 */
		_allowInteraction : function(event) {
			if (this._super(event)) {
				return true;
			}
			
			// address interaction issues with general iframes with the dialog
			if (event.target.ownerDocument != this.document[0]) {
				return true;
			}
			
			// address interaction issues with dialog window
			if ($(event.target).closest(".cke_dialog").length) {
				return true;
			}
			
			// address interaction issues with iframe based drop downs in IE
			if ($(event.target).closest(".cke").length) {
				return
read more

树莓派 搭建一个nginx+php+mysql+dnspod动态解析

这次要搭建一个nginx+php+mysql+dnspod动态解析

有路由器的么直接去路由器管理界面把树莓的mac绑定下,再映射这样会方便很多,不用担心ip变掉。

首先sudo su获得root权限后操作会方便很多

  1. apt-get update

  1. apt-get install nginx php5-fpm php5-cli php5-curl php5-gd php5-mcrypt php5-mysql php5-cgi mysql-server

安装期间会提示叫你输入数据库密码(这必须要记住..)

  • 环境配置

在root权限命令行输入命令

  1. nano /etc/nginx/nginx.conf

对照修改如下
开头部分

  1. user www-data;
  2. worker_processes 1;   修改这里
  3. pid /var/run/nginx.pid;
  4. events {
  5. worker_connections 64; 修改这里
  6. # multi_accept on;
  7. }

继续向后找到gzip  去掉前面的注释 修改如下

  1. gzip on;
  2. gzip_disable “msie6”;
  3. gzip_vary on;
  4. gzip_proxied any;
  5. gzip_comp_level 6;
  6. gzip_buffers 16 8k;
  7. gzip_http_version 1.1;
  8. gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

Ctrol+O保存 Ctrl+X退出
在root权限命令行输入命令

  1. nano /etc/php5/fpm/php.ini

找到这一段

  1. ; Maximum amount of memory a script may consume (128MB) ;
  2. <a href=”http://php.net/memory-limit” target=”_blank”>http://php.net/memory-limit </a>
  3. memory_limit = 32M  修改这里

找到这一段

  1. ; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI.  PHP’s
  2. ; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
  3. ; what PATH_INFO is.  For more information on PATH_INFO, see the cgi specs.  Setting
  4. ; this to 1 will cause PHP CGI to fix its paths to conform to the spec.  A setting ; of zero causes PHP to behave as before.  Default is 1.  You should fix your scripts
  5. ; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
  6. ;<a href=”http://php.net/cgi.fix-pathinfo” target=”_blank”>http://php.net/cgi.fix-pathinfo </a>
  7. cgi.fix_pathinfo=1  修改这里

在root权限命令行输入命令

  1. nano /etc/php5/fpm/php-fpm.conf

找到这一段

  1. ; The maximum number of processes FPM will fork. This has been design to control
  2. ; the global number of processes when using dynamic PM within a lot of pools.
  3. ; Use it with caution.
  4. ; Note: A value of 0 indicates no limit
  5. Default Value: 0 process.max = 4  修改这里

接着改nginx

  1. nano /etc/nginx/sites-enabled/default

找到这里 修改如下

  1. # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
  2. ##
  3. server {
  4. listen   80; ## listen for ipv4; this line is default and implied
  5. #listen   [::]:80 default_server ipv6only=on; ## listen for ipv6root /home/pi/www;

#建议放在此文件夹内,以后管理更加方便

  1. # index index.html index.htm;
  2. index index.php index.html index.htm;
  3. root /home/pi/wwwroot;
  4. index index.html index.htm;
  5. # Make site accessible from http://localhost/
  6. server_name localhost;

在这句后面增加以下内容

  1.  if (!-e $request_filename) {
  2.     rewrite ^(.*)$ /index.php$1 last;
  3. }

找到这句
location ~ \.php$ {
连同后续内容修改如下

  1.    location ~ .*\.php(\/.*)*$
  2. {
  3. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  4.        # NOTE: You should have “cgi.fix_pathinfo = 0;” in php.ini
  5.        # With php5-cgi alone:
  6.        #fastcgi_pass 127.0.0.1:9000;
  7.       With php5-fpm:fastcgi_pass unix:/var/run/php5-fpm.sock;
  8.       fastcgi_index index.php;
  9.       include fastcgi_params;
  10. }

read more

listview下拉刷新 上拉(滑动分页)加载更多

最 近做的类似于微博的项目中,有个Android功能要使用到listview的向下拉刷新来刷新最新消息,向上拉刷新(滑动分页)来加载更多。
新浪微博就是使用这种方式的典型。
当用户从网络上读取微博的时候,如果一下子全部加载用户未读的微博这将耗费比较长的时间,造成不好的用户体验,同时一屏的内容也不足以显示如此多的内容。这时候,我们就需要用到另一个功能,那就是listview的分页了,其实这个分页可以做成客户端的分页,也可以做成服务器端的分页(点击加载时,从服务器对应的加载第N页就好了!!!)。通过分页分次加载数据,用户看多少就去加载多少。
read more

Excel.Application 使用手册

定制模块行为
(1) Option Explicit ‘强制对模块内所有变量进行声明
Option Private Module ‘标记模块为私有,仅对同一工程中其它模块有用,在宏对话框中不显示
Option Compare Text ‘字符串不区分大小写
Option Base 1 ‘指定数组的第一个下标为1
(2) On Error Resume Next ‘忽略错误继续执行VBA代码,避免出现错误消息
(3) On Error GoTo ErrorHandler ‘当错误发生时跳转到过程中的某个位置
(4) On Error GoTo 0 ‘恢复正常的错误提示
(5) Application.DisplayAlerts=False ‘在程序执行过程中使出现的警告框不显示
(6) Application.ScreenUpdating=False ‘关闭屏幕刷新
Application.ScreenUpdating=True read more

AndroidManifest.xml文件详解(activity)(五)

android:taskAffinity

这个属性用于跟Activity有亲缘关系的任务。带有相同亲缘关系的Activity,在概念上是属于相同任务的(从用户的角度看,它们是属于同一应用程序的)。任务的亲缘关系是通过它的根节点的Activity的亲缘关系来判定的。

亲缘关系决定了两件事情:1.Activity能否重新设定父任务(看allowTaskReparenting属性);2.这个任务能够包含用FLAG_ACTIVITY_NEW_TASK标记启动的Activity。

read more

记事本小技巧(可以自动添加时间)

1.打开一个空白的记事本文件 。

2.在第一行写入 .LOG(大写),回车并存盘退出。

3.双击你刚刚保存的文件,这是应该注意到在文件的最后出现了此时的日期时间。

4.你可以输入要写入的内容,存盘退出。

5.每一次你打开这个文件,它都会重复这个动作,添加当时的日期时间的。