简单详细的Typora 流程图使用

1、横向流程图源码格式(mermaid) graph LR A[方形] -->B(圆角) B --> C{条件a} C -->|a=1| D[结果1] C -->|a=2| E[结果2] A-->F[横向流程图] G[横向流程图] 例如 graph LR A[方形] --> B(圆角) B --> C{条件a} C --> |a=1| D[结果1] C --> |a==2| E[结果2] A --> F[横向流程图] G[横向流程图] ### 2、竖向流程图源码格式(mermaid) > ``` `graph TD A[方形] --> B(圆角) B --> C{条件a} C --> |a=1| D[结果1] C --> |a=2| E[结果2] A --> F[竖向流程图]` 例如: `graph TD A[方形] --> B(圆角) B --> C{条件a} C --> |a=1| D[结果1] C --> |a=2| E[结果2] A --> F[竖向流程图] ` 3、标准流程图源码格式(flow) st=>start: 开始框:>https://www.baidu.com op=>operation: 处理框 cond=>condition: 判断框(是或否?) sub1=subroutine: 子流程 io=>inputoutput: 输入输出框 e=>end: 结束框 st->op->cond cond(yes)->io->e cond(no)->sub1(right)->op 例如: ...

2021年1月29日 · 3 分钟 · 天边的星星

ElasticSearch安装与配置

ElasticSearch安装与配置 centos 7 安装 ElasticSearch 安装elasticsearch之前 先要安装java jdk 8 这里提供下载地址:链接: https://pan.baidu.com/s/1ZIJc0JWKMyLl4Iivh-YlBw 密码: gr08 `# 进入opt目录 cd /opt/ # 创建 soft文件夹 用来存储所有的软件 如果你有自己的目录,可以不创建这个目录 mkdir soft cd soft # 执行下载 ElasticSearch 这里使用目前最新的 7.10.1 如果没有wget命令 执行 yum install wget 进行安装 wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.1-linux-x86_64.tar.gz # 解压文件 tar -zxvf elasticsearch-7.10.1-linux-x86_64.tar.gz # 修改文件夹名称和移动目录 mv elasticsearch-7.10.1 /opt/elasticsearch # 进入elasticsearch目录 cd /opt/elasticsearch # 默认为了安全,不要使用root进行启动,这里创建一个 elasticsearch 用户和组 # 添加 elasticsearch 组 groupadd elasticsearch # 添加 elasticsearch 用户 并添加到elasticsearch组中 -g 后表示组 useradd elasticsearch -g elasticsearch # 修改文件夹拥有者 表示把elasticsearch文件夹 给elasticsearch用户和elasticsearch组 # 修改这个组之前 先退到elasticsearch的目标文件夹上一级 chown -R elasticsearch:elasticsearch elasticsearch # 修改elasticsearch配置文件 # 进入elasticsearch 的config目录 cd elasticsearch/config/ # 编辑配置文件 参考下面配置文件 vi elasticsearch.yml ## 启动 # 进入 elasticsearch/bin目录 cd bin/ # 使用elasticsearch用户进行启动 sudo -u elasticsearch ./elasticsearch -d # 查询是否启动成功 ps -ef|grep elasticsearch # 查看启动日志 tail -f /opt/elasticsearch/logs/yqzl-service.log # 验证是否成功 curl http://localhost:9200 #出现这个表示成功 :` { "name" : "yqzl-node-1", "cluster_name" : "yqzl-service", "cluster_uuid" : "3wrpP4wwTFCBHdCboBqQfQ", "version" : { "number" : "7.10.1", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "1c34507e66d7db1211f66f3513706fdf548736aa", "build_date" : "2020-12-05T01:00:33.671820Z", "build_snapshot" : false, "lucene_version" : "8.7.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" } ` ` elasticsearch.yml `# ======================== Elasticsearch Configuration ========================= # # NOTE: Elasticsearch comes with reasonable defaults for most settings. # Before you set out to tweak and tune the configuration, make sure you # understand what are you trying to accomplish and the consequences. # # The primary way of configuring a node is via this file. This template lists # the most important settings you may want to configure for a production cluster. # # Please consult the documentation for further information on configuration options: # https://www.elastic.co/guide/en/elasticsearch/reference/index.html # # ---------------------------------- Cluster ----------------------------------- # # Use a descriptive name for your cluster: 集群名称 # cluster.name: yqzl-service # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: 节点名称 # node.name: yqzl-node-1 # # Add custom attributes to the node: # #node.attr.rack: r1 # # ----------------------------------- Paths ------------------------------------ # # Path to directory where to store the data (separate multiple locations by comma): # #path.data: /path/to/data # # Path to log files: # #path.logs: /path/to/logs # # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # #bootstrap.memory_lock: true # # Make sure that the heap size is set to about half the memory available # on the system and that the owner of the process is allowed to use this # limit. # # Elasticsearch performs poorly when the system is swapping the memory. # # ---------------------------------- Network ----------------------------------- # # Set the bind address to a specific IP (IPv4 or IPv6): 运行访问的ip 0.0.0.0 表示都可以访问 # network.host: 0.0.0.0 # # Set a custom port for HTTP: # #http.port: 9200 # # For more information, consult the network module documentation. # # --------------------------------- Discovery ---------------------------------- # # Pass an initial list of hosts to perform discovery when this node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # #discovery.seed_hosts: ["host1", "host2"] # # Bootstrap the cluster using an initial set of master-eligible nodes: 初始化主节点 # cluster.initial_master_nodes: ["yqzl-node-1"] # # For more information, consult the discovery and cluster formation module documentation. # # ---------------------------------- Gateway ----------------------------------- # # Block initial recovery after a full cluster restart until N nodes are started: # #gateway.recover_after_nodes: 3 # # For more information, consult the gateway module documentation. # # ---------------------------------- Various ----------------------------------- # # Require explicit names when deleting indices: # #action.destructive_requires_name: true ` 安装遇到问题 `elasticsearch启动时遇到的错误 elasticsearch用户拥有的内存权限太小,至少需要262144; ...

2020年12月18日 · 3 分钟 · 天边的星星

阿里云OSS之Nginx反向代理配置

nginx配置 设置代理 upstream ossproxy{ server zcpcimgs.oss-cn-beijing.aliyuncs.com; } 配置代理 server { listen 80; server_name zc2019.com; location /data { proxy_pass http://ossproxy; proxy_redirect off; proxy_set_header Host zcpcimgs.oss-cn-beijing.aliyuncs.com; proxy_set_header X-Real-IP remote_addr; proxy_set_header X-Forwarded-Forproxy_add_x_forwarded_for; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_max_temp_file_size 0; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; } location / { # root html; # index index.html index.htm; proxy_pass http://zcjfweb; # 真实信息 proxy_set_header Host host; proxy_set_header X-Real-IPremote_addr; proxy_set_header X-Forwarded-For proxy_add_x_forwarded_for; client_max_body_size 100M; proxy_read_timeout 30000; proxy_send_timeout 75s; #proxy_redirect off; #proxy_pass_header Set-Cookie; #proxy_hide_header X-Powered-By; #proxy_hide_header X-Mod-Pagespeed; #proxy_ignore_client_abort off; #proxy_cache_valid any 10m; #proxy_connect_timeout 75s; #proxy_read_timeout 75s; #proxy_send_timeout 75s; } ...

2019年3月19日 · 2 分钟 · 天边的星星

微信分享链接的缩略图和标题

一、微信内分享 在微信内打开链接后,点右上角【…】选择【发送给朋友】或【分享到朋友圈】,这种分享方式获取缩略图的方法: 方法一:在页面 body 最上方添加 300*300 像素的 img 如该图片不需要显示,可以用 css 隐藏,但不能直接对 img 设置 display: none;。 可以在父层 div 上设置 display: none; 或者对 img 设置 position: absolute; visibility: hidden;。 <img src=&quot;/img/thumbnail.png&quot; alt=&quot;&quot;></div> 1 " data-snippet-id="ext.2607b3963245b14ba18790d96be6e596" data-snippet-saved="false" data-codota-status="done">`&lt;div style="display:none;"&gt;&lt;img src="/img/thumbnail.png" alt=""&gt;&lt;/div&gt;` 方法二:通过微信 JS-SDK 的分享接口 这种方法需要一个微信公众号的 app_id,同时需要一个后端服务生成 signature。好处是可以定制分享的标题、缩略图、描述。 二、从浏览器分享 在浏览器打开链接后,点分享图标,选择【微信】,这种分享方式获取缩略图的方法: 在页面的 head 部分添加 Open Graph Metadata: <meta property=&quot;og:title&quot; content=&quot;页面标题&quot;> <meta property=&quot;og:description&quot; content=&quot;页面描述&quot;> <meta property=&quot;og:image&quot; content=&quot;http://www.example.com/img/thumbnail.png&quot;> <meta property=&quot;og:url&quot; content=&quot;http://www.example.com/&quot;> 1 2 3 4 5 " data-snippet-id="ext.d5f2b073507882789543238b1b2f0a2b" data-snippet-saved="false" data-codota-status="done">`&lt;meta property="og:type" content="website" /&gt; &lt;meta property="og:title" content="页面标题"&gt; &lt;meta property="og:description" content="页面描述"&gt; &lt;meta property="og:image" content="http://www.example.com/img/thumbnail.png"&gt; &lt;meta property="og:url" content="http://www.example.com/"&gt;` 其中 og:image 影响浏览器分享时的图标,需要指定图片的完整路径。 ...

2019年3月2日 · 2 分钟 · 天边的星星

H5自动播放音频

方法一 监听界面元素 监听界面 //–创建页面监听,等待微信端页面加载完毕 触发音频播放 document.addEventListener(‘DOMContentLoaded’, function () { function audioAutoPlay() { var audio = document.getElementById(‘audio’); audio.play(); document.addEventListener(“WeixinJSBridgeReady”, function () { audio.play(); }, false); } audioAutoPlay(); }); //–创建触摸监听,当浏览器打开页面时,触摸屏幕触发事件,进行音频播放 document.addEventListener(‘touchstart’, function () { function audioAutoPlay() { var audio = document.getElementById(‘audio’); audio.play(); } audioAutoPlay(); }); // var firstTouch = true; $(“body”).bind(“touchstart”,function(e) { if ( firstTouch ) { firstTouch = false; document.getElementById(‘audio’).play(); }else{ return; } }); // $(“body”).one(“touchstart”,function() { document.getElementById(‘audio’).play(); }); ...

2019年2月28日 · 2 分钟 · 天边的星星

linux中java执行脚本守护脚本

#/bin/bash while true; do count=`ps -ef | grep test.jar | grep -v grep|wc -l` if [ ${count} -lt 1 ]; then nohup java -jar xxx.jar >log.out 2>&1 & else echo “process is running” fi sleep 3 done Linux Shell脚本:自动读取pid并关闭进程 查询进程信息 ps -ef|grep elasticsearch 过滤掉grep进程 ps -ef|grep elasticsearch|grep -v grep 提取pid(awk以空格分割,显示第二个变量即为pid) ps -ef|grep elasticsearch|grep -v grep|awk ‘{print $2}’ 根据pid kill掉该进程 完整脚本如下所示

2019年2月22日 · 1 分钟 · 天边的星星

配置独立sftp账号

 设置用户组和用户、并设置密码 groupadd sftp #创建sftp用户组 useradd -g sftp -s /bin/false mysftp # 创建mysftp用户 passwd mysftp #设置mysftp密码 创建并设置mysftp的主目录 mkdir mydata #创建mydata文件夹 cd mydata #进入mydata mkdir uploads #创建uploads文件夹 usermod -d /mydata/uploads/ mysftp #设置mysftp的主目录 配置sshd_config vi /etc/ssh/sshd_config #这个要放到最后(至少保证在’UseDNS’ 后面否则可能出现错误) # Subsystem sftp /usr/libexec/openssh/sftp-server Subsystem sftp internal-sftp Match Group sftp ChrootDirectory /mydata ForceCommand internal-sftp AllowTcpForwarding no X11Forwarding no 配置文件权限(至少为755权限) chown root:sftp /mydata chmod 755 /mydata chown mysftp:sftp /mydata/uploads chmod 755 /mydata/uploads ...

2018年12月8日 · 1 分钟 · 天边的星星

新时期的Node.js入门总结

基础汇总 require引用的文件中不要有内部调用,否则可能有未知隐患(内存泄漏、或者直接崩溃) Buffer 是Node特有的数据类型(固有属性、不需要require),主要用来处理二进制数据(Buffer通常表现为十六进制的字符串),新Node API Buffer()方法为Deprecated,推荐使用Buffer.form来初始化一个Buffer对象 <blockquote> buffer.toString([encoding],[start],[end]) buffer 支持编码类型 ASCII Base64 Binary Hex UTF-8 UTF-16LE/UCS-2 Buffer一个常用的场景就是HTTP的POST请求,例如 var body = &#8221; req.setEncoding(&#8216;utf-8&#8217;); req.on(&#8216;data&#8217;,function(chumk){ body += chunk; }) req.on(&#8216;end&#8217;,function(){ }) </blockquote> <span class="">Fill System 是Node中使用最为频繁的模块之一,该模块提供了读写文件的能力,是借助于底层的linuv的C++ API实现的。</span> <blockquote contenteditable="true"> 常用API readFile writeFile stat <span class="">fs.stat获取文件的状态(可以用来判断文件还是文件夹)</span> </blockquote> HTTP服务 是Node的核心模块。 <blockquote contenteditable="true"> var http = require(&#8220;http&#8221;) var server = http.createServer(function(req,res){ // req.url 获取访问的路径 //req.method 请求方法 req.on(&#8220;data&#8221;,function(chunk){ }).on(&#8220;end&#8221;,function(){ }); res.writeHead(200,{&#8216;Content-Type&#8217;:&#8217;text/plain&#8217;,&#8221;Content-Length&#8221;:Buffer.byteLength(body)}); res.end(&#8216;Hello Node!!!&#8217;);//每个HTTP请求的最后都会被调用,当客户端的请求完成后,开发者应该调用该方法结束HTTP请求 }); server.on(&#8220;connection&#8221;,function(req,res){ }); server.on(&#8220;request&#8221;,function(req,res){ }) server.listen(3000) //处理异常 process.on(&#8220;uncaughtException&#8221;,function(){ }) // req.headesr 表示head信息 POST上传文件 表单类型设置为: enctype=&#8221;multipart/form-data&#8221; 服务器处理上传文件通常基于stream来实现,这里比较流行的第三方库formidable function dealUpload(req,res){ var form = new formidable.IncomingForm(); <span class="">form.eekpExtension = true;</span> form.uploadDir =__dirname; from.parse(req,function(err,fields.files){ if(err)throw err; console.log(fields); console.log(files); res.writeHead(200,{&#8220;Content-type&#8221;:&#8217;text/plain&#8217;}); <span class="">res.end(&#8216;upload finished&#8217;);</span> <span class="">})</span> } HTTP 客户端服务 var http=require(&#8220;http&#8221;); http.get(&#8220;<span class="md-link" spellcheck="false">[http://www.baidu.com](http://www.baidu.com)</span>&#8220;,function(res){ var statusCode = res.statusCode; if(statusCode==200){ res.on(&#8220;data&#8221;,function(chunk){ }); res.on(&#8220;end&#8221;,function(){ }); res.on(&#8220;error&#8221;,function(e){ <span class="">})</span> <span class="">}</span> }); //代理服务器 var http =require(&#8220;http&#8221;); var url = require(&#8220;url&#8221;); http.createServer(function(req,res){ var url = req.url.substring(1,req.url.length);//去掉最前面的/ var proxyRequest = http.request(url,function(pres){ res.writhHead(pres.statusCode,pres.headers); pres.on(&#8220;data&#8221;,function(data){ <span class="">res.write(data);</span> }); pres.on(&#8220;end&#8221;,function(){ <span class="">res.end();</span> <span class="">})</span> }); req.on(&#8220;data&#8221;,function(data){ <span class="">proxyRequest.write(data);</span> }); req.on(&#8220;end&#8221;,function(){ <span class="">proxyReques.end();</span> <span class="">});</span> <span class="">}).listen(8080);</span> </blockquote> <span class="">WebSocekt (比较出名的WebSocket模块还有Socket.IO)</span> <blockquote contenteditable="true"> Node 实现WebSocket var WebSocketServer = require(&#8220;ws&#8221;).Server; var wss = new WebScoketServer({port:3304}); wss.on(&#8220;connection&#8221;,function(ws){ ws.on(&#8220;message&#8221;,function(message){ <span class="">console.log(message);</span> }); <span class="">ws.send(&#8220;Node Hello WebSocket&#8221;);</span> <span class="">})</span> </blockquote> Events 在Node中只定义了一个类EventEmitter <blockquote contenteditable="true"> var eventEmitter = require(&#8220;events&#8221;); var myEmitter = new eventEmitter(); <span class="">myEmitter.on(&#8220;begin&#8221;,function(){//注册一个begin事件</span> <span class="">console.log(&#8220;begin&#8221;);</span> <span class="">});</span> <span class="">myEmitter.emit(&#8220;begin&#8221;);//触发begin事件</span> </blockquote> 多进程服务 <blockquote contenteditable="true"> child_process模块中包括很多创建子进程的方法,包括fork、spawn、exec、execFile <span class="">Cluster是Node 0.6之后新增模块(Cluster可以看做是做了封装的child_process模块)</span> </blockquote> <span class="">Proces对象是一个全局的对象,每个Node进程都有独立的process对象,该对象中存储了当前的环境变量,也定义了一些事件</span> <blockquote contenteditable="true"> process.getuid();//用户id process.argv;//Node的命令行参数列表 process.pid;//进程id process.cwd();//当前目录 process.versoin;//Node版本 <span class="">process.env;//</span> </blockquote> Timer setTimeout setInterval nvm <blockquote contenteditable="true"> nvm install version 安装某个版本的node nvm use veresion 切换到某个版本 nvm ls 列出当前安装的所有的Node版本 let关键字 会创建一个块级作用域 const变量不可以再被修改 </blockquote> 函数 <blockquote contenteditable="true"> 参数可以设置默认值 function gred(x=&#8221;a&#8221;,y=&#8221;b&#8221;){ } Spread运算符(&#8230;)展开运算符 var ab=[&#8220;ab&#8221;,&#8221;cd&#8221;] gred(..ab); 箭头函数(ES6) var func= a=>a;等价于 var func = function(a){ <span class="">return a;</span> } 多个参数 var func=(a,b)=>{ <span class="">console.log(a,b);</span> <span class="">}</span> </blockquote> Promise 异步处理 <blockquote contenteditable="true"> var promis = new Promise(function(resolve.reject){ //执行相关异步操作 //resolve(data) // reject(err) }),then(res=>{}).catch(err=>{}); <span class="">promise.all 多个promise需要执行封装为一个</span> </blockquote> 回调的终点&#8211;async/await <blockquote contenteditable="true"> node 7.6.0之后原生支持 var asyncReadFile = async function(){ var result1 = await readFile(&#8216;a.txt&#8217;); var result 2 = await readFile(&#8216;b.txt&#8217;); console.log(result1); <span class="">console.log(result2);</span> <span class="">}</span> </blockquote> Koa2 构建web站点 <blockquote contenteditable="true"> koa-static 静态文件服务 koa-router 路由服务 koa-bodyparse </blockquote> MongoDB (Mongoose) <blockquote contenteditable="true"> npm install mongoose var mongoose = require(&#8220;mongoose&#8221;) mongoose.connect(&#8220;mongodb://xxx/test&#8221;); var db = mongose.connection; db.on(&#8220;error&#8221;,console.error.bind(console.&#8217;conection error:&#8217;)) db.on(&#8216;open&#8217;.function(callback){ }) var loginSchema = new mongoose.Schema({ username:String, <span class="">password:String</span> }) <span class="">var login = db.model(&#8220;login&#8221;,loginSchema,&#8221;login&#8221;)//第一个名称是创建实例使用的名称,第二个是表结构参数,第三个是数据库显示的结合的名称不填的话默认是实例名称的复数s</span> var user1 = new login({username:&#8221;zhang&#8221;,password:&#8217;test&#8217;}) user1.save(function(err){ <span class="">if(err) return handleError(err)</span> <span class="">})</span> </blockquote> Redis <blockquote> npm install redis var redis = require(&#8220;redis&#8221;) var client = redis.createClient(&#8216;6379&#8242;,&#8217;127.0.0.1&#8217;) client.on(&#8220;error&#8221;,function(error){ }) client.on(&#8220;ready&#8221;,funciont(){ }) <span class="">client.set(&#8220;name&#8221;,&#8221;zhang&#8221;,redis.print)</span> client.get(&#8220;name&#8221;,function(err,reply){ }) client.publish(&#8216;test&#8217;,&#8221;hello,Node&#8221;) client.subscribe(&#8216;test&#8217;) client.on(&#8220;message&#8221;,function(channel,message){ <span class="">})</span> </blockquote> Localtunnel <blockquote contenteditable="true"> localtunnel是一个有名的第三方模块 localtunnel.me </blockquote> 爬虫 <blockquote contenteditable="true"> robot.txt是爬虫默认规则 PHelper cheerio request.js //node第三方的HTTP请求 <span class="md-link" spellcheck="false">[https://github.com/request/request](https://github.com/request/request)</span> cheerio 网页解析 <span class="md-link" spellcheck="false">[https://github.com/cheeriojs/cheerio](https://github.com/cheeriojs/cheerio)</span> <span class="">selenium</span> MongoDB存储数据 Redis消息队列 </blockquote> 测试与调试 <blockquote contenteditable="true"> 使用Assert模块 Jasmine Ava.js nyc代码覆盖率 Travis <span class="">node-inspector v8-inspector</span> </blockquote> package.json <blockquote contenteditable="true"> package.json常用字段 name项目名称 verion项目版本号 scripts项目不同阶段的命令 version字段说明 version:完全匹配 <span spellcheck="false">`&gt;`</span>version 大于这个版本 <span spellcheck="false">`&gt;=`</span>version 大于登录这个版本 ~version 非常接近这个版本 ^version与这个版本不兼容 1.2.x 这个符号1.2.x的版本 x是任意数字 *或者“” 任何版本都可以 <span class="md-expand">version1-version2 版本在version1和version2之间(包括version1和version2)</span> </blockquote>

2018年11月2日 · 3 分钟 · 天边的星星

Nginx 配置文件服务器下载apk和ipa

在nginx配置文件 mime.types中配置 application/vnd.android.package-archive apk; application/iphone pxl ipa; 这样apk在界面中就可以下载并提示安装 服务器iis支持.apk文件下载的设置 IIS服务器不能下载.apk文件的原因:iis的默认MIME类型中没有.apk文件,所以无法下载。 IIS服务器不能下载.apk文件的解决办法:既然.apk无法下载是因为没有MIME,那么添加一个MIME类型就可以了。 IIS服务器不能下载.apk文件的解决步骤: 打开IIS服务管理器,找到服务器,右键-属性,打开IIS服务属性; 单击MIME类型下的“MIME类型”按钮,打开MIME类型设置窗口; 单击“新建”,建立新的MIME类型; 扩展名中填写“.apk”, MIME类型中填写apk的MIME类型“ application/vnd.android.package-archive ” 单击“确定”保存设置。 重启IIS,使设置生效。 服务器apache支持.apk文件下载的设置 在Apache安装目录下的conf/mime.types文件的对应位置,加上以下一行语句,指定APK文件的MIME类型为 application/vnd.android.package-archive 即可: application/vnd.android.package-archive apk; 重启apache即可 服务器nginx支持.apk文件下载的设置 apk 和 .ipa分别是android应用和ios应用的扩展名。 如果在浏览器下载这些文件为后缀的文件时,会自动重命名为zip文件。 当然可以下载后手动修改后缀,依然可以安装。 如果想下载后缀直接就是apk ipa的,可以修改 /usr/local/nginx/conf目录下的mime.types 增加如下配置,重启nginx生效 application/vnd.android.package-archive apk; application/iphone pxl ipa; 少人做了Android的APP应用且放在了外网上,但是手机用户通过url找到了apk文件却无法实现下载,也或者下载后无法自动安装。针对这样一些问题今天进行了一个技术性的汇总,希望可以帮到那些为此问题烦恼的Android开发者。 写了一些 android 的应用放在网站上让人下载,在某些机型上,三星的 android 的 4.0 以上多款机型最普遍, 用安卓自带浏览器下载程序,会提示 “无法打开文件”,导致下载后不能直安装. 一般性只能采用下面方法解决: 1、用 UC 来下载安装,但这样就要求客户要用 UC 才可下载及安装我们的系统 2、叫用户自己在 android 在桌面上,打开文件夹, 则该 apk 点击时即可安装 问题:某些 android 自带浏览器 , 可能 对下载的 apk 安装进行了限制。 我想通过自己办法,例如修改 apk 或者加某些编译参数,能否解决这种安装的兼容问题 ? 最终人性化的解决方法: (1)、在IIS服务器上,MIME类型中添加一个: 文件扩展名: .apk MIME类型: application/vnd.android.package-archive (2)、服务端部署在tomcat下,已经在tomcat的web.xml里面配置了mini type ...

2017年11月17日 · 1 分钟 · 天边的星星

ProtoBuf.js 使用技巧

Protocol Buffers Protocol buffers 是一个用来序列化结构化数据的技术,支持多种语言诸如 C++、Java 以及 Python 语言,可以使用该技术来持久化数据或者序列化成网络传输的数据。相比较一些其他的 XML 技术而言,该技术的一个明显特点就是更加节省空间(以二进制流存储)、速度更快以及更加灵活。 具体参见 Google 开发文档:https://developers.google.com/protocol-buffers/docs/overview ProtoBuf.js 上面抄的内容不是本文重点,重点是 Google 没有推出官方的 JavaScript 库,在神奇的同性交友社区 Github 上,我找到了一个纯绿色无公害的 ProtoBuf.js 库。它是一个由纯 JavaScript 实现构建在 ByteBuffer.js 之上的 .proto 文件解析库,包含 Message 构建、数据序列化和反序列化等功能。 Google Protocol Buffers 传输的数据是二进制格式,JavaScript 天生不具备处理二进制数据的能力,所以要依赖 ByteBuffer.js ,ByteBuffer 和 ProtoBuf 都是由同一个团队 dcode.io 出品,ByteBuffer 可以单独使用,兼容 IE8+。 .proto 文件 .proto 文件是 Protocol Buffers 的结构化数据定义,结构化数据被称为 Message,具体的就不解释了,可以看最末的两篇参考文章。 ProtoBuf.js 可以解析 .proto,构建 Message 对象,实现数据的序列化和反序列化,对于 .proto 不了解可以看官方文档:https://developers.google.com/protocol-buffers/docs/proto3 下面举几个例子简单说明: .proto文件初始化和构建 Message,例子参见:https://github.com/dcodeIO/ProtoBuf.js/blob/master/examples/websocket/www/index.html ``` 1 2 ``` <td class="code"> <div class="top-box hide"> </div> ``` var builder = ProtoBuf.loadProtoFile("./example.proto"); var Message = builder.build(“Message”); ...

2017年6月25日 · 4 分钟 · 天边的星星