• 利用Bucardo 将PostgresSQL数据同步到MongoDB

    Bucardo 是一个用 Perl 语言编写的 PostgreSQL的多Master节点复制系统
    它支持任意方式的同步,以下是同步到mongodb的说明
    参考:http://blog.endpoint.com/2011/06/mongodb-replication-from-postgres-using.html

  • 思考

    有两种方式构建软件设计:一种是把软件做得很简单以至于明显找不到缺陷;另一种是把它做得很复杂以至于找不到明显的缺陷。

    一个人,一定要想清楚自己五年后要做什么,不要只看着眼前。

  • 百度地图 JavaScript API 说明

    http://developer.baidu.com/map/jsdemo.htm

    基础应用

    1.创建地图: var map = new BMap.Map(“divid”);

    2.创建坐标点:var point = new BMap.Point(“经度”,”纬度”);

    3.设置视图中心点:map.centerAndZoom(point,size);

    4.激活滚轮调整大小功能:map.enableScrollWheelZoom();

    5.添加控件:map.addControl(new BMap.Xxx());

    6.添加覆盖物:map.addOverlay();

    控件介绍

    1.NavigationControl:缩放地图的控件,默认在左上角;

    2.OverviewMapControl:地图的缩略图的控件,默认在右下方;

    3.ScaleControl:地图显示比例的控件,默认在左下方;

    4.MapTypeControl:地图类型控件,默认在右上方;

    map.addControl()方法添加控件;

    1.标注:Marker

    (1)在point处添加标注:var marker = new BMap.Marker(point);

    (2)添加覆盖物:map.addOverlay(marker);

    (3)激活标注的拖拽功能:marker.enableDragging();

    (4)为标注添加事件:marker.addEventListener(“名称”,function(){

    //点击标注后的事件

    });

    (5)删除覆盖物:map.removeOverlay(marker);

    (6)销毁标注:marker.dispose();

    2.信息窗口:InfoWindow

    (1)在某个特定的位置创建一个信息窗口:var infowindow = new BMap.InfoWindow(“内容”,{width:250,height:100,title:”hello”});

    (2)在地图中央打开信息窗口:map.openInfoWindow(infoWindow,map.getCenter());

    获取坐标:
    http://developer.baidu.com/map/static/doc/Reference_of_Baidu_JavaScript_API_v1.4.pdf
    http://developer.baidu.com/map/static/doc/Guide_for_Baidu_JavaScript_API_v1.4.pdf

    http://api.map.baidu.com/lbsapi/getpoint/index.html
    http://api.map.baidu.com/lbsapi/creatmap/index.html

    test code:

            
    
    function initialize() {
                var map = new BMap.Map('map');
                var point = new BMap.Point(112.550864,37.890277);
                map.centerAndZoom(point, 12);
                /*
                *  缩放控制按钮
                *  BMAP_NAVIGATION_CONTROL_LARGE 表示显示完整的平移缩放控件。
                *  BMAP_NAVIGATION_CONTROL_SMALL 表示显示小型的平移缩放控件。
                *  BMAP_NAVIGATION_CONTROL_PAN 表示只显示控件的平移部分功能。
                *  BMAP_NAVIGATION_CONTROL_ZOOM 表示只显示控件的缩放部分功能。
                * */
                var opts = {type: BMAP_NAVIGATION_CONTROL_ZOOM}
                map.addControl(new BMap.NavigationControl(opts));
                /*
                 *  那个破尺子  可以调整它所在的位置
                 * */
                //var opts = {offset: new BMap.Size(15, 5)}
                //map.addControl(new BMap.ScaleControl(opts));
                /*
                *   此类表示缩略地图控件  就是右下角的那个小地图
                 */
                map.addControl(new BMap.OverviewMapControl());
                /*
                 * 显示其它类型的地图  三维 卫星
                 */
                //map.addControl(new BMap.MapTypeControl());
                //map.setCurrentCity("北京");
    
    /*            map.addEventListener('click', function(e){
                    alert(e.point);
                });*/
    
                /*
                * 从这里我们标注地图
                 */
               var icon = new BMap.Icon('pin.png', new BMap.Size(20, 32), {
                    anchor: new BMap.Size(10, 30)
                });
                var infowindow = new BMap.InfoWindow("内容",{width:250,height:100,title:"hello"});
                //map.openInfoWindow(infowindow,map.getCenter());
    
                var myLabel = new BMap.Label("海辉房产 21000元",     //为lable填写内容
                        {offset:new BMap.Size(-60,-60),                  //label的偏移量,为了让label的中心显示在点上
                            position:point});                                //label的位置
    
                myLabel.setTitle("我是文本标注label");               //为label添加鼠标提示
                map.addOverlay(myLabel);                             //把label添加到地图上
                var circle = new BMap.Circle(point,5000);
                map.addOverlay(circle);
                var mkr =new BMap.Marker(point, {
                    //icon: icon,
                    enableDragging: true,
                    raiseOnDrag: true
                });
                map.addOverlay(mkr);
                mkr.addEventListener('dragend', function(e){
                    //这里可以把获取到的经纬度存到数据库里去
                    console.log(e.point.lng +', '+e.point.lat);
                })
    
    
            }
    
            function loadScript() {
                var script = document.createElement("script");
                script.src = "http://api.map.baidu.com/api?v=1.4&callback=initialize";
                document.body.appendChild(script);
            }
    
            window.onload = loadScript;
     
    
  • 省市数据 json格式 mysql格式

    两种数据

    {"北京":["西城","东城","崇文","宣武","朝阳","海淀","丰台","石景山","门头沟","房山","通州","顺义","大兴","昌平","平谷","怀柔","密云","延庆"],"天津":["青羊","河东","河西","南开","河北","红桥","塘沽","汉沽","大港","东丽","西青","北辰","津南","武清","宝坻","静海","宁河","蓟县","开发区"],"河北":["石家庄","秦皇岛","廊坊","保定","邯郸","唐山","邢台","衡水","张家口","承德","沧州","衡水"],"山西":["太原","大同","长治","晋中","阳泉","朔州","运城","临汾"],"内蒙古":["呼和浩特","赤峰","通辽","锡林郭勒","兴安"],"辽宁":["大连","沈阳","鞍山","抚顺","营口","锦州","丹东","朝阳","辽阳","阜新","铁岭","盘锦","本溪","葫芦岛"],"吉林":["长春","吉林","四平","辽源","通化","延吉","白城","辽源","松原","临江","珲春"],"黑龙江":["哈尔滨","齐齐哈尔","大庆","牡丹江","鹤岗","佳木斯","绥化"],"上海":["浦东","杨浦","徐汇","静安","卢湾","黄浦","普陀","闸北","虹口","长宁","宝山","闵行","嘉定","金山","松江","青浦","崇明","奉贤","南汇"],"江苏":["南京","苏州","无锡","常州","扬州","徐州","南通","镇江","泰州","淮安","连云港","宿迁","盐城","淮阴","沐阳","张家港"],"浙江":["杭州","金华","宁波","温州","嘉兴","绍兴","丽水","湖州","台州","舟山","衢州"],"安徽":["合肥","马鞍山","蚌埠","黄山","芜湖","淮南","铜陵","阜阳","宣城","安庆"],"福建":["福州","厦门","泉州","漳州","南平","龙岩","莆田","三明","宁德"],"江西":["南昌","景德镇","上饶","萍乡","九江","吉安","宜春","鹰潭","新余","赣州"],"山东":["青岛","济南","淄博","烟台","泰安","临沂","日照","德州","威海","东营","荷泽","济宁","潍坊","枣庄","聊城"],"河南":["郑州","洛阳","开封","平顶山","濮阳","安阳","许昌","南阳","信阳","周口","新乡","焦作","三门峡","商丘"],"湖北":["武汉","襄樊","孝感","十堰","荆州","黄石","宜昌","黄冈","恩施","鄂州","江汉","随枣","荆沙","咸宁"],"湖南":["长沙","湘潭","岳阳","株洲","怀化","永州","益阳","张家界","常德","衡阳","湘西","邵阳","娄底","郴州"],"广东":["广州","深圳","东莞","佛山","珠海","汕头","韶关","江门","梅州","揭阳","中山","河源","惠州","茂名","湛江","阳江","潮州","云浮","汕尾","潮阳","肇庆","顺德","清远"],"广西":["南宁","桂林","柳州","梧州","来宾","贵港","玉林","贺州"],"海南":["海口","三亚"],"重庆":["渝中","大渡口","江北","沙坪坝","九龙坡","南岸","北碚","万盛","双桥","渝北","巴南","万州","涪陵","黔江","长寿"],"四川":["成都","达州","南充","乐山","绵阳","德阳","内江","遂宁","宜宾","巴中","自贡","康定","攀枝花"],"贵州":["贵阳","遵义","安顺","黔西南","都匀"],"云南":["昆明","丽江","昭通","玉溪","临沧","文山","红河","楚雄","大理"],"西藏":["拉萨","林芝","日喀则","昌都"],"陕西":["西安","咸阳","延安","汉中","榆林","商南","略阳","宜君","麟游","白河"],"甘肃":["兰州","金昌","天水","武威","张掖","平凉","酒泉"],"青海":["黄南","海南","西宁","海东","海西","海北","果洛","玉树"],"宁夏":["银川","吴忠"],"新疆":["乌鲁木齐","哈密","喀什","巴音郭楞","昌吉","伊犁","阿勒泰","克拉玛依","博尔塔拉"],"香港":["中西区","湾仔区","东区","南区","九龙-油尖旺区","九龙-深水埗区","九龙-九龙城区","九龙-黄大仙区","九龙-观塘区","新界-北区","新界-大埔区","新界-沙田区","新界-西贡区","新界-荃湾区","新界-屯门区","新界-元朗区","新界-葵青区","新界-离岛区"],"澳门":["花地玛堂区","圣安多尼堂区","大堂区","望德堂区","风顺堂区","嘉模堂区","圣方济各堂区","路氹城"]}
    

    中国省市区三级数据库表 txt

  • PhpStorm的一些快捷键说明

    . ctrl + shift + n: 打开工程中的文件
    . ctrl + j: 输出模板
    . ctrl + b: 跳到变量申明处
    . ctrl + alt + T: 围绕包裹代码(包括zencoding的Wrap with Abbreviation), ctrl + shift + del: 删除包裹
    . ctrl + []: 匹配 {}[]
    . ctrl + F12: 可以显示当前文件的结构,快速跳转到目标函数
    . ctrl + x: 剪切行
    . alt + left/right:标签切换
    . ctrl + r: 替换 ctrl + shift + r: 全局替换
    . ctrl + shift + up: 行移动
    . shift + alt + up: 块移动
    . ctrl + d: 行复制
    . ctrl + shift + ]/[: 选中块代码<table>….</table>
    . ctrl + / : 单行注释
    . ctrl + shift + / : 块注释
    . ctrl + shift + i : 显示当前class,function的详细信息
    . ctrl + p: 显示默认参数
    . ctrl + shift + v: 可以复制多个文本
    . shift + enter: 智能跳到下一行
    . ctrl + k: svn 提交
    . ctrl + shift + u: 大小写
    . ctrl + ~ : 切换主题
    . ctrl + F11: 添加标签 ctrl + shift + 大键盘数字键
    . ctrl + alt + F12: file path
    . ctrl + alt + a: search keymap
    . shift + F6: 重构标签名
  • 帝国目录权限修改脚本

    #! /bin/sh
    chmod 777 d/ -Rf
    chmod 777 s/ -Rf
    chmod 777 search/ -Rf
    chmod 777 html/ -Rf
    chmod 777 index.html -Rf
    chmod 777 e/data/ -Rf
    chmod 777 e/install/ -Rf
    chmod 777 e/admin/ebak/bdata/ -Rf
    chmod 777 e/admin/ebak/zip/ -Rf
    chmod 777 e/class/config.php
    chmod 777 e/class/user.php
    chmod 777 e/member/iframe/index.php
    chmod 777 e/member/login/loginjs.php
    chmod 777 e/pl/more/index.php
    chmod 777 e/sch/index.php
    chmod 777 e/tool/feedback/temp/ -Rf
    chmod 777 e/tool/gbook/index.php

  • IE里Cookie跨域不能读取

    1.页面里的COOKIE不能是浏览器进程的COOKIE(包括验证票和不设置超时时间的COOKIE),否则跨域会取不到.这点做跨域COOKIE的人比较少提到.不过实际上留意下几家大学做的方案,有细微的提到他们的验证模块里的COOKIE是有设置超时时间的.

    2.当利用IFRAME时,记得要在相应的动态页的页头添加一下P3P的信息,否则IE会自觉的把IFRAME框里的COOKIE给阻止掉,产生问题.本身不保存自然就取不到了.这个其实是FRAMESET和COOKIE的问题,用FRAME或者IFRAME都会遇到.

    3.测试时输出TRACE,会减少很多测试的工作量.

    只需要设置 P3P HTTP Header,在隐含 iframe 里面跨域设置 cookie 就可以成功。他们所用的内容是:

    P3P: CP=’CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR’

    ASP直接在头部加了头部申明,测试有效。
    <%Response.AddHeader "P3P", "CP=CAO PSA OUR"%>

    php的话,应该是如下写法:
    -PHP
    header('P3P: CP=CAO PSA OUR');

    ASP.NET的话
    通过在代码上加
    -C#
    Response.AddHeader("P3P", "CP=CAO PSA OUR");

    或者在Window服务中将ASP.NET State Service 启动。

    JSP:
    response.setHeader("P3P","CP=CAO PSA OUR")

    英语原文解析
    You can add a P3P compact policy header to your child content, and you can declare that no malicious actions are performed with the data of the user. If Internet Explorer detects a satisfactory policy, then Internet Explorer permits the cookie to be set.

    Visit the following MSDN Web site for a complete list of satisfactory and unsatisfactory policy codes:

    Privacy in Internet Explorer 6
    http://msdn.microsoft.com/workshop/security/privacy/overview/privacyie6.asp
    A simple compact policy that fulfills this criteria follows:

    P3P: CP=”CAO PSA OUR”

    This code sample shows that your site provides you access to your own contact information (CAO), that any analyzed data is only “pseudo-analyzed”, which means that the data is connected to your online persona and not to your physical identity (PSA), and that your data is not supplied to any outside agencies for those agencies to use (OUR).

    You can set this header if you use the Response.AddHeader method in an ASP page. In ASP.NET, you can use the Response.AppendHeader method. You can use the IIS Management Snap-In (inetmgr) to add to a static file.

    Follow these steps to add this header to a static file:

    1. Click Start, click Run, and then type inetmgr.
    2. In the left navigation page, click the appropriate file or directory in your Web site to which you want to add the header, right-click the file, and then click Properties.
    3. Click the HTTP Headers tab.
    4. In the Custom HTTP Headers group box, click Add.
    5. Type P3P for the header name, and then for the compact policy string, type CP=…, where “…” is the appropriate code for your compact policy.

    Alternatively, Internet Explorer users can modify their privacy settings so that they are prompted to accept third party content. The following steps show how to modify the privacy settings:

    1. Run Internet Explorer.
    2. Click Tools, and then click Internet Options.
    3. Click the Privacy tab, and then click Advanced.
    4. Click to select the Override automatic cookie handling check box.
    5. To allow ASP and ASP.NET session cookies to be set, click to select the Always allow session cookies check box.
    6. To receive a prompt for any type of third party cookie, click Prompt in the Third-party Cookies list.

  • ASP读写文本文件

    在ASP里,有一个FSO对象,File System Object,即文件系统对象。我们可以使用它来从文本文件中读取数据,或者将信息写入文本文件中。

    定义和用法

    OpenTextFile 方法打开指定的文件,并返回可用来访问此文件的 TextStream 对象。

    语法:

    FileSystemObject.OpenTextFile(fname,mode,create,format)
    参数 描述
    fname 必需的。要打开的文件的名称。
    mode 可选的。如何打开文件。

    • 1=ForReading – 打开文件用于读取数据。您无法向此文件写数据。
    • 2=ForWriting – 打开文件用于写数据。
    • 8=ForAppending – 打开文件,并向文件的末尾写数据。
    create 可选的。设置如果文件名不存在,是否创建新文件。True 指示可创建新文件,而 False 指示新文件不会被创建。False 是默认的。
    format 可选的。文件的格式。

    • 0=TristateFalse – 以 ASCII 打开文件。默认。
    • -1=TristateTrue – 以 Unicode 打开文件。
    • -2=TristateUseDefault – 使用系统默认格式打开文件。

    先来看一段代码:

    <%
    dim fs,f
    set fs=Server.CreateObject("Scripting.FileSystemObject")
    set f=fs.OpenTextFile(Server.MapPath("testread.txt"),8,true)
    f.WriteLine("This text will be added to the end of file")
    f.Close
    set f=Nothing
    set fs=Nothing
    %>

    上面的代码展示如何将一段文字写入到一个文本文件中。 下面我们再写一段程序,用ASP把它从文本文件中读出来,且看:

    <%
    dim fs,f,t,x
    set fs=Server.CreateObject("Scripting.FileSystemObject")
    set f=fs.CreateTextFile("c:\test.txt")
    f.write("Hello World!")
    f.close
    
    set t=fs.OpenTextFile("c:\test.txt",1,false)
    x=t.ReadAll
    t.close
    Response.Write("The text in the file is: " & x)
    %>

    这里使用了逐行读取的方法,将文本文件中的内容全部读取出来,保存到一个str变量中,ASP最后把str变量输出出来了。
    还一个方法叫readAll(),用它替换readLine()方法,表示,一次性把文本文件中的所有的内容都读出来,这时候当然就不需要循环了,大家可以自己写写看。
  • 地方团

    团购的最大亮点在于他能弥补类似淘宝、京东等商城无法提供生活化服务的缺陷。如果团购仅仅拼的是价格,那团购模式也不会被投资者如此看重了。
    从本地团购消费者的角度来讲,团购网站目前除了在一些大城市推广餐饮、娱乐服务外,对其他地区的大众推出的都是一些仅仅只有价格优势,而缺乏其他特色的产品。有些用户更需要的是一些本地商家、店家的打折优惠,对于这些需求,大的团购网站是无法满足他们的。地方团购网站正好弥补了这些不足,利用本地的地域优势,积极联系本地商家、店家,推出本地特色的团购产品和服务,这是行得通的。
    当我们的团购网站做出品牌知名度、用户量达到一定程度,你还怕没出路吗?无论是自己组建小团购运营还是将其出售给其他团购网站大佬,相信都是不错的选择。