首页 文章 精选 留言 我的

精选列表

搜索[TDSQL-C PostgreSQL 版],共10000篇文章
优秀的个人博客,低调大师

吴恩达深度学习中文版笔记:人脸识别和神经风格转换

自2016年8月份,吴恩达的初创公司deeplearning.ai通过Coursera提供深度学习的最新在线课程,到今年2月份,吴老师更新了课程的第五部分(点击查看大数据文摘相关报道),前后耗时半年时间。 本文将着重介绍吴恩达老师第四周课程的视频内容和笔记,展示一些重要的卷积神经网络的特殊应用,我们将从人脸识别开始,之后讲神经风格迁移,你将有机会在编程作业中实现这部分内容,创造自己的艺术作品。 什么是人脸识别? 让我们先从人脸识别开始,我这里有一个有意思的演示。我在领导百度AI团队的时候,其中一个小组由林元庆带领的,做过一个人脸识别系统,这个系统非常棒,让我们来看一下。 以下内容为演示视频内容: 视频开始: 我想演示一个人脸识别系统,我现在在百度的中国总部,很多公司要求进入公司的时候要刷工卡,但是在这里我们并不需要它,使用人脸识别,看看我能做

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

一个简单的C#+arcgis的非数据库版例子

1.首先新建一个winform的项目。 2.确保C#工具箱包含ESRI的相关控件,如果没有就需要安装SDK。 如果VS中依旧不存在esri控件解决方案如下,以VS2013为例: (1)打开注册表,定位至HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0,点击10.0在右侧空白处右侧新建--字符串值,名称取”InstallDir“,类型默认为REG_SZ,其数据值即为HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0\InstallDir的值,也就是你VS2013的安装路径。 (2)win7 64位下只要把vs2010安装目录下\Common7\IDE\ItemTemplates\CSharp\ArcGIS文件夹和\Common7\IDE\ProjectTemplates\CSharp\ArcGIS分别对应复制到C:\Users\Administrator\Documents\Visual Studio 2013\Templates\ItemTemplates\Visual C#和C:\Users\Administrator\Documents\Visual Studio 2013\Templates\ProjectTemplates\Visual C#就可以了。 (3)重启VS后还没有那就手动添加一下吧! 3.将VS的相应ToolbarControl(工具控件),AxTOCControl(目录控件),AxMapControl(地图控件)和AxLicenseControl (许可控件)控件拖到界面形成一下效果: 之后修改public Form1()的后台代码如下: ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop); InitializeComponent(); string path = @"F:\Chang\mapTest\mapTest\World\"; string fileName = @"World.mxd"; //加载图层文件 axMapControl1.LoadMxFile(path + fileName); //设置MapControl显示范围到数据的全局范围 axMapControl1.Extent = axMapControl1.FullExtent; 运行效果最终形成 源码下载

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

“中国版特斯拉”绝地反击,自动驾驶开辟“第三条路”?

马斯克最近可以不用睡在工厂了。 不久前,中国宣布将相当幅度降低汽车进口关税,很可能将整车关税从目前的25%降低到15%,以特斯拉为代表的美国车企将直接因此受益。 但对中国车企来说,降税带来竞争结果并非全是挑战,况且,在特斯拉们进门之前,现在正是黄金窗口期:一方面,新关税的制定需要落地时间和执行过程;另一方面,特斯拉本身产能不足,尤其是“平民款”Model 3车型交付遥遥无期,因此马斯克也只能睡在工厂当“监工”。 下周,北京车展将开幕,这是中国2018年的第一个大展,在中美贸易关系微妙的背景下,国内车企的主打车的高性能、低价格,更像是一次集体秀肌肉。 进口汽车关税降幅或达40%,中国车企北京车展趁机反击 在刚刚结束的博鳌亚洲论坛上,国家领导人承诺对进口汽车降低关税。 汽车行业分析师张毅在接受《环球时报》记者采访时预测称,综合各种因素考虑,中国很

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

SSM-SpringMVC-26:SpringMVC异常骇级之自定义异常注解版

------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 注解的方法实现异常解析,话不多说,直接搞起,和以前一样的习惯,和上篇博客一样的代码放后面,不一样的在前面 案例: 1.自定义处理器和处理方法 package cn.dawn.day18annotationexception; import cn.dawn.day18annotationexception.userexception.UserageException; import cn.dawn.day18annotationexception.userexception.UsernameException; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Created by Dawn on 2018/3/28. */ @Controller public class ZDYExceptionController { /*作用于这俩个*/ @ExceptionHandler({UsernameException.class,UserageException.class}) public ModelAndView resolveException(Exception ex) { ModelAndView modelAndView=new ModelAndView(); /*返回的异常对象*/ modelAndView.addObject("ex",ex); /*判断去那个页面*/ if(ex instanceof UsernameException){ modelAndView.setViewName("name"); } if(ex instanceof UserageException){ modelAndView.setViewName("age"); } return modelAndView; } @RequestMapping("/annotationException") public String annotationException(String username,Integer userage) throws Exception { if(!username.equals("admin")){ throw new UsernameException("登陆名不正确"); } if(userage<18){ throw new UserageException("未成年,走开"); } return "success"; } } 2.自己的xml大配置文件 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!--包扫描器--> <context:component-scan base-package="cn.dawn.day18annotationexception"></context:component-scan> <!--视图解析器--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/day18/"></property> <property name="suffix" value=".jsp"></property> </bean> </beans> 3.修改web.xml的中央调度器的上下文配置路径 4.login.jsp <%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %> <html> <head> <title>Title</title> </head> <body> <h2>登录</h2> <form action="${pageContext.request.contextPath}/annotationException" method="post"> 用户名:<input name="username"> 年龄:<input name="userage"> <input type="submit" value="登录"/> </form> </body> </html> 下面的内容与上篇博客相同 5.UserageException自定义异常 package cn.dawn.day17selfexceptionresolver.userexception; /** * Created by Dawn on 2018/3/30. */ public class UserageException extends Exception { public UserageException() { super(); } public UserageException(String message) { super(message); } } 6.UsernameException自定义异常 package cn.dawn.day17selfexceptionresolver.userexception; /** * Created by Dawn on 2018/3/30. */ public class UsernameException extends Exception { public UsernameException() { super(); } public UsernameException(String message) { super(message); } } 7.jsp页面 7.1success.jsp <%@ page language="java" pageEncoding="utf-8" isELIgnored="false" %> <html> <body> <%--<img src="image/1.jpg">--%> <h2>Success!</h2> </body> </html> 7.2error.jsp <%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %> <html> <head> <title>Title</title> </head> <body> <h2>ERROR</h2> <p>${ex.message}</p> 服务器被猴子砍了,攻城狮在抢修中,还杀了个程序猿祭天 </body> </html> 7.3age.jsp <%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %> <html> <head> <title>Title</title> </head> <body> <h2>年龄错误ERROR</h2> <p>${ex.message}</p> 服务器被猴子砍了,攻城狮在抢修中,还杀了个程序猿祭天 </body> </html> 7.4name.jsp <%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %> <html> <head> <title>Title</title> </head> <body> <h2>名字错误ERROR</h2> <p>${ex.message}</p> 服务器被猴子砍了,攻城狮在抢修中,还杀了个程序猿祭天 </body> </html> 8.启动tomcat,访问login.jsp

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

Android版:验证手机号码的正则表达式 (转)

/** * 验证手机格式 */ public static boolean isMobileNO(String mobiles) { /* 移动:134、135、136、137、138、139、150、151、157(TD)、158、159、187、188 联通:130、131、132、152、155、156、185、186 电信:133、153、180、189、(1349卫通) 总结起来就是第一位必定为1,第二位必定为3或5或8,其他位置的可以为0-9 */ String telRegex = "[1][358]\\d{9}";//"[1]"代表第1位为数字1,"[358]"代表第二位可以为3、5、8中的一个,"\\d{9}"代表后面是可以是0~9的数字,有9位。 if (TextUtils.isEmpty(mobiles)) return false; else return mobiles.matches(telRegex); } 转自:链接 本文转自SharkBin博客园博客,原文链接:http://www.cnblogs.com/SharkBin/p/5237495.html,如需转载请自行联系原作者

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

Android第十三期 - 百度云推送(百度后台版)

这回比较费事儿,我给学弟学妹分解一下,下面开始: 配置部分: 1.去百度云推送注册账号,配置一下,如图: 2.点击消息跳转的配置部分,如图: 3.发送消息的配置,如图: 这样就完成百度后台的发送消息的服务器的配置了。 接着是App的代码部分: 1.MyPushMessageReceiver: 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 package com.baidu.push.example; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import org.json.JSONException; import org.json.JSONObject; import android.content.Context; import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.baidu.frontia.api.FrontiaPushMessageReceiver; /** *Push消息处理receiver。请编写您需要的回调函数,一般来说:onBind是必须的,用来处理startWork返回值; *onMessage用来接收透传消息;onSetTags、onDelTags、onListTags是tag相关操作的回调; *onNotificationClicked在通知被点击时回调;onUnbind是stopWork接口的返回值回调 * *返回值中的errorCode,解释如下: *0-Success *10001-NetworkProblem *30600-InternalServerError *30601-MethodNotAllowed *30602-RequestParamsNotValid *30603-AuthenticationFailed *30604-QuotaUseUpPaymentRequired *30605-DataRequiredNotFound *30606-RequestTimeExpiresTimeout *30607-ChannelTokenTimeout *30608-BindRelationNotFound *30609-BindNumberTooMany * *当您遇到以上返回错误时,如果解释不了您的问题,请用同一请求的返回值requestId和errorCode联系我们追查问题。 * */ public class MyPushMessageReceiver extends FrontiaPushMessageReceiver{ /**TAGtoLog*/ public static final StringTAG=MyPushMessageReceiver. class .getSimpleName(); /** *调用PushManager.startWork后,sdk将对push *server发起绑定请求,这个过程是异步的。绑定请求的结果通过onBind返回。如果您需要用单播推送,需要把这里获取的channel *id和userid上传到应用server中,再调用server接口用channelid和userid给单个手机或者用户推送。 * *@paramcontext *BroadcastReceiver的执行Context *@paramerrorCode *绑定接口返回值,0-成功 *@paramappid *应用id。errorCode非0时为null *@paramuserId *应用userid。errorCode非0时为null *@paramchannelId *应用channelid。errorCode非0时为null *@paramrequestId *向服务端发起的请求id。在追查问题时有用; *@returnnone */ @Override public void onBind(Contextcontext, int errorCode,Stringappid, StringuserId,StringchannelId,StringrequestId){ StringresponseString= "onBinderrorCode=" +errorCode+ "appid=" +appid+ "userId=" +userId+ "channelId=" +channelId + "requestId=" +requestId; Log.d(TAG,responseString); //绑定成功,设置已绑定flag,可以有效的减少不必要的绑定请求 if (errorCode== 0 ){ Utils.setBind(context, true ); } //Demo更新界面展示代码,应用请在这里加入自己的处理逻辑 updateContent(context,responseString); } /** *接收透传消息的函数。 * *@paramcontext *上下文 *@parammessage *推送的消息 *@paramcustomContentString *自定义内容,为空或者json字符串 */ @Override public void onMessage(Contextcontext,Stringmessage, StringcustomContentString){ StringmessageString= "透传消息message=\"" +message + "\"customContentString=" +customContentString; Log.d(TAG,messageString); //自定义内容获取方式,mykey和myvalue对应透传消息推送时自定义内容中设置的键和值 if (!TextUtils.isEmpty(customContentString)){ JSONObjectcustomJson= null ; try { customJson= new JSONObject(customContentString); Stringmyvalue= null ; if (customJson.isNull( "mykey" )){ myvalue=customJson.getString( "mykey" ); } } catch (JSONExceptione){ //TODOAuto-generatedcatchblock e.printStackTrace(); } } //Demo更新界面展示代码,应用请在这里加入自己的处理逻辑 updateContent(context,messageString); } /** *接收通知点击的函数。注:推送通知被用户点击前,应用无法通过接口获取通知的内容。 * *@paramcontext *上下文 *@paramtitle *推送的通知的标题 *@paramdescription *推送的通知的描述 *@paramcustomContentString *自定义内容,为空或者json字符串 */ @Override public void onNotificationClicked(Contextcontext,Stringtitle, Stringdescription,StringcustomContentString){ StringnotifyString= "通知点击title=\"" +title+ "\"description=\"" +description+ "\"customContent=" +customContentString; Log.d(TAG,notifyString); //自定义内容获取方式,mykey和myvalue对应通知推送时自定义内容中设置的键和值 if (!TextUtils.isEmpty(customContentString)){ JSONObjectcustomJson= null ; try { customJson= new JSONObject(customContentString); Stringmyvalue= null ; if (customJson.isNull( "mykey" )){ myvalue=customJson.getString( "mykey" ); } } catch (JSONExceptione){ //TODOAuto-generatedcatchblock e.printStackTrace(); } } //Demo更新界面展示代码,应用请在这里加入自己的处理逻辑 updateContent(context,notifyString); } /** *setTags()的回调函数。 * *@paramcontext *上下文 *@paramerrorCode *错误码。0表示某些tag已经设置成功;非0表示所有tag的设置均失败。 *@paramsuccessTags *设置成功的tag *@paramfailTags *设置失败的tag *@paramrequestId *分配给对云推送的请求的id */ @Override public void onSetTags(Contextcontext, int errorCode, List<String>sucessTags,List<String>failTags,StringrequestId){ StringresponseString= "onSetTagserrorCode=" +errorCode + "sucessTags=" +sucessTags+ "failTags=" +failTags + "requestId=" +requestId; Log.d(TAG,responseString); //Demo更新界面展示代码,应用请在这里加入自己的处理逻辑 updateContent(context,responseString); } /** *delTags()的回调函数。 * *@paramcontext *上下文 *@paramerrorCode *错误码。0表示某些tag已经删除成功;非0表示所有tag均删除失败。 *@paramsuccessTags *成功删除的tag *@paramfailTags *删除失败的tag *@paramrequestId *分配给对云推送的请求的id */ @Override public void onDelTags(Contextcontext, int errorCode, List<String>sucessTags,List<String>failTags,StringrequestId){ StringresponseString= "onDelTagserrorCode=" +errorCode + "sucessTags=" +sucessTags+ "failTags=" +failTags + "requestId=" +requestId; Log.d(TAG,responseString); //Demo更新界面展示代码,应用请在这里加入自己的处理逻辑 updateContent(context,responseString); } /** *listTags()的回调函数。 * *@paramcontext *上下文 *@paramerrorCode *错误码。0表示列举tag成功;非0表示失败。 *@paramtags *当前应用设置的所有tag。 *@paramrequestId *分配给对云推送的请求的id */ @Override public void onListTags(Contextcontext, int errorCode,List<String>tags, StringrequestId){ StringresponseString= "onListTagserrorCode=" +errorCode+ "tags=" +tags; Log.d(TAG,responseString); //Demo更新界面展示代码,应用请在这里加入自己的处理逻辑 updateContent(context,responseString); } /** *PushManager.stopWork()的回调函数。 * *@paramcontext *上下文 *@paramerrorCode *错误码。0表示从云推送解绑定成功;非0表示失败。 *@paramrequestId *分配给对云推送的请求的id */ @Override public void onUnbind(Contextcontext, int errorCode,StringrequestId){ StringresponseString= "onUnbinderrorCode=" +errorCode + "requestId=" +requestId; Log.d(TAG,responseString); //解绑定成功,设置未绑定flag, if (errorCode== 0 ){ Utils.setBind(context, false ); } //Demo更新界面展示代码,应用请在这里加入自己的处理逻辑 updateContent(context,responseString); } private void updateContent(Contextcontext,Stringcontent){ Log.d(TAG, "updateContent" ); StringlogText= "" +Utils.logStringCache; if (!logText.equals( "" )){ logText+= "\n" ; } SimpleDateFormatsDateFormat= new SimpleDateFormat( "HH-mm-ss" ); logText+=sDateFormat.format( new Date())+ ":" ; logText+=content; Utils.logStringCache=logText; Intentintent= new Intent(); intent.setClass(context.getApplicationContext(),PushDemoActivity. class ); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.getApplicationContext().startActivity(intent); } } 注意:这里面的方法onMessage和onNotificationClicked可以自定义消息的显示样式。 2.要跳转到的MainActivity: 1 2 3 4 5 6 7 8 9 10 11 12 package com.baidu.push.example; import com.gaoxiaotongctone.R; import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity{ @Override protected void onCreate(BundlesavedInstanceState){ //TODOAuto-generatedmethodstub super .onCreate(savedInstanceState); setContentView(R.layout.custom_activity); } } 3.主窗体PushDemoActivity的显示: 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 package com.baidu.push.example; import java.util.Calendar; import java.util.List; import android.app.Activity; import android.app.AlertDialog; import android.app.Notification; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.util.Log; import android.view.View; import android.webkit.CookieManager; import android.webkit.CookieSyncManager; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.ScrollView; import android.widget.TextView; import com.baidu.android.pushservice.CustomPushNotificationBuilder; import com.baidu.android.pushservice.PushConstants; import com.baidu.android.pushservice.PushManager; /* *云推送Demo主Activity。 *代码中,注释以Push标注开头的,表示接下来的代码块是Push接口调用示例 */ public class PushDemoActivity extends Activity implements View.OnClickListener{ private static final StringTAG=PushDemoActivity. class .getSimpleName(); RelativeLayoutmainLayout= null ; int akBtnId= 0 ; int initBtnId= 0 ; int richBtnId= 0 ; int setTagBtnId= 0 ; int delTagBtnId= 0 ; int clearLogBtnId= 0 ; ButtoninitButton= null ; ButtoninitWithApiKey= null ; ButtondisplayRichMedia= null ; ButtonsetTags= null ; ButtondelTags= null ; ButtonclearLog= null ; TextViewlogText= null ; ScrollViewscrollView= null ; public static int initialCnt= 0 ; private boolean isLogin= false ; @Override public void onCreate(BundlesavedInstanceState){ super .onCreate(savedInstanceState); Utils.logStringCache=Utils.getLogText(getApplicationContext()); Resourcesresource= this .getResources(); StringpkgName= this .getPackageName(); setContentView(resource.getIdentifier( "main" , "layout" ,pkgName)); akBtnId=resource.getIdentifier( "btn_initAK" , "id" ,pkgName); initBtnId=resource.getIdentifier( "btn_init" , "id" ,pkgName); richBtnId=resource.getIdentifier( "btn_rich" , "id" ,pkgName); setTagBtnId=resource.getIdentifier( "btn_setTags" , "id" ,pkgName); delTagBtnId=resource.getIdentifier( "btn_delTags" , "id" ,pkgName); clearLogBtnId=resource.getIdentifier( "btn_clear_log" , "id" ,pkgName); initWithApiKey=(Button)findViewById(akBtnId); initButton=(Button)findViewById(initBtnId); displayRichMedia=(Button)findViewById(richBtnId); setTags=(Button)findViewById(setTagBtnId); delTags=(Button)findViewById(delTagBtnId); clearLog=(Button)findViewById(clearLogBtnId); logText=(TextView)findViewById(resource.getIdentifier( "text_log" , "id" ,pkgName)); scrollView=(ScrollView)findViewById(resource.getIdentifier( "stroll_text" , "id" ,pkgName)); initWithApiKey.setOnClickListener( this ); initButton.setOnClickListener( this ); setTags.setOnClickListener( this ); delTags.setOnClickListener( this ); displayRichMedia.setOnClickListener( this ); clearLog.setOnClickListener( this ); //Push:以apikey的方式登录,一般放在主Activity的onCreate中。 //这里把apikey存放于manifest文件中,只是一种存放方式, //您可以用自定义常量等其它方式实现,来替换参数中的Utils.getMetaValue(PushDemoActivity.this, //"api_key") //通过sharepreference实现的绑定标志开关,如果已经成功绑定,就取消这次绑定 if (!Utils.hasBind(getApplicationContext())){ PushManager.startWork(getApplicationContext(), PushConstants.LOGIN_TYPE_API_KEY, Utils.getMetaValue(PushDemoActivity. this , "api_key" )); //Push:如果想基于地理位置推送,可以打开支持地理位置的推送的开关 //PushManager.enableLbs(getApplicationContext()); } //Push:设置自定义的通知样式,具体API介绍见用户手册,如果想使用系统默认的可以不加这段代码 //请在通知推送界面中,高级设置->通知栏样式->自定义样式,选中并且填写值:1, //与下方代码中PushManager.setNotificationBuilder(this,1,cBuilder)中的第二个参数对应 CustomPushNotificationBuildercBuilder= new CustomPushNotificationBuilder( getApplicationContext(),resource.getIdentifier( "notification_custom_builder" , "layout" ,pkgName), resource.getIdentifier( "notification_icon" , "id" ,pkgName), resource.getIdentifier( "notification_title" , "id" ,pkgName), resource.getIdentifier( "notification_text" , "id" ,pkgName)); cBuilder.setNotificationFlags(Notification.FLAG_AUTO_CANCEL); cBuilder.setNotificationDefaults(Notification.DEFAULT_SOUND |Notification.DEFAULT_VIBRATE); cBuilder.setStatusbarIcon( this .getApplicationInfo().icon); cBuilder.setLayoutDrawable(resource.getIdentifier( "simple_notification_icon" , "drawable" ,pkgName)); PushManager.setNotificationBuilder( this , 1 ,cBuilder); } @Override public void onClick(Viewv){ if (v.getId()==akBtnId){ initWithApiKey(); } else if (v.getId()==initBtnId){ initWithBaiduAccount(); } else if (v.getId()==richBtnId){ openRichMediaList(); } else if (v.getId()==setTagBtnId){ setTags(); } else if (v.getId()==delTagBtnId){ deleteTags(); } else if (v.getId()==clearLogBtnId){ Utils.logStringCache= "" ; Utils.setLogText(getApplicationContext(),Utils.logStringCache); updateDisplay(); } else { } } //打开富媒体列表界面 private void openRichMediaList(){ //Push:打开富媒体消息列表 IntentsendIntent= new Intent(); sendIntent.setClassName(getBaseContext(), "com.baidu.android.pushservice.richmedia.MediaListActivity" ); sendIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PushDemoActivity. this .startActivity(sendIntent); } //删除tag操作 private void deleteTags(){ LinearLayoutlayout= new LinearLayout(PushDemoActivity. this ); layout.setOrientation(LinearLayout.VERTICAL); final EditTexttextviewGid= new EditText(PushDemoActivity. this ); textviewGid.setHint( "请输入多个标签,以英文逗号隔开" ); layout.addView(textviewGid); AlertDialog.Builderbuilder= new AlertDialog.Builder( PushDemoActivity. this ); builder.setView(layout); builder.setPositiveButton( "删除标签" , new DialogInterface.OnClickListener(){ public void onClick(DialogInterfacedialog, int which){ //Push:删除tag调用方式 List<String>tags=Utils.getTagsList(textviewGid .getText().toString()); PushManager.delTags(getApplicationContext(),tags); } }); builder.show(); } //设置标签,以英文逗号隔开 private void setTags(){ LinearLayoutlayout= new LinearLayout(PushDemoActivity. this ); layout.setOrientation(LinearLayout.VERTICAL); final EditTexttextviewGid= new EditText(PushDemoActivity. this ); textviewGid.setHint( "请输入多个标签,以英文逗号隔开" ); layout.addView(textviewGid); AlertDialog.Builderbuilder= new AlertDialog.Builder( PushDemoActivity. this ); builder.setView(layout); builder.setPositiveButton( "设置标签" , new DialogInterface.OnClickListener(){ public void onClick(DialogInterfacedialog, int which){ //Push:设置tag调用方式 List<String>tags=Utils.getTagsList(textviewGid .getText().toString()); PushManager.setTags(getApplicationContext(),tags); } }); builder.show(); } //以apikey的方式绑定 private void initWithApiKey(){ //Push:无账号初始化,用apikey绑定 PushManager.startWork(getApplicationContext(), PushConstants.LOGIN_TYPE_API_KEY, Utils.getMetaValue(PushDemoActivity. this , "api_key" )); } //以百度账号登陆,获取accesstoken来绑定 private void initWithBaiduAccount(){ if (isLogin){ //已登录则清除Cookie,accesstoken,设置登录按钮 CookieSyncManager.createInstance(getApplicationContext()); CookieManager.getInstance().removeAllCookie(); CookieSyncManager.getInstance().sync(); isLogin= false ; initButton.setText( "登陆百度账号初始化Channel" ); } //跳转到百度账号登录的activity Intentintent= new Intent(PushDemoActivity. this ,LoginActivity. class ); startActivity(intent); } @Override public void onStart(){ super .onStart(); } @Override public void onResume(){ super .onResume(); Log.d(TAG, "onResume" ); updateDisplay(); } @Override protected void onNewIntent(Intentintent){ Stringaction=intent.getAction(); if (Utils.ACTION_LOGIN.equals(action)){ //Push:百度账号初始化,用accesstoken绑定 StringaccessToken=intent .getStringExtra(Utils.EXTRA_ACCESS_TOKEN); PushManager.startWork(getApplicationContext(), PushConstants.LOGIN_TYPE_ACCESS_TOKEN,accessToken); isLogin= true ; initButton.setText( "更换百度账号" ); } updateDisplay(); } @Override public void onStop(){ super .onStop(); } @Override public void onDestroy(){ Utils.setLogText(getApplicationContext(),Utils.logStringCache); super .onDestroy(); } //更新界面显示内容 private void updateDisplay(){ Log.d(TAG, "updateDisplay,logText:" +logText+ "cache:" +Utils.logStringCache); if (logText!= null ){ logText.setText(Utils.logStringCache); } if (scrollView!= null ){ scrollView.fullScroll(ScrollView.FOCUS_DOWN); } } } 注意:这句话才是关键。 PushManager.startWork(getApplicationContext(), PushConstants.LOGIN_TYPE_API_KEY, Utils.getMetaValue(PushDemoActivity.this, "api_key")); 下面分别是打开另一个activity和打开指定的网页的效果图: 附图: 附件:http://down.51cto.com/data/2364801 本文转自 吴雨声 51CTO博客,原文链接:http://blog.51cto.com/liangxiao/1544813,如需转载请自行联系原作者

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

Android应用开发提高系列(2)——《Practical Java 中文版》读书笔记(下)

正文 注意:条目和用语可能与书籍有所出入,但尽量保持原样加一些自己的理解。 一、性能 1. 先把焦点放在设计、数据结构和算法身上 备注:良好的设计、明智的选择数据结构和算法可能比高效代码更重要。 2. 不要依赖编译器优化技术 3. 理解运行时(runtime)代码优化 备注:JIT将bytecode于运行时转换为本地二进制码,从而提高性能。因此编译后代码被执行次数越多,本机代码生成代价就很合算。 4. 连接字符串使用StringBuffer要比String快,尤其是大量字符串拼接 5. 将对象创建成本降至最小 备注:复用既有对象,不要创建非必要的对象,只在需要的时候才创建它们。 6. 将同步化(synchronization)降至最低 备注:如果synchronized函数抛出异常,则在异常离开函数之前,锁会自动释放。如果整个函数都需要被同步化,为了产生体积较小且执行速度较快的代码,请优先使用函数修饰符,而不是在函数内使用synchronized代码块。 7. 尽可能使用stack变量 备注:如果在函数中频繁访问成员变量、静态变量,可以用本地(local)变量替代,最后操作完后再赋值给成员/静态变量。 8. 尽可能的使用static、final和private函数 备注:此类函数可以在编译期间被静态决议(statically resolved),而不需要动态议决(dynamic resolved)。(子类无法覆写) 9. 类的成员变量、静态变量都有缺省值,务须重复初始化 备注:记住,本地变量没有缺省值(例如函数内定义的变量)。 10. 尽可能的使用基本数据类型 备注:如int、short、char、boolean,使得代码更快更小。 11. 不要使用枚举器(Enumeration)和迭代器(Iterator)来遍历Vector 备注:使用for循环+get() 12. 使用System.arraycopy()来复制数组 备注:使用System.arraycopy()代替for循环,可以产生更快的代码。如: public voidcopyArray( int[]src, int[]dest){ intsize=src.length; System.arraycopy(src,0,dest,0,size); } System.arraycopy()是以native method实现的,可以直接、高效的移动原始数组到目标数组,因此它执行速度更快。 13. 优先使用数组,然后才考虑Vector和ArrayList,理由: a). Vector的get()是同步的 b). ArrayList基本上就是一个非线程同步的Vector,比Vector要快 c). ArrayList和Vector添加元素或移除元素都需要重新整理数组。 备注:不要仅仅因为手上有个数不定的数据需要存储,就毫无选择的使用Vector或ArrayList。可以考虑创建一个足够大的数组,通常这样可能会浪费内存,但性能上的收益可能超过内存方面的代价。 14. 手工优化代码 a). 剔除空白函数和无用代码 b). 削减强度 备注:以更高效的操作替换成本昂贵的操作。一个常见的优化手法是使用复式复制操作符(如+=、-=)。 c). 合并常量 备注:将变量声明为final,使得操作在编译器就进行。 d). 删减相同的子表达式 备注:可用一个临时变量代替重复的表达式。 e). 展开循环 备注:如循环次数少且已知循环次数,可展开去掉循环结构,直接访问数组元素。缺点是会产生更多代码。 f). 简化代数 备注:使用数学技巧来简化表达式。(例如从1+..+100的问题) g). 搬移循环内的不变式 备注:循环内不变化的表达式可用移至循环外,不必重复计算表达式。 15. 编译为本机代码 备注:将程序的某部分编译为本机二进制代码,然后通过JNI访问。 二、多线程 1. 对于实例(instance)函数,同步机制锁定的是对象,而不是函数和代码块。 备注:函数或代码块被声明为synchronized并非意味它在同一时刻只能有一个线程执行(同一对象不同线程调用会阻塞)。Java语言不允许将构造函数声明为synchronized。 2. 同步实例函数和同步静态函数争取的是不同的locks。 备注:两者均非多线程安全,可以使用实例变量进行同步控制,如(byte[] lock = new byte[0]),比其他任何对象都经济。 3. 对于synchronized函数中可被修改的数据,应使之成为private,并根据需要提供访问函数。如果访问函数返回的是可变对象,那么可以先克隆该对象。 4. 避免无谓的同步控制 备注:过度的同步控制可能导致代码死锁或执行缓慢。再次提醒,当一个函数声明为synchronized,所获得的lock是隶属于调用此函数的那个对象。 5. 访问共享变量时请使用synchronized或volatile 备注:如果并发性很重要,而且不需要更新很多变量,则可以考虑使用volatile。一旦变量被声明为volatile,在每次访问它们时,它们就与主内存进行一致化。如果使用synchronized,只在取得lock和释放lock时候才一致化。 6. 在单一操作(single operation)中锁定所有用到的对象 备注:如果某个同步函数调用了某个非同步实例函数来修改对象,它是线程安全的。使用同步控制时,一定要对关键字synchronized所作所为牢记在心。它锁定的是对象而非函数或代码。 7. 以固定而全局性的顺序取得多个locks(机制)以避免死锁。P/181~P/185 备注:嵌入[锁定顺序]需要额外的一些工作、内存和执行时间。 8. 优先使用notifyAll()而非notify() 备注:notify()和notifyAll()用以唤醒处以等待状态的线程,waite()则让线程进入等待状态。notify()仅仅唤醒一个线程。 9. 针对wait()和notifyAll()使用旋转锁(spin locks) 备注:旋转锁模式(spin-lock pattern)简洁、廉价,而且能确保等待着某个条件变量的代码能循规蹈矩。 10. 使用wait()和notifyAll()替代轮询(polling loops) 备注:调用wait()时会释放同步对象锁,暂停(虚悬,suspend)此线程。被暂停的线程不会占用CPU时间,直到被唤醒。如: public voidrun() { intdata; while( true){ synchronized(pipe){ while((data=pipe.getDate())==0){ try{ pipe.waite(); } catch(InterruptedExceptione){} } } // ProcessData } } 11. 不要对已锁定对象的对象引用重新赋值。 12. 不要调用stop()和suspend() 备注:stop()中止一个线程时,会释放线程持有的所有locks,有搅乱内部数据的风险;suspend()暂时悬挂起一个线程,但不会释放持有的locks,可能带来死锁的风险。两种都会引发不可预测的行为和不正确的行为。 当线程的run()结束时,线程就中止了运行。可以用轮询+变量来控制,如下代码: private volatile booleanstop; public voidstopThread() { stop= true; } public voidrun() { while(!stop){ // ProcessData } } 注意:这里使用了关键字volatile,由于Java允许线程在其 私有专用内存 中保留主内存变量的副本(可以优化),线程1对线程2调用了stopThread(),但线程2可能不会及时察觉到stop主内存变量已变化,导致不能及时中止线程。 三、类与接口 1. 实现一个final类(immutable class 不可变类)时,请遵循下列规则: a). 声明所有数据为private b). 只提供取值函数(getter),不提供赋值函数(setter) c). 在构造函数中设置有实例数据 d). 如果函数返回、接受引用final对象,请克隆这个对象。 e). 区别浅层拷贝和深层拷贝应用场景。如拷贝Vector需要使用深层拷贝。 2. 实现clone()时记得调用super.clone() 备注:不管是浅层拷贝还是深层拷贝都需要调用super.clone()。 3. 别只依赖finalize()清理内存以外的资源 备注:finalize()函数只有在垃圾回收器释放对象占用的空间之前才会被调用,回收时可能并非所有符合回收条件的对象都被回收,也无法保证是否被调用、何时调用。实现finalize()方法时记得调用super.finalize()。 4. 在构造函数内应避免调用非final函数,以免被覆写而改变初衷。 结束 书是从朋友那边借过来的,拿到手也有一段时间,磨磨唧唧好多天才看了几十页,而余下部分从上篇文章到这篇文章也不过才3-5天。发现以这种方式来看书也不错,一方面能加快速度,一方面由于要写文章更加认真细读,还能提炼把书读薄记录分享出来,实在是很适合我这样的 :) 本文转自over140 51CTO博客,原文链接:http://blog.51cto.com/over140/844924,如需转载请自行联系原作者

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

在各大Linux发行版中如何安装Docker及设置加速器?

如果读者没有现成的服务器来进行测试Docker,那么可以使用VMware Workstation这款软件来模拟Linux,并且虚拟机支持操作的回滚,那么即使在Linux平台上进行了非法的操作,这也是可以通过快照还原的。下面是笔者的虚拟机的配置: 笔者的电脑配置是CPU:Intel i3,内存12GB,240GB的SSD 一点点初始化操作: 由于笔者多次升级CentOS,所以会有多个启动参数。默认选择第一个启动就可以了。 本人习惯使用远程连接工具来管理Linux主机,这样可以让初学者更加贴近生产环境。下面的命令操作均是使用XShell进行操作的。类似的远程连接工具还有SecureCRT、PUTTY等等。PUTTY+WinSCP可是若干年前网管人员的法宝啊! 由于CentOS7使用了多线程的开机机制,开机速度是非常快的。下面在命令行窗口登录Linux主机。 由于笔者用的是无线网卡,然后虚拟机桥接到了无线网卡上,笔记本电脑接到了家庭的路由器上,所以要重新启动Linux的网路服务,使其获得新的IP地址(之前我是做过实验的,所以虚拟机并不是处于关机状态,而是挂起的状态)。 这个地方笔者使用了比较老旧的命令来重启Linux的网络服务,也可以使用service network restart来重启网路服务。 下面将虚拟机管理软件的界面关掉或者最小化即可,但是读者务必保证勾选以下选项,否则虚拟机将会强制关闭: 下面使用XShell进行连接: 笔者已经安装了docker,只需要启动即可。 No.1:如果你使用的系统环境是CentOS7那么使用docker有以下两种安装方式: 1.使用Yum进行在线安装: Docker要求的系统环境的内核版本在3.10以上。使用uname -r进行查看。使用yum install docker -y进行安装docker。安装完成后可以使用service docker start启动docker的后台服务。当docker后台的服务启动以后我们可以测试docker的hello-world容器:docker run hello-world,因为docker还没有本地的镜像文件,所以docker会到DockerHub上进行下载hello-world的镜像文件,并在容器中运行。 2.使用脚本进行安装 使用sudo命令获取系统管理员的权限,或者直接使用root权限登录我们的CentOS7操作系统。首先将yum包更新到最新。使用如下命令:sudoyum update 执行docker的安装脚本,curl -fsSLhttps://get.docker.com | sh 这个叫别人会自动添加docker的Yum源docker.repo并会自动安装docker。当docker安装完成后同样使用sudo service docker start命令进行启动docker的后台进程。使用同样的命令sudo docker run hello-world命令进行初次测试docker是否可以正常使用。 No.2:如果你的系统数Ubuntu,那么Docker有以下安装方式: 查看系统内核的版本,docker使用的Ubuntu的内核版本必须高于3.10,你可以使用uname -r来查看你的Ubuntu的内核版本。下面使用脚本的方式安装docker。 wget-qO- https://get.docker.com/ | sh 输入当前的用户名和密码就可以安装docker了,安装后会有提示,当腰使用费root权限的用户运行docker的时候必须执行sudo usermod -aG docker<username>,然后重新登录,要不然会有报错信息提示。 启动docker的后台服务:sudoservice docker start,接着我们可以使用docker run hello-world命令来测试运行docker容器。 No.3:Docker在Windows上安装并运行: 如果你是Windows的忠实用户,或者对Linux不太熟悉,那么Docker可以在Windows上运行。 由于docker引擎使用的Linux内核的特性,所以最好使用Linux的环境进行学习和测试使用docker,不过我们可以在Windows上运行一个1轻量级虚拟机来运行docker,那就是Boot2Docker。这是个虚拟机和docker的结合产品,安装步骤比较简单。 可以在https://github.com/boot2docker/windows-installer/releases/latest下载最最新本的Boot2Docker。然后运行安装文件。这个文件将会安装甲骨文VirtualBox、MSYS-giit、boot2docker Linux 镜像文件和Boot2Docker的管理工具。 安装步骤: 双击运行安装程序,单击“Next”按钮,选择boot2docker的安装路径,建议使用较短的英文的安装路径,单击“Next”,选择要安装的组件,选择Full installation,也就是全部安装,最后单击Install进行文件的安装,然后单击“Finsh”,安装完成。从桌面上或者是安装的路径或者是开始菜单都可以启动Boot2Docker。Boot2Docker启动后将会启动一个Unix Shell来配置和管理运行在虚拟机中的docker,我们可以通过docker version命令来查看docker是否正常工作。同样也可以使用docker run hello-world命令来到DockerHub上拉取hello-world的镜像文件来测试docker是否可以正常工作。 由于DockerHub是国外的网站,速度比较慢,笔者使用阿里云的docker加速源: 首先登录https://dev.aliyun.com/search.html到阿里云开发者平台去获取加速器地址: Redhat 7/CentOS7配置加速器的方式与其他系统都不一样,需要编辑/etc/sysconfig/docker配置文件。 在OPTIONS配置项中添加加速器配置--registry-mirror=<your accelerate address> 最后service docker restart重启docker daemon。 本文转自 棋帅小七 51CTO博客,原文链接:http://blog.51cto.com/xvjunjie/1982392

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

MySQL主从架构由5.5版本升级到5.6方案

主从架构[一主多从]升级步骤 1. 首先安装最新版本的MySQL mysql-5.6.26.tar.gz :每台主机分别安装目录:/usr/local/mysql-5.6 yum install libaio-devel 编译参数 /usr/local/cmake/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6 \ -DMYSQL_DATADIR=/usr/local/mysql-5.6/data \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DENABLE_LOCAL_INFILE=1 \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DEXTRA_CHARSETS=all \ -DMYSQL_TCP_PORT=3306 \ -DWITH_DEBUG=OFF \ -DWITH_READLINE=1 \ -DWITH_EMBEDDED_SERVER=1 \ -DMYSQL_UNIX_ADDR=/tmp/mysql6.sock \ -DWITH_SSL=bundled \ -DENABLE_DTRACE=OFF make;make install 软件安装OK 2. 停止其中一个从库: 将原版本中的数据[data]目录[/usr/local/mysql]拷贝到新版本对应的目录下面[/usr/local/mysql-5.6] cp -r /usr/local/mysql/data /usr/local/mysql-5.6/ 3. 变更权限: chown -R root . chown -R mysql data 4. 变更启动脚本 rm -f /etc/init.d/mysqld cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld-5.5 cp /usr/local/mysql-5.6/support-files/mysql.server /etc/init.d/mysqld-5.6 chmod +x /etc/init.d/mysqld-5.* 5.启动新版本实例 注意:配置文件必须配置正确,如果配置了旧的参数,会导致实例无法启动 /etc/init.d/mysqld-5.6 start 然后观察错误文件,会看到如下报错: 2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'setup_actors' has the wrong structure 2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'setup_objects' has the wrong structure 2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'table_io_waits_summary_by_index_usage' has the wrong structure 2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'table_io_waits_summary_by_table' has the wrong structure 2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'table_lock_waits_summary_by_table' has the wrong structure 2015-08-04 13:16:31 18815 [ERROR] Column count of mysql.threads is wrong. Expected 14, found 3. Created with MySQL 50518, now running 50626. Please use mysql_upgrade to fix this error. 2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'events_stages_current' has the wrong structure 2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'events_stages_history' has the wrong structure 2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'events_stages_history_long' has the wrong structure 2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'events_stages_summary_by_thread_by_event_name' has the wrong structure 2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'events_stages_summary_by_account_by_event_name' has the wrong structure 2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'events_stages_summary_by_user_by_event_name' has the wrong structure 2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'events_stages_summary_by_host_by_event_name' has the wrong structure 6. 运行新版本下的升级脚本进行升级检查,修复mysql库中的主要表 /usr/local/mysql-5.6/bin/mysql_upgrade -u root -proot Warning: Using a password on the command line interface can be insecure. Looking for 'mysql' as: /usr/local/mysql_5.6/bin/mysql Looking for 'mysqlcheck' as: /usr/local/mysql-5.6/bin/mysqlcheck Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql6.sock' Warning: Using a password on the command line interface can be insecure. Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql6.sock' Warning: Using a password on the command line interface can be insecure. mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK mysql.general_log OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK mysql.help_topic OK mysql.host OK mysql.innodb_index_stats OK mysql.innodb_table_stats OK mysql.ndb_binlog_index OK mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.proxies_priv OK mysql.servers OK mysql.slave_master_info OK mysql.slave_relay_log_info OK mysql.slave_worker_info OK mysql.slow_log OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK Running 'mysql_fix_privilege_tables'... Warning: Using a password on the command line interface can be insecure. Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql6.sock' Warning: Using a password on the command line interface can be insecure. Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql6.sock' Warning: Using a password on the command line interface can be insecure. babysitter.abc OK babysitter.account_tactics_daily_availability OK babysitter.andtlhz_new OK 7. 检查完后重启实例 /etc/init.d/mysqld-5.6 restart 配置文件 [client] #default-character-set = utf8 port = 3306 socket = /tmp/mysql6.sock [mysqld] #skip-grant-tables user = mysql port = 3306 socket = /tmp/mysql6.sock pid-file = /usr/local/mysql-5.6/data/mysql-upgrade-master.pid #pid-file = /usr/local/mysql-5.6/data/[主机名].pid #pid-file = /usr/local/mysql-5.6/data/[主机名].pid ################## basedir = /usr/local/mysql-5.6 datadir = /usr/local/mysql-5.6/data server-id = 1 #server-id = 2 #从库1配置 #server-id = 3 #从库2配置 log_slave_updates = 1 log_slave_updates = 0 #从库配置 log-bin = mysql-bin #log-bin = mysql-bin #从库不需要开启binlog binlog_format = mixed binlog_cache_size = 64M max_binlog_cache_size = 128M expire_logs_days = 2 max_binlog_size = 1G binlog-ignore-db = mysql binlog-ignore-db = test binlog-ignore-db = information_schema binlog-ignore-db = performance_schema query_cache_type =0 key_buffer_size = 384M sort_buffer_size = 2M read_buffer_size = 2M read_rnd_buffer_size = 16M join_buffer_size = 2M thread_cache_size = 8 query_cache_size = 32M query_cache_limit = 2M query_cache_min_res_unit = 2K thread_concurrency = 32 table_open_cache = 512 open_files_limit = 10240 back_log = 600 max_connections = 5000 max_connect_errors = 6000 external-locking = FALSE max_allowed_packet = 10M default-storage-engine = MYISAM thread_stack = 192K transaction_isolation = READ-COMMITTED tmp_table_size = 256M max_heap_table_size = 512M bulk_insert_buffer_size = 64M long_query_time = 2 slow_query_log slow_query_log_file = /usr/local/mysql-5.6/data/slow_query.log skip-name-resolve explicit_defaults_for_timestamp = true #新版本关于时间戳的新特性配置 innodb_buffer_pool_size = 512M innodb_data_file_path = ibdata1:256M:autoextend innodb_file_io_threads = 4 innodb_thread_concurrency = 8 innodb_flush_log_at_trx_commit = 2 innodb_log_buffer_size = 16M innodb_log_file_size = 128M innodb_log_files_in_group = 3 innodb_max_dirty_pages_pct = 90 innodb_lock_wait_timeout = 120 innodb_file_per_table = 1 innodb_flush_method = O_DIRECT [mysqldump] quick max_allowed_packet = 10M [mysql] no-auto-rehash safe-updates [mysqlhotcopy] interactive-timeout [myisamchk] key_buffer_size = 256M sort_buffer_size = 256M read_buffer = 2M write_buffer = 2M ################## 以上操作顺序为:从1》从2》主 特别注意配置文件的正确性 磁盘空间足够存放两份旧数据的大小 旧数据不动,以防升级失败,可以回退到旧版本 本文转自andylhz 51CTO博客,原文链接:http://blog.51cto.com/andylhz2009/1844007,如需转载请自行联系原作者

资源下载

更多资源
优质分享App

优质分享App

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

腾讯云软件源

腾讯云软件源

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

Spring

Spring

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

Sublime Text

Sublime Text

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

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