Giter VIP home page Giter VIP logo

dev-notes's People

Contributors

iott avatar

Stargazers

 avatar

Watchers

 avatar  avatar

dev-notes's Issues

geojson2shp character encoding, with ogr2ogr

1. 问题描述

开发中有个需求把geojson文件转化为shp文件,其中的属性值为中文,通过ogr2ogr转换的结果查看发现乱码,然后各种查询和搜索最终得以解决

1.1设置编码前的操作命令如下:

ogr2ogr -f "ESRI Shapefile" f:\\gdal\\countries.shp f:\\gdal\\countries.geojson

1.2 设置编码的操作命令如下:

ogr2ogr --config SHAPE_ENCODING "UTF-8" -f "ESRI Shapefile" f:\\gdal\\countries.shp f:\\gdal\\countries.geojson
or
ogr2ogr --config SHAPE_ENCODING "UTF-8" -f "ESRI Shapefile" f:\\gdal\\countries.shp f:\\gdal\\countries.geojson

MySQL GIS常用空间函数.md

由于之前从未接触过GIS,本文粗浅的记录一些涉及到的函数,便于日后翻阅。

常用函数

MBRIntersects

  • 作用:从数据库中获取完全或部分在此框内的所有多边形
  • 示例:
SELECT * FROM `polygons` 
 WHERE mbrIntersects(ogc_geom,
   GeomFromText('POLYGON((-18 120,-10 120,-10 140,-18 140, -18 120))'));

ST_WITHIN

  • 作用:找出目的地(例如餐馆)是否在范围内。ST_WITHIN(g1, g2): 如果g1在g2的范围内,则返回1,否则返回0
  • 示例:
select ST_WITHIN(ST_GeomFromText('POINT(123.7550476770001 48.29881346700004)'),ST_GeomFromText("POLYGON((123.7550476770001 48.29881346700004,123.754951105 48.29876770200008,123.7547182170001 48.29896478300005,123.7538080500001 48.29853876000006,123.7540577190001 48.29835305800005,123.7537012780001 48.29830251100005,123.753545848 48.29847929300011,123.75315602 48.29836059100005,123.7529432980001 48.29856224300004,123.753799132 48.299119832,123.7543766760001 48.29942498400002,123.7544152390001 48.29945213900005,123.7550476770001 48.29881346700004))"))

总结.md

docker常用命令

本文只记录docker常用命令,如果想了解每一个选项的细节,请参考官方文档,这里只作为自己以后的备忘记录下来。

概览

  • 容器生命周期管理
    docker [run|start|stop|restart|kill|rm|pause|unpause]

  • 容器操作运维
    docker [ps|inspect|top|attach|events|logs|wait|export|port]

  • 容器rootfs命令
    docker [commit|cp|diff]

  • 镜像仓库
    docker [login|pull|push|search]

  • 本地镜像管理
    docker [images|rmi|tag|build|history|save|import]

  • 其他命令
    docker [info|version]

docker 状态信息查看

docker info

Docker 镜像管理

创建镜像
  • 根据DockerFile构建容器
    Step1:创建Dockefile文件及其相关依赖文件
    Step2:切换到Dockerfile文件所在目录,执行如下命令:
    cd DockerFile所在目录
    docker build -t 镜像名 .
    
  • 根据已有镜像实例化后进行交互式环境修改后保存
    Step1:根据已有镜像实例化容器,记录容器ID,并进入交互式命令行
    docker run -it 已有镜像名称 /bin/bash
    
    Step2:在交互式命令行执行相关操作后退出交互式命令行
    Step3:执行如下命令创建镜像
    docker commit 容器ID 镜像名称
    
修改镜像
  • 对照创建镜像,修改镜像同样有两种方式:
    1.修改Dockerfile后重新创建镜像
    2.根据已有镜像实例化后进行交互式环境修改后保存
查看所有镜像列表

docker images 或 docker images --no-trunc

删除本地镜像
docker rmi b39c68b7af30  镜像名称
注:对于存在容器的镜像,首先需要删除其对应的容器才能删除该镜像
为镜像添加标签
docker tag 旧镜像名称 新镜像名称
注:该命令会在原有的镜像上重新生成一个新的镜像名称对应该镜像
拉取镜像
docker pull 镜像名称
注:该命令会在对应的镜像仓库查询镜像并拉取到本地
推送镜像
docker push 镜像名称

docker运行容器

docker运行容器的基本命令:

docker run -参数 镜像名称 执行命令

运行容器命令可以分解为三个部分,分别是参数,镜像名称和执行命令

  • 参数:
1.  -it:-i参数用设置容器中的STDIN是开启的。-t参数表示为创建的容器分配一个伪tty终端。 二者通常联合使用。
2.  --name 容器名:用于为启动的容器设置一个容器名称。
3.  -d:将程序放在后台执行,用于创建守护式容器。
4.  --restart:设置自动重启,可以设置什么情况下重启,例如--restart=always,--restart=on-failure:5。
5.  -p:端口映射。例如:8000:80表示将容器的80端口映射到宿主机的8000端口。80表示将容器的80端口映射到宿主机的任意端口。
6.  -P:端口映射,将容器Dockerfile中EXPOSE指定的端口映射到宿主机的任意端口。
7.  -w:指定工作目录
8.  -h:为容器设置HOST主机名称。
9.  --entrypoint:强制指定启动程序。
10.  -v:卷映射。示例:/home/nianshi/logs:/logs表示将宿主机的/home/nianshi/logs目录挂载到容器的/logs目录下。
11.  --link:容器链接。示例:redis:db表示将容器名称为redis的容器连接到新建的容器上,同时设置别名为db。此时在新容器中可以使用db来表示redis容器的地址。
12.  --volumes-from:参数用于连接某个指定容器的卷,从而可以访问到指定容器中的所有的卷。示例:blog_demo表示新容器中挂载了blog_demo容器中所有的卷。
13.  --rm:表示容器运行完成后自动删除。
  • 镜像名称
    此处镜像名称需要输入完成的镜像名称。
    镜像名称的格式如下:[Registry/][username/]简要镜像名称[:标签]
    注:其中Registry默认为Docker Hub地址; 对于官方源,username不需要填写,否则必填;简要镜像名称必填;标签默认为latest。
  • 执行命令
    执行命令为启动容器时需要执行的操作。
    例如:
    /bin/bash
    

docker启动/停止容器

  • 启动一个目前尚未运行的容器
    docker start 容器名称/容器ID 
    
  • 停止一个运行中的容器
    docker stop 容器名称/容器ID
    

docker进入容器命令行

当我们启动了一个有交互式运行环境的容器时,可以执行如下命令来进入交互式环境。

docker attach 容器名/容器ID
或
docker exec -it 容器名称/容器ID

docker已有镜像中运行命令/启动进程

docker exec -参数 容器名称/容器ID 执行命令

查看容器

查看所有容器列表
docker ps -a

查看正在运行的容器

docker ps
查看指定容器的详细信息
docker inspect 容器名称/容器ID

查看docker状态

docker stats

查看容器端口

docker port 容器名称/容器ID

查看指定容器进程

docker top 容器名称/容器ID

docker 查看指定容器日志

docker logs 容器名称/容器ID
注:可以添加-f来监控日志文件,-t参数来增加时间戳。

启动容器

docker run -d 容器名

停止容器

docker stop 容器名称/容器id

重启容器

docker start 容器id

删除容器

docker rm 容器名称/容器ID

删除所有容器

docker rm `docker ps -a -q`

将宿主机目录拷贝到容器

docker cp /ROOT.war mytomcat2:/usr/local/tomcat/webapps
注: cp:拷贝命令;将ROOT.war文件拷贝到mytomcat2容器中的/usr/local/tomcat/webapps目录下

soap client - server communication in Nodejs

complete example:
// server.js

var soap = require('strong-soap').soap;
var http = require('http');

var myService = {
    CheckUserName_Service: {
        CheckUserName_Port: {
            checkUserName: function(args, soapCallback) { 
                console.log('checkUserName: Entering function..');
                soapCallback(args);
            }
        }
    }   
};


var xml = require('fs').readFileSync('check_username.wsdl', 'utf8');

var server = http.createServer(function(request,response) {
    response.end("404: Not Found: " + request.url);
});

var port = 8000;
server.listen(port);

var soapServer = soap.listen(server, '/test', myService, xml);
soapServer.log = function(type, data) {
    console.log('Type: ' + type + ' data: ' + data);
};

console.log('SOAP service listening on port ' + port);

//client.js

"use strict";

var soap = require('strong-soap').soap; 
var url = 'http://localhost:8000/test?wsdl';

var options = { endpoint: 'http://localhost:8000/test'};
var requestArgs = { userName: "TEST_USER" };
let method="checkUserName";
soap.createClient(url, options, function(err, client) {
  if (err) {
      console.error("An error has occurred creating SOAP client: " , err);  
  } else {
    console.log("client:",client);
      var description = client.describe();
      console.log("Client description:" , description);
      // var method = client.checkUserName;
      var method = client["CheckUserName_Service"]["CheckUserName_Port"]["checkUserName"];
      console.log(method,111);
      method(requestArgs, function(err, result, envelope, soapHeader) {
      // client.checkUserName(requestArgs, function(err, result, envelope, soapHeader) {
        //response envelope
        console.log('Response Envelope: \n' + envelope);
        //'result' is the response body
        console.log('Result: \n' + JSON.stringify(result));
      });
  }
});

//check_username.wsdl

<definitions name = "CheckUserNameService"
   targetNamespace = "http://www.examples.com/wsdl/CheckUserNameService.wsdl"
   xmlns = "http://schemas.xmlsoap.org/wsdl/"
   xmlns:soap = "http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:tns = "http://www.examples.com/wsdl/CheckUserNameService.wsdl"
   xmlns:xsd = "http://www.w3.org/2001/XMLSchema">

   <message name = "CheckUserNameRequest">
      <part name = "userName" type = "xsd:string"/>
   </message>
   <message name = "CheckUserNameResponse">
      <part name = "status" type = "xsd:string"/>
   </message>
   <portType name = "CheckUserName_PortType">
      <operation name = "checkUserName">
         <input message = "tns:CheckUserNameRequest"/>
         <output message = "tns:CheckUserNameResponse"/>
      </operation>
   </portType>

   <binding name = "CheckUserName_Binding" type = "tns:CheckUserName_PortType">
      <soap:binding style = "rpc"
         transport = "http://schemas.xmlsoap.org/soap/http"/>
      <operation name = "checkUserName">
         <soap:operation soapAction = "checkUserName"/>
         <input>
            <soap:body encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/" namespace = "urn:examples:CheckUserNameService" use = "encoded"/>
         </input>
         <output>
            <soap:body encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/" namespace = "urn:examples:CheckUserNameService" use = "encoded"/>
         </output>
      </operation>
   </binding>

   <service name = "CheckUserName_Service">
      <documentation>WSDL File for CheckUserNameService</documentation>
      <port binding = "tns:CheckUserName_Binding" name = "CheckUserName_Port">
         <soap:address
            location = "http://www.examples.com/CheckUserName/" />
      </port>
   </service>
</definitions>

Nginx--启动 重启 关闭

概览

启动

启动代码格式:nginx安装目录地址 -c nginx配置文件地址

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

停止

Step1:查看进程号

ps -ef|grep nginx

Step2:根据pid kill 进程

kill -QUIT 2072      //从容停止
kill -TERM 2132 或 kill -INT 2132   //快速停止
pkill -9 nginx    //强制停止

重启

  • 验证Nginx配置文件是否正确
    方式一:
    step1:进入Nginx安装目录sbin下
    step2:输入命令./nginx -t
    看到如下显示nginx.conf syntax is ok
    nginx.conf test is successful
    说明配置文件正确!
    方式二:
    在启动命令-c前加-t
    /usr/local/nginx/sbin/nginx -t  -c /usr/local/nginx/conf/nginx.conf
    
  • 重启Nginx服务
    方式一:进入nginx可执行目录sbin下,输入命令./nginx -s reload 即可
    cd /usr/local/nginx/sbin
    ./nginx -s reload
    
    方式二:查找当前nginx进程号,然后输入命令:kill -HUP 进程号 实现重启nginx服务
    ps -ef|grep nginx
    kill -HUP 2255
    

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.