首页 文章 精选 留言 我的

精选列表

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

Cordova 实现热更新

文章来源 http://blog.csdn.net/zhuzhiqiang_zhu/article/details/53608398 一、添加插件 说明:在这个步骤里面,以下的命令需要在项目根目录下执行 ● 新建Cordova项目 ○ cordova create CordovaHotCode com.ezample.hotcode ● 添加android平台 ○ cordova platform add android ● 添加iOS平台 ○ cordova platform add ios ● 添加自动更新插件 ○ cordova plugin add cordova-hot-code-push-plugin ● 添加cordova hot code push客户端,用于生成www目录下文件的hash码,更新的时候对比使用。(注意:安装过就不用在安装了) ○ npm install -g cordova-hot-code-push-cli 二、配置 修改config.xml ○ iOS工程的地址 config.xml的路径是:projectName/platforms/ios/projectName/config.xml 其中 projectName 是我们创建的工程名称 ○ Android工程的地址是 projectName/platforms/android/res/xml/config.xml 修改内容如图: 417114801036.png //代码为 <chcp> <auto-download enabled="true" /> <auto-install enabled="true" /> <config-file url="http://172.16.1.245:8080/cordova-hot-update/cordova/www/chcp.json" /> </chcp> 转移项目根目录下的www目录里的内容 ○ ios平台 将www里面的内容拷贝到 projectName/platforms/ios/projectName/www ○ Android平台 将www里面的内容拷贝到 projectName/platforms/android/assets/www 为了chcp.json文件生成的方便,我们需要在项目的根目录下新建一个文件cordova-hcp.json,内容为: { "update": "start", "content_url": "http://192.168.40.203:8080/cordova/www" } 上面执行完之后,可以将项目导入到android studio中或者直接在根目录执行cordova build,然后在CordovaHotCode\platforms\android\build\outputs\apk这个目录下生成了apk文件,直接安装就行。 三、服务器端配置 服务器端就比较简单了,我们修改项目根目录下的www目录之后,在根目录下执行cordova-hcp build. 直接把根目录下的www目录拷贝到服务器中,注意地址不要写错。然后启动我们的app,第一次启动的时候检查更新并下载更新,第二次启动的时候就会使用更新的版本。 213130800190.png

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

php实现文件上传

存档: upload1.html(单文件上传) 1 <html> 2 <head> 3 <title>单个文件上传</title> 4 </head> 5 <body> 6 <form action="upload.php" method="post" enctype="multipart/form-data"> 7 <input type="hidden" name="MAX_FILE_SIZE" value="1000000"> 8 选择文件:<input type="file" name="myfile"> 9 <input type="submit" value="上传文件"> 10 </form> 11 </body> 12 </html> upload2.html(多文件上传) 1 <html> 2 <head> 3 <title>多文件上传</title> 4 </head> 5 <body> 6 <form action="upload.php" method="post" enctype="multipart/form-data"> 7 <input type="hidden" name="MAX_FILE_SIZE" value="1000000"> 8 选择文件1:<input type="file" name="myfile[]"><br> 9 选择文件2:<input type="file" name="myfile[]"><br> 10 选择文件3:<input type="file" name="myfile[]"><br> 11 <input type="submit" value="上传文件"> 12 </form> 13 </body> 14 </html> upload.php 1 <?php 2 require "fileupload.class.php"; 3 $up=new FileUpload; 4 $up ->set('path','./newpath/') 5 ->set('size',1000000) 6 ->set('allowtype',array('gif','jpg','png')) 7 ->set('israndname',false); 8 if($up->upload('myfile')){ 9 print_r($up->getFileName()); 10 } 11 else{ 12 print_r($up->getErrorMsg()); 13 } 14 ?> fileupload.class.php 1 <?php 2 class FileUpload{ 3 private $path="./uploads"; 4 private $allowtype=array('jpg','gif','png'); 5 private $maxsize=1000000; 6 private $israndname=true; 7 private $originName; 8 private $tmpFileName; 9 private $fileType; 10 private $fileSize; 11 private $newFileName; 12 private $errorNum=0; 13 private $errorMess=""; 14 15 function set($key,$val){ 16 $key=strtolower($key); 17 if(array_key_exists($key,get_class_vars(get_class($this)))){ 18 $this->setOption($key,$val); 19 } 20 return $this; 21 } 22 23 function upload($fileField){ 24 $return=true; 25 if(!$this->checkFilePath()){ 26 $this->errorMess=$this->getError(); 27 return false; 28 } 29 $name=$_FILES[$fileField]['name']; 30 $tmp_name=$_FILES[$fileField]['tmp_name']; 31 $size=$_FILES[$fileField]['size']; 32 $error=$_FILES[$fileField]['error']; 33 if(is_Array($name)){ 34 $errors=array(); 35 for($i=0;$i<count($name);$i++){ 36 if($this->setFiles($name[$i],$tmp_name[$i],$size[$i],$error[$i])){ 37 if(!$this->checkFileSize()||!$this->checkFileType()){ 38 $errors[]=$this->getError(); 39 $return=false; 40 } 41 } 42 else{ 43 $errors[]=$this->getError(); 44 $return=false; 45 } 46 if(!$return){ 47 $this->setFiles(); 48 } 49 } 50 if($return){ 51 $fileNames=array(); 52 for($i=0;$i<count($name);$i++){ 53 if($this->setFiles($name[$i],$tmp_name[$i],$size[$i],$error[$i])){ 54 $this->setNewFileName(); 55 if(!$this->copyFile()){ 56 $errors[]=$this->getError(); 57 $return=false; 58 } 59 $fileNames[]=$this->newFileName; 60 } 61 } 62 $this->newFileName=$fileNames; 63 } 64 $this->errorMess=$errors; 65 return $return; 66 } 67 else{ 68 if($this->setFiles($name,$tmp_name,$size,$error)){ 69 if($this->checkFileSize()&&$this->checkFileType()){ 70 $this->setNewFileName(); 71 if($this->copyFile()){ 72 return true; 73 } 74 else{ 75 $return=false; 76 } 77 } 78 else{ 79 $return=false; 80 } 81 } 82 else{ 83 $return=false; 84 } 85 if(!$return){ 86 $this->errorMess=$this->getError(); 87 } 88 return $return; 89 } 90 } 91 92 public function getFileName(){ 93 return $this->newFileName; 94 } 95 96 public function getErrorMsg(){ 97 return $this->errorMess; 98 } 99 100 private function getError(){ 101 $str="上传文件<font color='red'>{$this->originName}</font>时出错:"; 102 switch($this->errorNum){ 103 case 4: 104 $str.="没有文件被上传"; 105 break; 106 case 3: 107 $str.="文件只有部分被上传"; 108 break; 109 case 2: 110 $str.="上传的文件大小超过了HTML表单中MAX_FILE_SIZE选项指定的值"; 111 break; 112 case 1: 113 $str.="上传的文件超过了php.ini中的upload_max_filesize选定限制的值"; 114 break; 115 case -1: 116 $str.="未允许类型"; 117 break; 118 case -2: 119 $str.="文件过大,上传的文件不能超过{$this->maxsize}个字节"; 120 break; 121 case -3: 122 $str.="上传失败"; 123 break; 124 case -4: 125 $str.="建立存放上传文件目录失败,请重新指定上传目录"; 126 break; 127 case -5: 128 $str.="必须指定上传文件的路径"; 129 break; 130 default: 131 $str.="未知错误"; 132 //break; 133 } 134 return $str.'<br>'; 135 } 136 137 private function setFiles($name="",$tmp_name="",$size=0,$error=0){ 138 $this->setOption('errorNum',$error); 139 if($error){ 140 return false; 141 } 142 $this->setOption('originName',$name); 143 $this->setOption('tmpFileName',$tmp_name); 144 $aryStr=explode(".",$name); 145 $this->setOption('fileType',strtolower($aryStr[count($aryStr)-1])); 146 $this->setOption('fileSize',$size); 147 return true; 148 } 149 150 private function setOption($key,$val){ 151 $this->$key=$val; 152 } 153 154 private function setNewFileName(){ 155 if($this->israndname){ 156 $this->setOption('newFileName',$this->proRandName()); 157 } 158 else{ 159 $this->setOption('newFileName',$this->originName); 160 } 161 } 162 163 private function checkFileType(){ 164 if(in_array(strtolower($this->fileType),$this->allowtype)){ 165 return true; 166 } 167 else{ 168 $this->setOption('errorNum',-1); 169 return false; 170 } 171 } 172 173 private function checkFileSize(){ 174 if($this->fileSize>$this->maxsize){ 175 $this->setOption('errorNum',-2); 176 return false; 177 } 178 else{ 179 return true; 180 } 181 } 182 183 private function checkFilePath(){ 184 if(empty($this->path)){ 185 $this->setOption('errorNum',-5); 186 return false; 187 } 188 if(!file_exists($this->path)||!is_writable($this->path)){ 189 if(!@mkdir($this->path,0755)){ 190 $this->setOption('errorNum',-4); 191 return false; 192 } 193 } 194 return true; 195 } 196 197 private function proRandName(){ 198 $fileName = date('YmdHis')."_".rand(100,999); 199 return $fileName.'.'.$this->fileType; 200 } 201 202 private function copyFile(){ 203 if(!$this->errorNum){ 204 $path=rtrim($this->path,'/').'/'; 205 $path.=$this->newFileName; 206 if(@move_uploaded_file($this->tmpFileName,$path)){ 207 return true; 208 } 209 else{ 210 $this->setOption('errorNum',-3); 211 return false; 212 } 213 } 214 else{ 215 return false; 216 } 217 } 218 } 219 ?> 结果如下: 您可以考虑给博主来个小小的打赏以资鼓励,您的肯定将是我最大的动力。thx. 微信打赏 支付宝打赏 作 者: Angel_Kitty 出 处:http://www.cnblogs.com/ECJTUACM-873284962/ 关于作者:潜心机器学习以及信息安全的综合研究。如有问题或建议,请多多赐教! 版权声明:本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接。 特此声明:所有评论和私信都会在第一时间回复。也欢迎园子的大大们指正错误,共同进步。或者直接私信我 声援博主:如果您觉得文章对您有帮助,可以点击右下角【推荐】推荐一下该博文。您的鼓励是作者坚持原创和持续写作的最大动力!

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

Rsync 实现远程同步

介绍 rsync命令是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件。rsync使用所谓的“rsync算法”来使本地和远程两个主机之间的文件达到同步,这个算法只传送两个文件的不同部分,而不是每次都整份传送,因此速度相当快。 rsync是一个功能非常强大的工具,其命令也有很多功能特色选项,我们下面就对它的选项一一进行分析说明。 常用场景一 无密码同步 1、安装rsync [root@localhost /]# yum -y install rsync 2、新建rsyncd.conf文件 vim /etc/rsyncd.conf #This is the rsync daemon configuration #global settings pid file = /var/run/rsyncd.pid port = 873 lock file = /var/run/rsyncd.lock log file = /var/log/rsync.log gid = root uid = root #module settings [share_data] #共享名称 path = /web/rsync/share_data #共享路径 use chroot = no max connections = 15 read only = yes write only = no list = no ignore errors = yes timeout = 120 保存 3、执行命令 /usr/bin/rsync --daemon mkdir -p /web/rsync/share_data #新建共享目录,实例中直接输入要共享文件的就好,可省去次步 客户端 1、安装rsync [root@localhost /]# yum -y install rsync 2、输入命令进行同步 rsync -avz --progress root@192.168.1.98::share_data /home/hadoop/share_data ↓ ↓ ↓ 服务器IP 配置文件共享目录名 客户端收纳目录 3、限制流量同步 限制流量同步: rsync -avz --bwlimit=50 --progress root@192.168.1.98::share_data /home/hadoop/share_data 常用场景二 有密码同步 服务端配置 1、配置文件修改 vim /etc/rsyncd.conf #This is the rsync daemon configuration #global settings pid file = /var/run/rsyncd.pid port = 873 lock file = /var/run/rsyncd.lock log file = /var/log/rsync.log gid = root uid = root #module settings [auth_data] path = /web/rsync/auth_data use chroot = no max connections = 15 read only = yes write only = no list = no ignore errors = yes timeout = 120 auth users = hadoop secrets file = /etc/rsyncd.passwd 3、执行命令 echo "hadoop:password123" > /etc/rsyncd.passwd chmod 600 /etc/rsyncd.passwd mkdir -p /web/rsync/auth_data 客户端配置 1、保存密码 echo "password123" > /home/hadoop/rsyncd.passwd chmod 600 /home/hadoop/rsyncd.passwd 2、远程同步 rsync -avz --progress --password-file=/home/hadoop/rsyncd.passwd hadoop@192.168.1.98::auth_data /home/hadoop/auth_data 或者是: export RSYNC_PASSWORD="password123" rsync -avz --progress hadoop@192.168.1.98::auth_data /home/hadoop/auth_data 常用场景三 写入同步 服务端 1、配置文件 vim /etc/rsyncd.conf #global settings pid file = /var/run/rsyncd.pid port = 873 lock file = /var/run/rsyncd.lock log file = /var/log/rsync.log gid = root uid = root #module settings [write_data] path = /web/rsync/write_data use chroot = no max connections = 15 read only = no list = no ignore errors = yes timeout = 120 auth users = hadoop secrets file = /etc/rsyncd.passwd 保存 2、执行命令 mkdir -p /web/rsync/write_data 客户端 1、输入同步命令 echo "123" > /home/hadoop/write_file export RSYNC_PASSWORD="password123" rsync -avz --progress --delete /home/hadoop/write_file hadoop@192.168.1.98::write_data 常用场景四 限定IP或网段 服务端 1、配置文件修改 #global settings pid file = /var/run/rsyncd.pid port = 873 lock file = /var/run/rsyncd.lock log file = /var/log/rsync.log gid = root uid = root #module settings [write_data] path = /web/rsync/write_data use chroot = no max connections = 15 read only = no list = no ignore errors = yes timeout = 120 auth users = hadoop secrets file = /etc/rsyncd.passwd hosts allow = 192.168.2.32 192.168.1.0/24 常见情景例子 指定端口 rsync -avz --port=8081 --progress /home/hadoop/auth_data hadoop@192.168.1.98::auth_data 限速 rsync --bwlimit=100 -avz --progress /home/hadoop/auth_data hadoop@192.168.1.98::auth_data 限速100kb/s同步数据 Rsync通过SSH传输 rsync -e "ssh -p 22" --progress /home/hadoop/auth_data hadoop@192.168.1.98::auth_data 本文参考:ggjucheng 更多命令参考 客户端 https://download.samba.org/pub/rsync/rsync.html 服务端https://download.samba.org/pub/rsync/rsyncd.conf.html

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

OpenStack Rabbit 集群实现

rabbitMQ 集群配置 1, install epel yum wget http://mirrors.yun-idc.com/epel/6/i386/epel-release-6-8.noarch.rpm rpm -vih epel-release-6-8.noarch.rpm 2, install rabbitMQ yum -y install rabbitmq-server 3, /etc/hosts configure Master rabbitMQ configure 192.168.8.180 athController.8.180.abs.com.cn athController 192.168.8.53 athBackup.8.53.abs.com.cn athBackup Node rabbitMQ configure 192.168.8.180 athController.8.180.autohome.com.cn athController 192.168.8.53 athBackup.8.53.autohome.com.cn athBackup 4, /etc/sysconfig/network configure Master hostname configure sed -i 's/HOSTNAME=.*/HOSTNAME=athController.8.180.abs.com.cn/' /etc/sysconf/network Node hostname configure sed -i 's/HOSTNAME=.*/HOSTNAME=athBackup.8.53.abs.com.cn/' /etc/sysconf/network 5, disabled selinux Master and Node selinux configure sed -i 's/SELINUX=.*/SELINUX=disabled/' /etc/selinux/config 6, Congfigure rabbitMQ Master rabbitMQ Configure 1, vim /etc/rabbitmq/rabbit.config % This file managed by Puppet % Template Path: rabbitmq/templates/rabbitmq.config [ {rabbit, [ {default_user, <<"guest">>}, {default_pass, <<"guest">>} ]}, {kernel, [ ]} ]. % EOF 2, vim /etc/rabbitmq/rabbit-env.conf RABBITMQ_NODE_PORT=5672 Node rabbitMQ Configure 1, vim /etc/rabbitmq/rabbit.config % This file managed by Puppet % Template Path: rabbitmq/templates/rabbitmq.config [ {rabbit, [ {default_user, <<"guest">>}, {default_pass, <<"guest">>} ]}, {kernel, [ ]} ]. % EOF 2, vim /etc/rabbitmq/rabbit-env.conf RABBITMQ_NODE_PORT=5672 7,restart rabbitMQ Master restart rabbitMQ service rabbitmq-server restart Node restart rabbitMQ service rabbitmq-server restart 8,configure rabbitmq cluster Master rabbitMQ cluster rabbitmqctl stop_app rabbitmqctl reset /usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management /usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management_agent rabbitmqctl start_app Node rabbitMQ cluster rabbitmqctl join_cluster rabbit@athController.8.180.autohome.com.cn rabbitmqctl stop_app rabbitmqctl reset /usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management /usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management_agent rabbitmqctl join_cluster --ram rabbit@athController rabbitmqclt start_app 9,show cluster status [root@athBackup yum.repos.d]# rabbitmqctl cluster_status Cluster status of node rabbit@athBackup ... [{nodes,[{disc,[rabbit@athController]},{ram,[rabbit@athBackup]}]}, {running_nodes,[rabbit@athController,rabbit@athBackup]}, {partitions,[]}] ...done. 本文转自 swq499809608 51CTO博客,原文链接:http://blog.51cto.com/swq499809608/1536082

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

PHP实现双向链表

看了很久数据结构但是没有怎么用过,在网上看到了关于PHP的数据结构,学习了一下,与大家一起分享一下。上一次分享了链表,这次来补充说一下双向链表。 简短不割 <?php class Hero { public $pre=null; public $no; public $name; public $next=null; public function __construct($no='',$name='') { $this->no=$no; $this->name=$name; } static public function addHero($head,$hero) { $cur = $head; $isExist=false; //判断目前这个链表是否为空 if($cur->next==null) { $cur->next=$hero; $hero->pre=$cur; } else { //如果不是空节点,则安排名来添加 //找到添加的位置 while($cur->next!=null) { if($cur->next->no > $hero->no) { break; } else if($cur->next->no == $hero->no) { $isExist=true; echo "<br>不能添加相同的编号"; } $cur=$cur->next; } if(!$isExist) { if($cur->next!=null) { $hero->next=$cur->next; } $hero->pre=$cur; if($cur->next!=null) { $hero->next->pre=$hero; } $cur->next=$hero; } } } //遍历 static public function showHero($head) { $cur=$head; while($cur->next!=null) { echo "<br>编号:".$cur->next->no."名字:".$cur->next->name; $cur=$cur->next; } } static public function delHero($head,$herono) { $cur=$head; $isFind=false; while($cur!=null) { if($cur->no==$herono) { $isFind=true; break; } //继续找 $cur=$cur->next; } if($isFind) { if($cur->next!=null) { $cur->next_pre=$cur->pre; } $cur->pre->next=$cur->next; } else { echo "<br>没有找到目标"; } } } $head = new Hero(); $hero1 = new Hero(1,'1111'); $hero3 = new Hero(3,'3333'); $hero2 = new Hero(2,'2222'); Hero::addHero($head,$hero1); Hero::addHero($head,$hero3); Hero::addHero($head,$hero2); Hero::showHero($head); Hero::delHero($head,2); Hero::showHero($head); ?> 本文转自我爱物联网博客园博客,原文链接:http://www.cnblogs.com/yydcdut/p/3782661.html,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

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

Nacos

Nacos

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

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

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