Akawa

ETY001的博客

今天在开发一个j2me程序的时候,需要用到json数据的解析,从百度上搜了一圈都是各种教你怎么用的,但问题是没有一个说,这个包从哪里获得。。。从一个老外的blog找到一个jar包,还看到一个非jar包的。先说jar包的,转自:http://per.liedman.net/2010/06/07/the-lack-of-a-json-parser-for-j2me/

In a pet project I’m spending my nights working on (hopefully more about that in a later post), I found myself in need of a JSON parser, or deserializer, for J2ME/CLDC. A bit to my surprise, I found that such a thing was not easy to find, even with the whole of the internets at my disposal.

To summarize, it appears that there has been a JSON lib for J2ME up on json.org at some point, but at least I can’t find it any longer. Also, some project on java.net is popular to link to, but come on, no download link? No pre-compiled JAR-file?

Anyway, after asking over at stackoverflow.com and getting surprisingly few answers, at least I found a link to some code that was easy enough to grab.

As some kind of attempt to give back to the community, I upload the compiled JAR from that source code here. So if you need to serialize, deserialize, marshal or unmarshal JSON from J2ME/CLDC, grab this JAR and go ahead:

The code is most likely a copy of the one that was previously posted on json.org, and is distributed under the json.org license according to the copyright notice in the source (most importantly: “The Software shall be used for Good, not Evil.”)

As a very tiny modification, I have added the methods remove and removeAll to the class JSONArray, since I really needed them. I hope you don’t mind too much.

非jar包:https://github.com/upictec/org.json.me/

最近不知道怎么安装过什么东西,导致了双击PHP文件打开Aptana Studio的时候,总是弹出failed to create the java virtual machine的错误提示框,但是Aptana Studio如果手动是能开启的。这个事情非常的让人郁闷,上百度搜了一圈都是说eclipse的处理方式的,后来在google上找到一篇英文的(http://kisdigital.wordpress.com/2011/06/16/speeding-up-aptana-studio-3/),大体意思是说按照eclipse的那个方法修改Aptana的配置文件也是可以成功的,于是我就复制了一下他给的配置文件,然后就好了,现在贴出来配置文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-name
Aptana Studio 3
-vmargs
-Xms512m
-Xmx512m
-Declipse.p2.unsignedPolicy=allow
-Djava.awt.headless=true
-XX:PermSize=128m
-XX:MaxPermSize=128m
-Xverify:none
-XX:+UseParallelGC
-XX:+AggressiveOpts
-XX:+UseFastAccessorMethods

vpn安装神马的都弱爆了,在linux下,直接一条命令就用ssh翻墙了,对以前的无知感到羞愧呀。。。。
命令如下:

1
sudo ssh -qTfnN -D 7070 root@host

7070是在本地开的代理端口,root是vps的用户名,host是vps的地址。
命令执行后,输入完vps密码,再在系统里设置代理即可,IP填127.0.0.1,端口7070.

最近买了一个BurstNet的VPS来玩玩,的确是很给力的,性价比超高,关键是有两个公网IP,并且可以再装cpanel之类的面板,操作系统的可选择性也极高,centos5,centos5.5,centos6.2,ubuntu,fedora,gentoo等等,并且系统貌似都是经过精简过的,就像我安装的centos5,安装完居然只占13M内存,硬盘也是只花费了550M。

为了测试一下这款VPS是否能搭建VPN,我从网上搜索了很多资料,最终了解到,OpenVZ架构的VPS只能安装OpenVPN,并且还需要开启TUN支持和iptables_nat模块支持(这个其实可以换一个iptables语句的)。

我参考了以下两篇博文,http://wty.name/centos-install-openvpn/http://www.xiaozhou.net/ittech/linux-ittech/configure_openvpn_on_burstnet_vps-2010-03-28.htm

其中需要注意的两点,一个是第一篇博文中有一键安装包,那个shell脚本里的ip地址并没有获取到,导致生成的.ovpn文件中的remote的ip地址是空白,再一点就是shell里面涉及到iptables转发的问题,在第二篇博文的评论中有提到解决方案。这个问题在网上其实也是很多的,就是执行

iptables -t nat -A POSTROUTING -s 192.168.21.0/24 -o eth0 -j MASQUERADE

的时候,会出现如下错误提示,

iptables:Unknown error 4294967295

解决方法是,改为下面的语句去执行:

/sbin/iptables -t nat -A POSTROUTING -s 192.168.21.0/24 -j SNAT –to-source YourVpsIP

这个vps的vpn配置我算是折腾了两天了,不过现在终于是可以翻墙出去啦,吼吼~

.htaccess文件如果没有生效的话,那么很可能是你的虚拟机配置信息中的AllowOverride 配置项的参数是None(默认是None),把这个设置为All 即可。

下面是AllowOverride 指令的相关信息:

说明:确定允许存在于.[htaccess](http://www.jzxue.com/tag/htaccess/)文件中的指令类型

语法:AllowOverride All|None|directive-type[directive-type] …

服务器发现一个.htaccess文件(由AccessFileName指定)时,它需要知道在这个文件中声明的哪些指令能覆盖在此之前指定的配置指令。

阅读全文 »

捣鼓了好几个小时了,终于知道怎么配置DHCP自动获取IP了,还是得上ArchLinux的官方Wiki才是王道啊。。。

DHCP (自动获取) IP

在这种情况下,你需要安装 dhcpcd 包(绝大多数情况下都是默认安装好的)。这样编辑 /etc/rc.conf :

1
2
3
eth0="dhcp"
INTERFACES=(eth0)
ROUTES=(!gateway)

貌似2012年9月份那个包以后,启动dhcp的方法有变化,看这里:https://wiki.archlinux.org/index.php/Configuring_Network_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)#.E5.90.AF.E5.8A.A8.E6.97.B6.E8.BF.90.E8.A1.8C_DHCP

刚才在看我的博客cnzz统计的时候,猛然间发现的这个隐患。

这个隐患是在人人网手机版页面,造成这个隐患的原因应该是方便手机用户能记忆登陆状态。

如果想触发这个漏洞,需要的条件比较多,但是一定会有上钩的。

介于现在还未和人人网说,所以暂且不公布,但是我想聪明的各位,应该能从我上面的叙述中猜出一二~

转载:http://hi.baidu.com/cpu686/blog/item/ad8caa0f05c652e1ab645709.html

于Nginx对高并发的优良性能,故配了个Nginx+php-fpm来跑在线代理程序,是按照张宴文章配的,刚配置好时运行正常,但运行一段时间 后,网站打开很慢,打开网站后,在输入框输入要访问的网站,也慢得不行。在网站打开慢时,在SSH终端上输入命令也慢,怀疑是机房网速问题,但在ssh上 输入

w3m www.example.com

这个打开也慢,基本可以排除机房的网速问题。

当打开网站慢时,把服务器重启后,就会快起来,后来发现,用

/usr/local/webserver/php/sbin/php-fpm restart

把fastcgi重启下也会快起来,最把它加入计划任务,每小时重启下,基本保证网站不会慢,但终究不是办法。

查看了nginx.log和php-fpm.log,根据里面的错误,找了以上转载的几篇文章,总算是把问题解决了,主要修改了两个地方
1、
问题:
发现/usr/local/webserver/php/etc/php-fpm.conf文件里定义的打开文件描述符的限制数量是
51200
但用 命令ulimit -n查看,发现只有1024

我已在/etc/rc.local里添加了
ulimit -SHn 51200

竟然没生效

解决:
vi /etc/security/limits.conf

文件最后加上
*        soft    nofile 51200
*        hard    nofile 51200

阅读全文 »
0%