elasticsearch 基本用法。

环境 elasticsearch6.0 kibana-6.0.0

进入
elasticsearch /bin 目录下

下载对应版本的ik分词(我这里是6.0版本)

elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.0.0/elasticsearch-analysis-ik-6.0.0.zip

运行
kibana 运行默认端口5601 开始代码把!

1.CURD

#1.新建数据库(索引)
#number_of_shards 分片的数量 默认5(一旦创建完成不能改)
#number_of_replicas 副本的数量 默认1
PUT blog
{
  "settings":{
    "index":{
      "number_of_shards":5,
      "number_of_replicas":1
    }    
  }
}
#2.获取索引消息
GET _all
GET blog
#3.添加表和数据
POST blog/article
{
  "title":"我是博客",
  "msg":{
    "author":"admin",
    "position":"程序员"
  },
  "desc":"i like you",
  "create_time":"2019-07-12",
  "look":50,
  "like":100
}
#4.获取数据(这里先简写后面详细讲解)
GET blog/article/_search
#5.修改数据
PUT blog/article/0PkS5msBS7MmrBYMH0SR
{
  "title":"我是程序员",
  "msg":{
    "author":"admin",
    "position":"程序员"
  },
  "desc":"i like you",
  "create_time":"2019-07-12",
  "look":50,
  "like":100
}
#5.1 修改数据
POST blog/article/0PkS5msBS7MmrBYMH0SR/_update
{
  "doc":{
    "title":"i like work ( fuck you ) "
  }
}
#6.delete (无法删除表,可以删除索引)
DELETE blog/article/0PkS5msBS7MmrBYMH0SR
DELETE blog
#7. 批量操作(同时执行增删改查)
(
格式 添加 {"index":{"_index":"索引名称","_type":"表名称","_id":"id(可不传入)"}}
接着下面填写数据
修改 {"update":{"_id":"id","_type":"表名称","_index":"索引名称"}}
接着下面修改数据
删除 {"delete":{"_id":"id","_type":"表名称","_index":"索引名称"}}
)
POST _bulk
{"index":{"_index":"blog","_type":"article","_id":1}}
{"title":"我是程序员","msg":{"author":"admin","position":"程序员"},"desc":"i like you","create_time":"2019-07-12","like":100}
{"index":{"_index":"blog","_type":"article","_id":2}}
{"title":"我是程序员","msg":{"author":"admin","position":"程序员"},"desc":"i like you","create_time":"2019-07-12","like":100}
{"update":{"_id":2,"_type":"article","_index":"blog"}}
{"doc":{"like":101}}
{"delete":{"_id":1,"_type":"article","_index":"blog"}}
#8.设置插入类型
( text字符串类型 keyword字符串类型(不分词) properties一个对象 date日期 format日期显示格式 integer数字 analyzer选择分词 )
PUT blog
{
  "mappings": {
    "article": {
      "properties": {
        "title":{
          "type": "text",
          "analyzer": "ik_max_word"
        },
        "msg":{
          "properties": {
            "author":{
              "type":"keyword"
            },
            "position":{
              "type":"keyword"
            }
          }
        },
        "desc":{
          "type": "text"
        },
        "create_time":{
          "type": "date",
          "format": "yyyy-MM-dd"
        },
        "like":{
          "type": "integer"
        }
      }
    }
  }
}

执行GET blog 效果如下:
{
  "blog": {
    "aliases": {},
    "mappings": {
      "article": {
        "properties": {
          "create_time": {
            "type": "date",
            "format": "yyyy-MM-dd"
          },
          "desc": {
            "type": "text"
          },
          "like": {
            "type": "integer"
          },
          "msg": {
            "properties": {
              "author": {
                "type": "keyword"
              },
              "position": {
                "type": "keyword"
              }
            }
          },
          "title": {
            "type": "text",
            "analyzer": "ik_max_word"
          }
        }
      }
    },
    "settings": {
      "index": {
        "creation_date": "1562935455291",
        "number_of_shards": "5",
        "number_of_replicas": "1",
        "uuid": "IQ0B-zsNSmeV26mNjb8i_w",
        "version": {
          "created": "6000099"
        },
        "provided_name": "blog"
      }
    }
  }
}
#1.match查询 (根据分词查询对应数据)
GET blog/article/_search
{
  "query":{
    "match":{
      "title":"python"
    }
  }
}
#2.term查询 (不会对搜索解析)
GET blog/article/_search
{
  "query": {
    "term":{
      "title":"python"
    }
  }
}
#3.terms查询 (数组内有一个满足就查询出来)
GET blog/article/_search
{
  "query": {
    "terms": {
      "title": [
        "php",
        "网站"
      ]
    }
  }
}
#4.分页查询
GET blog/article/_search
{
  "query":{
    "match":{
      "title":"python"
    }
  },
  "from": 0,
  "size": 1
}
#5.全部查询
GET blog/article/_search
{
  "query": {
    "match_all": {}
  }
}
#6.多字段查询 multi_match
GET blog/article/_search
{
  "query": {
    "multi_match": {
      "query": "程序员",
      "fields": ["title","msg.position"]
    }
  }  
}
#7.指定返回字段 (要在设置类型时设置 "store": true)
GET blog/article/_search
{
  "stored_fields":["title","desc"],
  "query": {
    "match": {
      "title": "php"
    }
  }
}
#8.sort排序 
GET blog/article/_search
{
  "query": {
    "match_all": {}
  },
  "sort": [
    {
      "like": {
        "order": "desc"
      }
    }
  ]
}
#9. 查询范围  
GET blog/article/_search
{
  "query": {
    "range": {
      "like": {
        "gte": 10,
        "lte": 20
      }
    }
  }
}

组合查询

#1. filter查询
#select * from article where like=50;
GET blog/article/_search
{
  "query": {
    "bool": {
      "must": {"match_all": {}},
      "filter": {
        "term": {
          "like": "50"
        }
      }
    }
  }
}
#should 或者 must必须 must_not取反 exists是否存在
GET blog/article/_search
{
  "query": {
    "bool": {
      "should": [
        {"term":{"title":"python"}}
      ],
      "must": [
        {"term":{"like":50}}
      ]
    }
  }
}

android9.0 hb 离线打包 plus.runtime.install 失败处理

参考网站:
http://ask.dcloud.net.cn/article/35703

第一步:下载最新的sdk 把libs里用上的 覆盖 到 自己的app

第二步:在application 下添加

<provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="x.x.x.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_provider" />
</provider>

把x换成包名。

C语言编写 hbX 自动生成在线app资源和android打包。

最近离线打包的时候,每一次离线生成app资源时,都要对应修改json文件里的唯一编号,这样如果只有几个还好,但是安卓市场那么多,还是写个自动化操作脚本好点。

好了不逼逼,看下实现步骤先。

  1. 首先是用鼠标点击到hbX 标题栏

2. 修改json文件里的 打包唯一标识

3.执行 alt+U alt+L alt+R 生成本地app资源

4. 把生成的 app资源 复制到 app项目的 assets\apps 目录下

5. 执行 gradle assembleRelease

6. 重命名app-release.apk 为 当前唯一标识 名称

接下来:就是代码的实现了 (我已经把注释写上了)

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <unistd.h>

/* 修改json配置文件 */
void setPackAgeJson(char *codeName)
{
  char *reStr = "{\"packageCode\":";
  char *packageCode = (char *) malloc(strlen(codeName) + strlen(reStr));
  //拼接 唯一标识
  sprintf(packageCode,"%s%s",reStr,codeName);
  //修改配置文件
  FILE *fp = fopen("F:\\xx\\xx\\xx\\xx\\xx\\xx\\xx\\packageCode.json","w");
  //把唯一标识 覆盖到 配置文件中
  fputs(packageCode,fp);
  fclose(fp);
  free(packageCode);
}

void gradleApk(char *codeName,char *name)
{

  setPackAgeJson(codeName);

  //设置鼠标位置为 50,0
  SetCursorPos(50, 0);
  //鼠标单击 
  mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); //左键按下
  mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);   //左键松开

  //按下alt+U
  keybd_event(18, 0, 0, 0);
  keybd_event(85, 0, 0, 0);
  //释放U键
  keybd_event(85, 0, KEYEVENTF_KEYUP, 0);
  //按下alt+L
  keybd_event(76, 0, 0, 0);
  //释放L键
  keybd_event(76, 0, KEYEVENTF_KEYUP, 0);
  //按下alt+R
  keybd_event(82, 0, 0, 0);
  //释放R键
  keybd_event(82, 0, KEYEVENTF_KEYUP, 0);
  //最后释放ALT键
  keybd_event(18, 0, KEYEVENTF_KEYUP, 0);

  //HBX导出app资源 时等 20秒
  Sleep(20000);

  //把导出的资源 复制到 android离线项目上
  system("xcopy F:\\xx\\xx\\xx\\xxx\\xxx\\xxx\\xx\\H5F3683FF F:\\xx\\xx\\app\\src\\main\\assets\\apps\\H5F3683FF\\ /E/Y");
  
  //把当前目录切换到android离线项目上
  chdir("F:\\yigonglaAndroid\\yigongla\\app");

  //执行 打包命令
  system("gradle assembleRelease");

  //打包完成后切换至 生成apk包目录
  chdir("F:\\xxx\\xxx\\app\\build\\outputs\\apk\\release");
  //获取生成的app名称
  char *oldname = "app-release.apk";
  //获取修改生成的app名称
  char *newname = name;
  //把生成的app名称 修改为 newname
  rename(oldname, newname);
}

int main()
{
  //要修改的唯一标识
  char name[5][100] = {"\"111114\"}","\"111115\"}","\"111116\"}","\"111117\"}","\"111118\"}"};
  //重命名apk
  char *newName[5] = {"111114.apk","111115.apk","111116.apk","111117.apk","111118.apk"};
  for(int i=0;i<5;i++)
  {
    gradleApk(*(name+i),*(newName+i));
  }
  
}

效果运行:(记得运行的时候要把 hbx 露出了,不然鼠标点不到)

运行完后的效果(运行是的效果我就不放出来,因为涉及到隐私。)

C语言编写 执行mysql脚本,禁止delete操作

代码:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct sqlConfig
{
        char *db_name;//数据库名称
        char *db_sql;//sql语句
} Config;

int main(int argc,char *argv[])
{

        if(argc!=3)
        {
                printf("第一个参数为数据库名,第二个数据库名为sql语句。\n");
                printf("例如:./a.out mysql 'select * from user;'\n");
                return 0;
        }


        char *shell_cmd = "/xxx/xxx/bin/mysql -h127.0.0.1 -Pxxxx -u xxxx -pxxxx -S /xxx/xxxx/mysql.sock";

        //初始化 结构体
        Config config = {*(argv+1),*(argv+2)};


        /*****  判断是否为delete语句  ******/
        char del_char[6] = {100,101,108,101,116,101};//delete 这个单词的ascii 码
        int is_bool = 0;//如果全部 ascii相同赋值为1
        for(int i=0;i<6;i++)
        {
                if(config.db_sql[i]==del_char[i])
                {
                        is_bool=1;
                }else{
                        is_bool=0;
                        break;
                }
        }
        if(is_bool==1)
        {
                printf("%s\n","危险操作!");
                return 0;
        }

        //动态分配字符变量,用来拼接sql语句
        char *return_text = (char *) malloc(strlen(shell_cmd)+strlen(config.db_name)+strlen(config.db_sql)+10);
        sprintf(return_text,"%s%s%s%s%s%s%s",shell_cmd," -D ",config.db_name," -e ","\"",config.db_sql,"\"");
        printf("%s\n",return_text);
        //执行sql语句
        system(return_text);
        //释放动态变量
        free(return_text);
}

运行:gcc test.c -o my_mysql

接着运行delete操作

./my_mysql bilbil “delete from bilbil_user;”

危险操作

运行 其他操作

./my_mysql bilbil “select * from bilbil_user_info;”
+—-+———+———–+———–+———-+————+———–+———————+———————+
| id | user_id | user_icon | user_name | user_uid | user_birth | user_desc | update_time | create_time |
+—-+———+———–+———–+———-+————+———–+———————+———————+
| 17 | 35 | NULL | NULL | NULL | NULL | | 2019-06-06 14:54:45 | 2019-06-06 14:54:45 |
+—-+———+———–+———–+———-+————+———–+———————+———————+

ios plist 安装应用

我们知道如果要安装ios应用的话除了上架和用itunes 之外,好像没有什么其他好方法了。

其实还有一种比较便捷的方法。

如:

我们先打一个ipa包出来

接着

编写一个 app.plist (app随便写)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>items</key>
        <array>
                <dict>
                        <key>assets</key>
                        <array>
                                <dict>
                                        <key>kind</key>
                                        <string>software-package</string>
                                        <key>url</key>
                                        <string>https://www.huxierong.xyz/yg.ipa (ipa的路径)</string>
                                </dict>
                                <dict>
                                        <key>kind</key>
                                        <string>full-size-image</string>
                                        <key>needs-shine</key>
                                        <true/>
                                        <key>url</key>
                                        <string>https://www.huxierong.xyz/yg.png (图标)</string>
                                </dict>
                                <dict>
                                        <key>kind</key>
                                        <string>display-image</string>
                                        <key>needs-shine</key>
                                        <true/>
                                        <key>url</key>
                                        <string>https://www.huxierong.xyz/yg.png(图标)</string>
                                </dict>
                        </array>
                        <key>metadata</key>
                        <dict>
                                <key>bundle-identifier</key>
                                <string>xxx.xxx.xxx (填写bundle id 如 com.xxx.xxx)</string>
                                <key>bundle-version</key>
                                <string>127 (填写版本code 不是版本名称哦) </string>
                                <key>kind</key>
                                <string>software</string>
                                <key>title</key>
                                <string>测试(填写app名称)</string>
                        </dict>
                </dict>
        </array>
</dict>
</plist>

然后编写一个 down.html

<script>
window.location = "itms-services://?action=download-manifest&url=https://www.huxierong.xyz/x5.plist"; //填写.plist 文件的路径
</script>

用ios手机运行下 正常情况下会出现下面这种情况



注意:如果是个人开发者(¥99) 需要把当前手机的uuid 加入描述文件中,而

企业用户(¥299)就不用,企业用户可以安装在所有ios手机设备上。

个人用户不要用生产环境的证书,不然会出现,点不了的情况