Monthly Archives: October 2011

Git create a archive

git archive --prefix=prefixDir -9 -o outputname.fmt(zip, tar.gz, tar, tgz)

RTFM!

Ext4中DataStore以及Model需要注意的几点

最近使用ExtJS在做项目, 其中grid会大量的使用Model以及Data.Store.平常使用是没有问题的, 如果做高级搜索的时候, 按照一般情况下, 当然时重建model以及data.store, 就是按以上的思路来做的, 起初的几次, 也没什么问题. 但是使用多次高级搜索之后, 就会报一个this model is undefined错误.
遍历整个代码, model每次都会赋值, 为什么还会是undefined? Google搜索之, 也没找到任何原因.
今天, 重新看Ext文档的时候, 发现了Data.Store的setProxy方法, proxy是用于将搜索条件以及调用函数储存起来, 然后extjs内部会去读取这个object.生成你想要的数据.
目前我已经高级搜索的方法都改成store.setProxy(object); store.loadPage(1); 目前用户测试反馈下来, 无报错..

Geolocation and get the address by Google Map API

在移动设备以及现代浏览器中可以直接同navigator.geolocation所提供的api, 获取你当前经纬度. 并且通过GoogleMapAPI, 查看你当前所在位置的地图.

一. 在客户端上获取经纬度.

获取经纬度有两个api: getCurrentPosition以及watchPosition. 从本质上来说都是获取你当前所在的位置.

getCurrentPosition(callback)

watchPosition(successCallback, failureCallback, options)

在stackoverflow上找到了一篇讨论两者不同的论题. http://stackoverflow.com/questions/1948952/watchposition-vs-getcurrentposition-w-settimeout

After some serious testing, I have verified watchPosition() will give you an accurate location much more quickly than getCurrentPostion() over and over again. When using watchPostion(), the map behaves poorly if you redraw it over and over again every time the device updates your location. To get around this, I have added a listener to the tilesloaded event, which allows me to only redraw the map if there is not already a thread trying to draw on the map. Once the user is happy with the determined location, I will clear the watch. This will get me the best of both worlds, as far as battery consumption and accuracy are concerned.

这个就看你个人喜欢用哪个api了, 我推荐后者watchPosition. 首先写一个页面用来获取经纬度
Read more »

The bash script of downloading the graphics programmming book

Download the <>, by Micheal Abrash

wget http://twimgs.com/ddj/abrashblackbook/gpbb{0..70}.pdf

or

curl -O http://twimgs.com/ddj/abrashblackbook/gpbb{0..70}.pdf

also, you can use the command below:

wget -r -l1 -H -t1 -nd -N -np -A.pdf -erobots=off http://drdobbs.com/high-performance-computing/184404919

How to show all partyframes in the SecureTemplates

The partyHeader only show one partyframe by the default. If you wanna show all partyframes, you add the code blew:

header:SetAttribute("startingIndex", -num)

Note: If you will debug the partyframes and show these partyframes, you set the attribute of “startingIndex” that it must be negative number !. if you set it positive number, u will cant see anything.

Protected: WSUF Tags API List

This content is password protected. To view it please enter your password below:

squid 301错误其中之一的解决办法

这两天将老站点改域名成为一个新站点, 并且同时还是还要支持老域名. 按照常规,只需要在nginx上增加新的域名, 并且在squid上改成新的域名. 恰恰就是这个问题. 刚开始点一两个页面还是没问题. 但是点击后面的文章, 全是一片空白. 然后我跳过squid 都能直接访问到.

然后同chrome开发工具测试, 打开那些页面都是301问题. 然后仔细一看配置. squid上是新域名, nginx是新老域名直接访问新站点. 这时候, 是否认为当我访问一个老域名缓存的cache页面, 她将自动跳转到新域名. 但是这个时候 新域名的这个页面确实不存在的.所以导致返回的code是301.

Read more »

SARG, Squid日志报表

SARG, 全称是Squid Analysis Report Generator.
是一个非常的Squid日志分析工具, 并且可以输出为html. 列出每位用户访问的站点信息, 时间占用, 排名, 链接次数, 访问量等等….

下载: http://sourceforge.net/projects/sarg/files/sarg/sarg-2.3.1/sarg-2.3.1.tar.gz/download

1. 安装

tar zxf sarg-2.3.1.tar.gz 
cd sarg-2.3.1
./configure
make -j4
make install

就完成sarg的安装.
配置文件地址在/usr/local/etc/sarg.conf

2. 配置
主要修改几处配置, 其他直接用默认即可
access_log access.log地址
charset UTF-8

然后运行sarg, 他会在你的wwwroot生产html, 你直接在浏览器输入即可访问到.

使用debian做路由网关

必要软件

今天利用debian做了一台路由网关, 并且能自动翻墙.

首先你需要一些东西: 一台已架设好openvpn/vpn的服务器, 一个已安装好debian系统的电脑或者虚拟机.

首先进入debian, 安装一些必要的软件

apt-get install openssl curl openvpn iptables bind9

Read more »

初次使用NodeJS构建RESTful服务

最近要给项目组用NodeJS写一个简单的RESTful. 在网上简单查了些资料。首先需要在服务器上安装NodeJS以及npm(NodeJS包管理工具). 这里不在重复安装的过程.

安装好这些, 然后需要安装webservice, mysql等模块.

npm install webservice mysql

安装完成之后. 创建一个目录demo, 并且创建一个server.js以及demo.js

Read more »