首页 文章 精选 留言 我的

精选列表

搜索[web],共10000篇文章
优秀的个人博客,低调大师

[Spark][python]从 web log 中提取出 UserID 作为key 值,形成新的 RDD

针对RDD, 使用 keyBy 来构筑 key-line 对: [training@localhost ~]$ cat webs.log 56.31.230.188 - 90700 "GET/KDDOC-00101.html HTTP/1.0" 56.32.230.186 - 90700 "GET/contents.css HTTP/1.0" 202.156.27.99 - 25223 "GET /KDDOC-00220.html HTTP/1.0" [training@localhost ~]$ [training@localhost ~]$ hdfs dfs -put webs.log [training@localhost ~]$ [training@localhost ~]$ hdfs dfs -cat webs.log 56.31.230.188 - 90700 "GET/KDDOC-00101.html HTTP/1.0" 56.32.230.186 - 90700 "GET/contents.css HTTP/1.0" 202.156.27.99 - 25223 "GET /KDDOC-00220.html HTTP/1.0" [training@localhost ~]$ [training@localhost ~]$ In [23]: mylogs = sc.textFile("webs.log") In [25]: mylogs001 = mylogs.keyBy(lambda line: line.split(' ')[2]) In [26]: mylogs001.take(1) Out[26]: [(u'90700', u'56.31.230.188 - 90700 "GET/KDDOC-00101.html HTTP/1.0"')] In [28]: mylogs001.take(2) Out[28]: [(u'90700', u'56.31.230.188 - 90700 "GET/KDDOC-00101.html HTTP/1.0"'), (u'90700', u'56.32.230.186 - 90700 "GET/contents.css HTTP/1.0"')] 作一个对比,看看 mylogs001.take(3) 和 mylogs.take(3) In [30]: mylogs001.take(3) Out[30]: [(u'90700', u'56.31.230.188 - 90700 "GET/KDDOC-00101.html HTTP/1.0"'), (u'90700', u'56.32.230.186 - 90700 "GET/contents.css HTTP/1.0"'), (u'25223', u'202.156.27.99 - 25223 "GET /KDDOC-00220.html HTTP/1.0"')] In [31]: mylogs.take(3) Out[31]: [u'56.31.230.188 - 90700 "GET/KDDOC-00101.html HTTP/1.0"', u'56.32.230.186 - 90700 "GET/contents.css HTTP/1.0"', u'202.156.27.99 - 25223 "GET /KDDOC-00220.html HTTP/1.0"'] 本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/p/008-Aggregating-Data-with-Pair-RDDs-keyBy.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

Golang 基于chrome浏览器语音识别web演示系统WebHTK开发之 UI篇

没啥好说的,直接上现阶段的HTML代码,后续修改,再更新该篇博客。 record.html: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 <!DOCTYPE html> <html> <head> <meta charset= "utf-8" /> <meta http-equiv= "X-UA-Compatible" content= "IE=edge" /> <meta name= "viewport" content= "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name= "keywords" content= "PONPON,HTK,Go语言" /> <meta name= "description" content= "基于Beego开发语音识别演示系统" /> <meta name= "generator" content= "PONPON" /> <link href= "/static/css/bootstrap.min.css" rel= "stylesheet" > <link href= "/static/css/docs.css" rel= "stylesheet" > <link href= "http://cdn.bootcss.com/highlight.js/7.3/styles/github.min.css" rel= "stylesheet" > <link rel= "shortcut icon" href= "/static/img/Logoicon.jpg" > <link rel= "stylesheet" href= "http://libs.baidu.com/fontawesome/4.0.3/css/font-awesome.min.css" /> <link rel= "alternate" type= "application/rss+xml" href= "/rss.xml" /> <script type= "text/javascript" src= "/static/lib/recorder.js" > </script> <script type= "text/javascript" src= "/static/lib/jquery-1.10.1.min.js" > </script> <script type= "text/javascript" src= "/static/lib/recController.js" > </script> <title>WebHTK 演示系统</title> </head> <body> <nav id= "header" > <div class= "container960 text-center" > <h3 id= "header-h" class= "center" >闽南语 - 语音识别演示系统</h3> <ul id= "resultbox" class= "center" style= "padding-top:425px;font-size:20px;text-align: center;color:#FFC8B6;font-family:'微软雅黑'" > <li >识别结果</li> </ul> <form style= "padding-top:20px;" > <a id= "img" href= "javascript://" > <img src= "/static/img/aa.png" style= "width:85px;height:85px;" alt= "" /> </a> </form> <div id= "message" style= "padding-top:10px;font-size:16px;color:#F5FFFA;text-align: center;font-family:'微软雅黑'" >点击麦克风,开始录音!</div> <script type= "text/javascript" > var recording = false ; function test() { if (!recording) { document.getElementById( "img" ).innerHTML= "<img src='/static/img/a1.png' style='width:85px;height:85px;'' alt=''/>" ; toRecord(); recording= true ; } else { document.getElementById( "img" ).innerHTML= "<img src='/static/img/aa.png' style='width:85px;height:85px;'' alt=''/>" ; toSend(); recording = false ; } }; function toRecord(){ rec.record(); var dd = ws.send( "start" ); $( "#message" ).text( "再次点击,结束录音!" ); intervalKey = setInterval( function () { rec.exportWAV( function (blob) { rec.clear(); ws.send(blob); }); }, 300); } function toSend(){ rec.stop(); if (intervalKey == null ) { $( "#message" ).text( "请先录音再发送!" ); return }; ws.send(sampleRate); ws.send(channels); ws.send( "stop" ); rec.clear(); clearInterval(intervalKey); intervalKey = null ; } </script> </div> </nav> <audio class= "hide" controls autoplay></audio> </body> </html> recorder.js: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 ( function (window) { var WORKER_PATH = '/static/lib/recorderWorker.js' ; var Recorder = function (source, chan, cfg) { var config = cfg || {}; var channels = chan || 1; var bufferLen = config.bufferLen || 8192; this .context = source.context; this .node = this .context.createJavaScriptNode(bufferLen, channels, channels); var worker = new Worker(config.workerPath || WORKER_PATH); worker.postMessage({ command: 'init' , config: { sampleRate: this .context.sampleRate } }); var recording = false , currCallback; this .node.onaudioprocess = function (e) { if (!recording) return ; worker.postMessage({ command: 'record' , buffer: [ e.inputBuffer.getChannelData(0) ] }); } this .configure = function (cfg) { for ( var prop in cfg) { if (cfg.hasOwnProperty(prop)) { config[prop] = cfg[prop]; } } } this .record = function () { recording = true ; } this .stop = function () { recording = false ; } this .clear = function () { worker.postMessage({ command: 'clear' }); } this .getBuffer = function (cb) { currCallback = cb || config.callback; worker.postMessage({ command: 'getBuffer' }) } this .exportWAV = function (cb, type) { currCallback = cb || config.callback; type = type || config.type || 'audio/wav' ; if (!currCallback) throw new Error( 'Callback not set' ); worker.postMessage({ command: 'exportWAV' , type: type }); } worker.onmessage = function (e) { var blob = e.data; currCallback(blob); } source.connect( this .node); this .node.connect( this .context.destination); }; window.Recorder = Recorder; })(window); recorderWorker.js: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 var recLength = 0, recBuffersL = [], sampleRate; this .onmessage = function (e) { switch (e.data.command) { case 'init' : init(e.data.config); break ; case 'record' : record(e.data.buffer); break ; case 'exportWAV' : exportWAV(e.data.type); break ; case 'getBuffer' : getBuffer(); break ; case 'clear' : clear(); break ; } }; function init(config) { sampleRate = config.sampleRate; } function record(inputBuffer) { recBuffersL.push(inputBuffer[0]); recLength += inputBuffer[0].length; } function exportWAV(type) { var bufferL = mergeBuffers(recBuffersL, recLength); var interleaved = interleave(bufferL); var dataview = encodeWAV(interleaved); var audioBlob = new Blob([dataview], { type: type }); this .postMessage(audioBlob); } function getBuffer() { var buffers = []; buffers.push(mergeBuffers(recBuffersL, recLength)); this .postMessage(buffers); } function clear(inputBuffer) { recLength = 0; recBuffersL = []; } function mergeBuffers(recBuffers, recLength) { var result = new Float32Array(recLength); var offset = 0; for ( var i = 0; i < recBuffers.length; i++) { result.set(recBuffers[i], offset); offset += recBuffers[i].length; } return result; } function interleave(inputL) { var length; var result; var index = 0, inputIndex = 0; if (sampleRate == 48000) { length = inputL.length / 6; result = new Float32Array(length); while (index < length) { result[index++] = (inputL[inputIndex++] + inputL[inputIndex++] + inputL[inputIndex++] + inputL[inputIndex++] + inputL[inputIndex++] + inputL[inputIndex++]) / 6; } } else if (sampleRate == 44100) { length = inputL.length / 6; result = new Float32Array(length); while (index < length) { if (inputIndex % 12 == 0) { result[index++] = (inputL[inputIndex] + inputL[inputIndex++] + inputL[inputIndex++] + inputL[inputIndex++] + inputL[inputIndex++] + inputL[inputIndex++] + inputL[inputIndex++]) / 7; } else { result[index++] = (inputL[inputIndex++] + inputL[inputIndex++] + inputL[inputIndex++] + inputL[inputIndex++] + inputL[inputIndex++] + inputL[inputIndex++]) / 6; }; } } else { length = inputL.length; result = new Float32Array(length); while (index < length) { result[index++] = inputL[inputIndex++]; } }; return result; } function floatTo16BitPCM(output, offset, input) { for ( var i = 0; i < input.length; i++, offset += 2) { var s = Math.max(-1, Math.min(1, input[i])); output.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7FFF, true ); } } function writeString(view, offset, string) { for ( var i = 0; i < string.length; i++) { view.setUint8(offset + i, string.charCodeAt(i)); } } function encodeWAV(samples) { var buffer = new ArrayBuffer(samples.length * 2); var view = new DataView(buffer); floatTo16BitPCM(view, 0, samples); return view; } recController.js: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 var onFail = function (e) { console.log( 'Rejected!' , e); }; var onSuccess = function (s) { var context = new webkitAudioContext(); var mediaStreamSource = context.createMediaStreamSource(s); rec = new Recorder(mediaStreamSource, channels); sampleRate = 8000; } navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; var rec; var intervalKey = null ; var audio = document.querySelector( '#audio' ); var sampleRate; var channels = 1; function startRecording() { if (navigator.getUserMedia) { navigator.getUserMedia({ audio: true }, onSuccess, onFail); } else { console.log( 'navigator.getUserMedia not present' ); } } startRecording(); //-------------------- var ws = new WebSocket( 'ws://' + window.location.host + '/join' ); ws.onopen = function () { console.log( "Openened connection to websocket" ); }; ws.onclose = function () { console.log( "Close connection to websocket" ); } ws.onerror = function () { console.log( "Cannot connection to websocket" ); } ws.onmessage = function (result) { var data = JSON.parse(result.data); console.log( '识别结果:' + data.Pinyin); var result = document.getElementById( "resultbox" ) result.getElementsByTagName( "li" )[0].innerHTML = data.Hanzi; document.getElementById( "message" ).innerHTML = "点击麦克风,开始录音!" ; } 进入页面: 正在录音: 识别结果,目前还为将拼音转换为汉字,下图为“点亮星光”的显示结果图: 本文转自 ponpon_ 51CTO博客,原文链接:http://blog.51cto.com/liuxp0827/1367846,如需转载请自行联系原作者

优秀的个人博客,低调大师

Eclipse下Maven新建项目、自动打依赖jar包(包含普通项目和Web项目)

当我们无法从本地仓库找到需要的构件的时候,就会从远程仓库下载构件至本地仓库。一般地,对于每个人来说,书房只有一个,但外面的书店有很多,类似第,对于Maven来说,每个用户只有一个本地仓库,但可以配置访问很多远程仓库。 Eclipse *版本 Eclipse *下载 强烈推荐书籍:Maven实战 许晓斌著。目前是第一版 注意:最新版本的Eclipse代号Mars,已经直接集成了Maven,所以无需安装m2Eclipse插件。 Eclipse下新建Maven项目 1、下载Maven安装包 进入Maven官网的下载页面:http://maven.apache.org/download.cgi,如下图所示: 选择当前最新版本:"apache-maven-3.3.9-bin.zip",下载到本地,解压缩到本地磁盘下。 2、配置 2.1 环境变量的配置 2.2 修改默认的本地仓库位置 进入Maven安装目录下的conf子目录中,打开settings.xml进行配置修改。 <!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repository <localRepository>/path/to/local/repo</localRepository> --> <localRepository>D:/SoftWare/maven/repository</localRepository> Maven默认的本地仓库位置是当前用户工作目录下的".m2/repository",使用过程中这个目录里的文件会比较多,占用空间越来越大。一般建议更换到其它磁盘目录下。如下配置,就把默认的本地仓库更改到自己创建的目录。 如下图所示的localRepository标签中设置,就把默认的本地仓库更改到D:/SoftWare/maven/repository这个目录(这个目录结构需要自己创建好)。 2.3修改默认的中央仓库镜像 Maven默认的中央仓库里的文件不全。所以,都需要自行添加其它的镜像地址。在settings.xml文件中的“<mirrors>”标签里添加如下内容: 其实,是如下 http://mirrors.ibiblio.org/maven2/ 注意啦!有时候,上面这样配置,不稳定,我这里给大家分享一个稳定的setting.xml !!!(优先) <?xml version="1.0" encoding="UTF-8"?> <!--Licensed to the Apache Software Foundation (ASF) under oneor more contributor license agreements. See the NOTICE filedistributed with this work for additional informationregarding copyright ownership. The ASF licenses this fileto you under the Apache License, Version 2.0 (the"License"); you may not use this file except in compliancewith the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing,software distributed under the License is distributed on an"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANYKIND, either express or implied. See the License for thespecific language governing permissions and limitationsunder the License.--> <!--| This is the configuration file for Maven. It can be specified at two levels:|| 1. User Level. This settings.xml file provides configuration for a single user,| and is normally provided in ${user.home}/.m2/settings.xml.|| NOTE: This location can be overridden with the CLI option:|| -s /path/to/user/settings.xml|| 2. Global Level. This settings.xml file provides configuration for all Maven| users on a machine (assuming they're all using the same Maven| installation). It's normally provided in| ${maven.home}/conf/settings.xml.|| NOTE: This location can be overridden with the CLI option:|| -gs /path/to/global/settings.xml|| The sections in this sample file are intended to give you a running start at| getting the most out of your Maven installation. Where appropriate, the default| values (values used when the setting is not specified) are provided.||--><settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"><!-- localRepository| The path to the local repository maven will use to store artifacts.|| Default: ${user.home}/.m2/repository<localRepository>/path/to/local/repo</localRepository>--> <localRepository>D:/SoftWare/maven/repository</localRepository><!-- interactiveMode| This will determine whether maven prompts you when it needs input. If set to false,| maven will use a sensible default value, perhaps based on some other setting, for| the parameter in question.|| Default: true<interactiveMode>true</interactiveMode>--> <!-- offline| Determines whether maven should attempt to connect to the network when executing a build.| This will have an effect on artifact downloads, artifact deployment, and others.|| Default: false<offline>false</offline>--> <!-- pluginGroups| This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.| when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers| "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.|--><pluginGroups><!-- pluginGroup| Specifies a further group identifier to use for plugin lookup.<pluginGroup>com.your.plugins</pluginGroup>--></pluginGroups> <!-- proxies| This is a list of proxies which can be used on this machine to connect to the network.| Unless otherwise specified (by system property or command-line switch), the first proxy| specification in this list marked as active will be used.|--><proxies><!-- proxy| Specification for one proxy, to be used in connecting to the network.|<proxy><id>optional</id><active>true</active><protocol>http</protocol><username>proxyuser</username><password>proxypass</password><host>proxy.host.net</host><port>80</port><nonProxyHosts>local.net|some.host.com</nonProxyHosts></proxy>--></proxies> <!-- servers| This is a list of authentication profiles, keyed by the server-id used within the system.| Authentication profiles can be used whenever maven must make a connection to a remote server.|--><servers><!-- server| Specifies the authentication information to use when connecting to a particular server, identified by| a unique name within the system (referred to by the 'id' attribute below).|| NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are| used together.|<server><id>deploymentRepo</id><username>repouser</username><password>repopwd</password></server>--> <!-- Another sample, using keys to authenticate.<server><id>siteServer</id><privateKey>/path/to/private/key</privateKey><passphrase>optional; leave empty if not used.</passphrase></server>--></servers> <!-- mirrors| This is a list of mirrors to be used in downloading artifacts from remote repositories.|| It works like this: a POM may declare a repository to use in resolving certain artifacts.| However, this repository may have problems with heavy traffic at times, so people have mirrored| it to several places.|| That repository definition will have a unique id, so we can create a mirror reference for that| repository, to be used as an alternate download site. The mirror site will be the preferred| server for that repository.|--><mirrors><!-- mirror| Specifies a repository mirror site to use instead of a given repository. The repository that| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.|<mirror><id>mirrorId</id><mirrorOf>repositoryId</mirrorOf><name>Human Readable Name for this Mirror.</name><url>http://my.repository.com/repo/path</url></mirror>--><mirror><id>osc</id><mirrorOf>central</mirrorOf><url>http://maven.aliyun.com/nexus/content/repositories/central</url></mirror><mirror><id>osc_thirdparty</id><mirrorOf>thirdparty</mirrorOf><url>http://maven.aliyun.com/nexus/content/repositories/central</url></mirror></mirrors> <!-- profiles| This is a list of profiles which can be activated in a variety of ways, and which can modify| the build process. Profiles provided in the settings.xml are intended to provide local machine-| specific paths and repository locations which allow the build to work in the local environment.|| For example, if you have an integration testing plugin - like cactus - that needs to know where| your Tomcat instance is installed, you can provide a variable here such that the variable is| dereferenced during the build process to configure the cactus plugin.|| As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles| section of this document (settings.xml) - will be discussed later. Another way essentially| relies on the detection of a system property, either matching a particular value for the property,| or merely testing its existence. Profiles can also be activated by JDK version prefix, where a| value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.| Finally, the list of active profiles can be specified directly from the command line.|| NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact| repositories, plugin repositories, and free-form properties to be used as configuration| variables for plugins in the POM.||--><profiles><!-- profile| Specifies a set of introductions to the build process, to be activated using one or more of the| mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>| or the command line, profiles have to have an ID that is unique.|| An encouraged best practice for profile identification is to use a consistent naming convention| for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.| This will make it more intuitive to understand what the set of introduced profiles is attempting| to accomplish, particularly when you only have a list of profile id's for debug.|| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.<profile><id>jdk-1.4</id> <activation><jdk>1.4</jdk></activation> <repositories><repository><id>jdk14</id><name>Repository for JDK 1.4 builds</name><url>http://www.myhost.com/maven/jdk14</url><layout>default</layout><snapshotPolicy>always</snapshotPolicy></repository></repositories></profile>--> <!--| Here is another profile, activated by the system property 'target-env' with a value of 'dev',| which provides a specific path to the Tomcat instance. To use this, your plugin configuration| might hypothetically look like:|| ...| <plugin>| <groupId>org.myco.myplugins</groupId>| <artifactId>myplugin</artifactId>|| <configuration>| <tomcatLocation>${tomcatPath}</tomcatLocation>| </configuration>| </plugin>| ...|| NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to| anything, you could just leave off the <value/> inside the activation-property.|<profile><id>env-dev</id> <activation><property><name>target-env</name><value>dev</value></property></activation> <properties><tomcatPath>/path/to/tomcat/instance</tomcatPath></properties></profile>--><profile><id>jdk-1.4</id><activation><jdk>1.4</jdk></activation><repositories> <repository><id>nexus</id><name>local private nexus</name><url>http://maven.aliyun.com/nexus/content/repositories/central</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></repository></repositories><pluginRepositories> <pluginRepository><id>nexus</id><name>local private nexus</name><url>http://maven.aliyun.com/nexus/content/repositories/central</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></pluginRepository></pluginRepositories></profile><profile><id>osc</id><activation><activeByDefault>true</activeByDefault></activation><repositories><repository><id>osc</id><url>http://maven.aliyun.com/nexus/content/repositories/central</url></repository><repository><id>osc_thirdparty</id><url>http://maven.aliyun.com/nexus/content/repositories/central</url></repository></repositories><pluginRepositories><pluginRepository><id>osc</id><url>http://maven.aliyun.com/nexus/content/repositories/central</url></pluginRepository> </pluginRepositories></profile></profiles> <!-- activeProfiles| List of profiles that are active for all builds.|<activeProfiles><activeProfile>alwaysActiveProfile</activeProfile><activeProfile>anotherAlwaysActiveProfile</activeProfile></activeProfiles>--></settings> 保存所做的修改,同时还需要把这个settings.xml文件复制一份到“D:\SoftWare\maven”目录下。 3、eclipse里的Maven插件安装 Eclipse默认不支持Maven。需要给它添加m2eclipse插件。下面是具体的操作步骤。 3.1、插件安装 打开Eclipse的Help->Install New Software,如下图所示: 选择“Add..”按钮,又会弹出如下对话框: 这个对话框就是用于添加一个插件地址的。在“Name”对应的输入框里输入该操作的一个标识名。在“Location”对应的输入框里输入这个插件的安装地址。注:Maven的Eclipse插件地址为:http://download.eclipse.org/technology/m2e/releases。输入后,如下图所示: Name: m2e Location: http://download.eclipse.org/technology/m2e/releases 输入完成后,点击右下角的“OK”按钮,就会弹出如下对话框: MARS版本 我这里,就,已经安装过了。 这一步,有可能会 注意:安装maven时一定要注意版本匹配问题:下面就是我安装时遇到的问题 首先安装maven时遇到Missing requirement: m2e logback configuration 1.7.0.20160603-1933 (org.eclipse.m2e.logback.configur。。。的问题。 这是由于eclipse和maven插件版本不匹配,我的eclipse版本为如下,只能安装m2e -http://download.eclipse.org/technology/m2e/releases/1.3的版本,高版本就报错 推荐用MARS版本!!! 注意,有些版本,我已测试过,如,NEON版本 会发生上述的错误。 这里需要选择想要安装的插件的详细内容。选中“Maven Integration for Eclipse”前面的复选框。如下图所示: 选择完成后,点击右下方的“Next>”按钮进行安装。安装成功后,会提示需要重启Eclipse来生效这次配置。重启之后,这个Eclipse就可以使用m2eclipse插件功能了。 需要一段时间 自动重启 3.2、Eclipse下对maven进行配置 插件安装好之后,还需要进行一些配置才能够开始使用Maven的功能。 3.2.1、设置m2eclipse插件所关联的Maven程序 需要修改配置:首先选择Window->Preferences,弹出如下对话框 在这个对话框左边的导航栏中展开“Maven”目录结点,并选择“Installations”子节点,如下图所示: 这里需要关联上对应的Maven安装程序。具体操作是,在右边面板中选择“Add…”按钮,会弹出如下选择Maven安装目录的选择对话框: 通过这个对话框来选择Maven的具体安装目录。选择好之后就点击“确定”按钮。如下图所示: 3.2.2、设置自定义的本地仓库 选择如上图对话窗口左边菜单树 “Maven”节点下的“UserSettings”子节点,它默认的配置文件是“C:\Documents and Settings\csdn\.m2\settings.xml”,如下图所示: 这边需要修改为我们自定义仓库位置下的settings.xml文件。具体操作是,点击“Browse…”按钮来选择上一步骤修改的本地仓库目录下的settings.xml文件,如下图所示: 在上图中选择D:\SoftWare\apache-maven-3.3.9\conf目录下的“settings.xml”文件,点击“打开”按钮来确认刚才的选择,就会回到如下图的对话窗口中: 在上图中点击右下角的“OK”按钮来完成所有的配置修改。 4、Eclipse创建maven项目 在eclipse菜单栏中选择"File"->"News"->"Other"菜单项,就会打开如下对话窗口,在窗口中选择"Maven"节点下"Maven Project"条目,如下图所示,之后跟着下一步。。。就可以将项目创建好了。 我这里,选择other 想说的是,SBT是为scala专门而设计的,但是,一般很多人还是用的是maven。 使用maven-archetype-quickstart 或者 coccoon-22-archetype-webapp 或者 也许,这一步,会碰到如下问题。 解决办法: 或者 Catalog File: http://repo2.maven.org/maven2/archetype-catalog.xml Description: maven catalog 然后,再重新 File -> New -> Maven Project 这里,自己任意取, Group Id: com.zhouls.spark Artifact Id: SparkApps CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:3.1: UnresolvableModelException: Failure to transfer org.apache.maven.plugins:maven-plugins:pom:24 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-plugins:pom:24 from/to central (https://repo.maven.apache.org/maven2): timeout 解决方法: 1.找到maven库目录,进入:D:\SoftWare\maven\repository\org\apache\maven\plugins\maven-compiler-plugin\3.1 2. 若3.1这个目录下只有,"maven-compiler-plugin-3.1.pom.lastUpdated" 则需要到http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.1/,把里面的文件下载下来放到目录3.1下,如果该仓库中没有,那么可以去http://search.maven.org/这个地方下载下来,然后放置到对应的本地仓库中 可见,我这里是不需进行步骤2,直接到步骤3. 3.删除3.1下的maven-compiler-plugin-3.1.pom.lastUpdated文件或3.1目录下的所有文件 4.项目右键-->maven-->Update Dependencies 即,得到解决! 如果以上方法还是无法解决该问题:则打开settings.xml,尝试换个mirror镜像或者干脆采用默认的仓库,即注释掉 删除清空 再重新来一次 这里,我继续,上面的步骤,下来。用了我那个稳定的setting.xml文件,之后,中间不会出现什么问题!!! 把此处默认的jdk,J2SE-1.5,变成我们自己安装的jdk版本(jdk1.7或jdk1.8) 得到 对应,得到 这个pom.xml文件,里有我们工程实际时编写和运行时的依赖和支持。 进入,如下 选择,pom.xml 在修改pom.xml文件之前,Maven Dependencies如下 创建项目之后,pom.xml默认的内容如下 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.zhouls.spark</groupId> <artifactId>SparkApps</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>SparkApps</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project> 这一步,最为关键,具体怎么修改pom.xml,是要看自己的需求。 http://mvnrepository.com/ 我这里,因为是spark1.5.2版本。 其他的,类似,这里不多赘述。 转】maven核心,pom.xml详解 在这过程中,最好是去复制,官网。为了避免自己手误或者格式不对!!!可以避免如下面的错误! 修改后的pom.xml内容是 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.zhouls.spark</groupId> <artifactId>SparkApps</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>SparkApps</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <junit.version>4.10</junit.version> <spark.version>1.5.2</spark.version> <hadoop.version>2.6.0</hadoop.version> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-core_2.10</artifactId> <version>${spark.version}</version> </dependency> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-sql_2.10</artifactId> <version>${spark.version}</version> </dependency> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-hive_2.10</artifactId> <version>${spark.version}</version> </dependency> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-streaming_2.10</artifactId> <version>${spark.version}</version> </dependency> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-streaming-kafka_2.10</artifactId> <version>${spark.version}</version> </dependency> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-client</artifactId> <version>${hadoop.version}</version> </dependency> </dependencies> <build> <sourceDirectory>src/main/java</sourceDirectory> <testSourceDirectory>src/main/test</testSourceDirectory> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <mainClass></mainClass> </manifest> </archive> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <goals> <goal>exec</goal> </goals> </execution> </executions> <configuration> <executable>java</executable> <includeProjectDependencies>true</includeProjectDependencies> <includePluginDependencies>false</includePluginDependencies> <classpathScope>compile</classpathScope> <mainClass>com.zhouls.spark.SparkApps.cores.WordCount</mainClass> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> </project> 正在下载 立马生成好了。可见,Maven自动生成jar包,多么的方便! 其他的一一去解决! 对应地,生成, 我的这里,得到如下 至此,Eclipse下新建Maven项目、自动打依赖jar包。大功告成!!! Eclipse里创建Maven,比较有价值的错误总结 http://blog.csdn.net/afgasdg/article/details/12757433 http://blog.csdn.net/sunnylinner/article/details/52183156 http://www.cnblogs.com/liaojie970/p/5509760.html http://www.cnblogs.com/tenghoo/p/maven_error.html 感谢如下博主: http://www.cnblogs.com/ljdblog/p/5840858.html http://blog.csdn.net/qjyong/article/details/9098213 http://dead-knight.iteye.com/blog/1910783 关于Maven的进一步,深入学习,推荐 本文转自大数据躺过的坑博客园博客,原文链接:http://www.cnblogs.com/zlslch/p/5882567.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

我的第一个python web开发框架(19)——产品发布相关事项

好不容易小白将系统开发完成,对于发布到服务器端并没有什么经验,于是在下班后又找到老菜。 小白:老大,不好意思又要麻烦你了,项目已经弄完,但要发布上线我还一头雾水,有空帮我讲解一下吗? 老菜:嗯,系统上线并不一件简单的事情,它可大可小。如果准备不充分,有可能会很多问题出现。你认为写好代码后要怎么发布? 小白:呃,完成开发后,上传到服务器,然后浏览器可以正常访问... 老菜:看来得普及一下上线的相关知识才行。 正规的产品上线一般可以按下面几个步骤来进行: 1. 开发人员自测(开发环境) 2. 测试人员测试(测试环境上) 3. 预生产环境测试 4. 生产环境测试 但根据我所接触的众多公司来看,没有测试人员的公司就占了多数,各公司的BOSS们甚至技术负责人都没有测试的意识,将产品测试交给开发人员或业务人员进行,其产生的后果怎么样就不得而知了。往小方面说用户体验不好,往大方面说可能更新后造成数据丢失,生产环境停机一段时间的情况。 对于开发人员自测,很多程序员都没有这个习惯,多数都是写完代码,自己以为肯定没有问题,然后往服务器上一扔就完事了,等其他同事或客户使用时进行测试,很多时候会出现500或各种bug,问起来都是因为粗心、没注意到或不小心造成的,有时等得到反馈时已经过上好长一段时间了,系统挂了多久都不知道。以前所在公司就遇过有技术人员一个小问题用了超长时间才开发出来,提交了不知多少次到测试环境都不通过,bug反复出现,被测试经理骂的狗血淋头的情况,我在旁边看着都差点忍不住上去怼上一份。可以看得出来,没有自测也是造成测试与开发矛盾的重要原因之一。 当然包括我在内,以前也没有养成自测的习惯,没有测试人员的约束,写好代码就往生产环境上扔,出现故障就在生产环境上调测或还原代码,再慢慢改的情况。以前也以为有没有测试都无所谓,最近几年一直待在有测试团队的公司里就不一样的,有了约束以后,虽然更新效率和速度打大折扣,但代码质量和稳定得到了飞跃性的提升。平时码代码也会习惯性完成后用各种参数跑一下,而使用测试的思维去写代码以后,代码的安全性、严谨性得到了很大的提升。 自测它是一种态度,它也是一种习惯。 一般有测试岗位的公司,都会创建一套测试环境专门给测试人员来进行测试,因为测试与开发共用一个环境时,数据很多时候就会造成混乱,其中一方辛辛苦苦建的数据,另一方拿来就用,又或者技术人员习惯直接打开数据库改数据,某些数据状态突然改变了,而测试人员以为是bug,造成不必要的困扰。一般来说,开发人员在开发环境上自测没有问题以后,才会将代码打包提交给测试人员更新到测试环境上。这个更新频率一般都在固定时间,而不是非常频繁,除非有重大bug测试人员无法继续下去,因为每一个版本的更新,测试人员都会从头到尾,按写好的测试用例全部重新跑一次,频繁的更新会造成测试人员工作量非常大。 测试前,标准来说测试人员一般分制定测试规范,做好测试计划和写测试用例,测试阶段会分为功能测试(可能会有功能1、功能2、功能3等多次测试)、UI测试、兼容性测试、性能测试、安全性测、UAT测试等,完成后会提交一份测试报告。不过很多时候测试规范、计划和报告都会被省略了,测试用例有时也可能会被略过,每家公司根据自己的需要也会进行对应的调整。 专业的测试是一个枯燥、重复、非常有耐心且敬业的职位,也是我很佩服的一个岗位。 很多公司产品开发完后是直接上线的,并没有预生产环境进行测试,好多一些重大的安全事故就是这样造成的。比如说没留意sql语句,不小心将生产环境的数据表给清空了;比如说更新后生产环境直接崩溃等情况在工作中时有发生。今年我在的公司也试过发生比较严重的问题,合作公司的小伙伴开发时代码循环写错了,没有经过全面测试就直接发布,APP发版后造成我方生产环境业务接口访问量暴增,短短几天访问量暴涨到6千万,服务器流量、CPU、内存等全部满负荷运行,影响到了其他合作公司业务的正常运行,由于生产环境不能停,服务器端只能通过快速扩容服务器组为高可用群组解决,客户端通过快速发布新版替换。 如果服务器并不是太多的影响下,通常预生产环境和生产环境放在一个服务器里,它只是一个数据库与程序的拷贝。条件充足时,会在本地搭建一个和生产环境一模一样的环境,来做发布前测试。预生产环境测试,可以帮我们避开很多服务器环境因素(配置或包不一致等情况)、数据库结构或配置因素(数据库结构调整未更新或记录参数改变后未同步等情况)和sql语句缺陷等问题造成的重大错误。 对于重大版本或变更更新时,预生产环境测试是有严格的更新步骤要求的。在整个预发布测试过程中,必须实时记录下每一个步骤的操作。对于重大更新,下面的步骤有时可能需要反复操作多次,这样才能保障更新到生产环境是完全无误的。 1)本地测试环境上测试通过,准备好更新代码包、数据库更新脚本、服务器配置更新脚本和修改说明文档; 2)清空预生产测试旧的数据库与程序(对于小版本更新可以直接在旧环境上进行,不必做这一步操作;另外如果数据库数据量比较大时,可继续使用旧环境数据); 3)备份预生产测试环境里的代码、数据库与相关配置文件; 4)获取生产环境中的代码、数据库与相关配置文件,并将它们更新到预生产测试环境中,搭建好可以正常运行; 5)开始发布,新服务器配置文件; 6)更新数据库脚本; 7)更新代码包; 8)运行前后端程序,进行全面测试(所有功能都必须跑过一次),检查程序是否可以正常运行; 9)如果此次更新不会对原系统产生破坏性变更,程序正常后就可以按预发布部署到生产环境上。 10)如果需要录入或变更相关配置数据,可以让相关维护人员登陆操作录入或修改内容,并测试通过; 11)导出维护人员录入的数据脚本; 12)再次还原生产环境的代码、数据库与相关配置文件到预生产测试环境中; 13)执行第5步到第7步的操作,并将第11步导出的数据脚本更新到数据库中; 14)执行第8步操作,确认没有问题后,发布到生产环境中。 正常来说,更新到生产环境的代码是测试过没有问题的,但有可能有些功能只能在生产环境上才能进行测试,所以一般发布都会选一个晚深人夜,没有什么客户使用时来进行的。更新以后需要快速进行测试,保证系统上线后运行正常没有问题。 常见的更新是热更新,即直接上传更新;也有使用svn等自动化工具进行同步更新,更新完成后,svn的勾子自动将代码同步到其他服务器上,并重启指的服务;还可以关闭高可用其中一个对外访问的节点来更新测试,等这个节点内部测试没有问题,再自动同步到其他节点上;如果是微服务架构,还可以使用微服务自动安装发布,自动同步注册更新的功能......不同的企业,服务架构不一样,更新的步骤与方式也不同。 前面的内容听起来好像有点复杂,有点多,不过对于你这个小站点来说,就不用那么操作了。你首先要做的是购买好域名,做好域名备案相关工作;然后购买一台云服务器,按我博客里的教程安装配置好服务器;最后将你的代码发布到服务器上去就可以了。 你按下面链接去搭建的话,你的程序大体上运行不会出现什么问题,下面配置是bate版的服务器环境搭建,是我研究运维配置好的服务器自己学习后写的,配置好后能正常的访问不会有太大的问题。如果想要应对高并发,需要在这个基础上进行调优处理,另外uwsgi最好使用xml配置,因为xml和ini所使用的包是不一样的,运行时效率和稳定性相差比较大,我们服务器处理每秒7百多并发就是使用xml配置的。 python服务器环境搭建(1)——本地服务器准备 python服务器环境搭建(2)——安装相关软件 python服务器环境搭建(3)——参数配置 本文转自 AllEmpty 博客园博客,原文链接:http://www.cnblogs.com/EmptyFS/p/8149856.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

《Web安全之机器学习入门》一 1.4 人工智能在安全领域的应用

1.4 人工智能在安全领域的应用 人工智能在安全领域的应用还属于起步阶段,各大安全公司以及互联网巨头都投入大量的人力物力,试图使用人工智能的技术来颠覆安全这个行业,目前在黄反鉴定、恶意链接、业务风控领域、病毒分析、APT检测方面都取得了不错的进展,典型案例的就是2015年的一次数据挖掘比赛。2015年,微软在Kaggle上发起了一个恶意代码分类的比赛,并提供了超过500G的原始数据。有意思的是,取得第一名的队伍三个人都不是搞安全出身的,所采用的方法与我们常见的方法存在很大不同,展现了机器学习在安全领域的巨大潜力。早期的反病毒软件大都单一的采用特征匹配的方法,简单的利用特征串完成检测。随着恶意代码技术的发展,恶意代码开始在传播过程中进行变形以躲避查杀,此时同一个恶意代码的变种数量急剧提升,形态较本体也发生了较大的变化,反病毒软件已经很

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册
修改密码
忘记密码