program collections

Java

byte & 0xff

byte[] b = new byte[1];b[0] = -127;System.out.println("b[0]:"+b[0]+"; b[0]&0xff:"+(b[0] & 0xff));//output:b[0]:-127; b[0]&0xff:129

计算机内二进制都是补码形式存储:

b[0]: 补码,10000001(8bit)

b[0]int输出:int(32bit),补位1。11111111 11111111 11111111 10000001(32bit)
和原数一致

b[0]&0xff:11111111 11111111 11111111 10000001(32bit) & 11111111 =
00000000 00000000 00000000 10000001

低精度转成高精度数据类型,有两种扩展方案。(1)补零扩展 (2)符号位扩展

对于正数两种是一样的。

  • 使用补零扩展能够保证二进制存储的一致性,但不能保证十进制值不变

  • 使用补符号位扩展能够保证十进制值不变,但不能保证二进制存储的一致性

对于有符号类型,Java使用的是补符号位扩展,这样能保证十进制的值不变

return break

break is used to exit (escape) the for-loop, while-loop, switch-statement that you are currently executing.
return will exit the entire method you are currently executing (and possibly return a value to the caller, optional).

inputstream byte[] to String


byte[] buffer = new byte[17];if (is != null) {int size = is.read(buffer);if(size > 0 ){String Str = new String(buffer,0,size);}}

Stm32 send packet

byte[] packet = new byte[len];packet[0] = (byte) type;packet[1] = (byte) len;packet[2] = (byte) seq;packet[3] = (byte)(isreset?1:0);packet[4] = (byte) vx;packet[5] = (byte)(vx >>8);packet[6] = (byte) vy;packet[7] = (byte)(vy >>8 );// System.arraycopy(command.toDatas(), 0, packet, 3, command.getLen());int Seq = (datas[0]&0XFF);int vx = (datas[1]&0XFF) | ((datas[2])<<8));int Vy = ((datas[3]&0XFF) | ((datas[4])<<8));boolean Motostatel = ((datas[4] & (1 << 1))!=0);boolean Motostater = ((datas[4] & (1 << 2))!=0);
  • System.arraycopy(Object src,int srcPos,Object dest,int destPos,int length)

  • src:源数组

  • srcPos:源数组起始位置

  • dest:目标数组

  • destPos:目标数组起始位置

  • length:长度

Tips: srcdest是要可以互相转换或是同类型的数组

Tips:

可以自己复制自己


int[] src ={0,1,2,3,4,5,6}; System.arraycopy(src,0,src,3,3);// output:{0,1,2,0,1,2,6}

生成一个长度为length的临时数组,将fun数组中srcPos
srcPos+length-1之间的数据拷贝到临时数组中,再执行System.arraycopy(临时数组,0,fun,3,3)

new Semaphore(0)


Semaphore semaphore = new Semaphore(0);try {semaphore.acquire();} catch (InterruptedException e) {e.printStackTrace();}//semaphore.release();

初始化信号量为0,semaphore.acquire()线程会阻塞。直到semaphore.release()之后 信号量变为1。

mysql

1045 access denied for user 'root'@'localhost' using password yes

忘记localhost密码,密码错误

  • step1,找到mysql安装目录下my.ini。在[mysql]下添加 skip-grant-tables

  • step2,重启mysql服务

  • step3,以管理员身份运行 cmd. 输入mysql -u root -p,直接回车

  • step4,输入use mysql

  • step5,mysql 5.6以前的,输入UPDATE mysql.user SET Password=PASSWORD('123456') WHERE User='root';

    mysql 5.6以后的,输入UPDATE mysql.user SET authentication_string=PASSWORD('root') WHERE USER='root';

Android

权限

root

linux系统中是只有root权限普通权限,root即是最高权限。

Android获取root其实和Linux获取root权限一样。Linux下获取root权限的时候就是执行sudo或者su

Android本身就不想让你获得Root权限,大部分手机出厂的时候根本就没有su这个程序。所以你想获得Android的root权限,第一步就是要把编译好的su文件拷贝到Android手机的/system/bin或者/system/xbin/目录下。接下来你可以在Android手机的adb shell或者串口下输入su了。

getColor() 过时


// 过时
textView.setTextColor(getResources().getColor(R.color.text_color));textView.setTextColor(ContextCompat.getColor(this,R.color.text_color));

Installation error:INSTALL_FAILED_UID_CHANGED

尝试通过ADB删除产生冲突的数据文件


adb rm -rf /data/data/<your.package.name>

setHeight no use

当设置的高度比原来默认的高度要小时,调整setHeight是不生效的。


editText=(EditText)findViewById(R.id.myEditText);// editText.setHeight(10); //不生效editText.getLayoutParams().height = 100; 

Installation error:INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

1.1 包名大写了

2.2 缺少AndroidManifest.xml文件

Error:Error converting bytecode to dex

1.1 包重复

2.2 build本身问题, 只需要clean and rebuild 一下

EditText光标颜色

EditText 有一个属性 android:textCursorDrawable 用来控制光标的颜色。android:textCursorDrawable="@null","@null"作用是让光标颜色和text color一样

发现了以元素'd:skin'开头的无效内容

把有问题的devices.xml删除,在Android SDK 里面的tool\lib 下找到devices.xml拷贝到那个文件夹。

finished with non-zero exit value 2

重复的jar包,删除引用的包,同时删除modulebuild.gradle文件的引用。

border


<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"><solid android:color="#418bdc"/><corners android:radius="2dp"/><stroke android:width="2dp" android:color="#303f9f"/><padding android:left="1dp" android:top="1dp" android:right="1dp" android:bottom="1dp" />
</shape>

VideoView播放视频无法全屏问题

重写VideoView


import android.content.Context;
import android.util.AttributeSet;
import android.widget.VideoView;/*** Created by lijingnan on 12/04/2017.*/
public class CustomerVideoView extends VideoView {public CustomerVideoView(Context context) {super(context);}public CustomerVideoView(Context context, AttributeSet attrs) {super(context, attrs);}public CustomerVideoView(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);}@Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {// 其实就是在这里做了一些处理。int width = getDefaultSize(0, widthMeasureSpec);int height = getDefaultSize(0, heightMeasureSpec);setMeasuredDimension(width, height);}
}

退出程序

  • KillProcess
//结束当前程序的进程  android.os.Process.killProcess(android.os.Process.myPid());

Tips:android中所有的activity都在主进程中,在Androidmanifest.xml中可以设置成启动不同进程,Service不是一个单独的进程也不是一个线程。

当你Kill掉当前程序的进程时也就是说整个程序的所有线程都会结束,Service也会停止,整个程序完全退出。

  • System.exit

//0表示正常退出,1表示异常退出(只要是非0的都为异常退出),即使不传0也可以退出,该参数只是通知操作系统该程序是否是正常退出
System.exit(0),System.exit(1)

Can't create handler inside thread that has not called Looper.prepare()

Handler对象与其调用者在同一线程中,如果在Handler中设置了延时操作,则调用线程也会堵塞。每个Handler对象都会绑定一个Looper对象,每个Looper对象对应一个消息队列(MessageQueue)。如果在创建Handler时不指定与其绑定的Looper对象,系统默认会将当前线程的Looper绑定到该Handler上。

在主线程中,可以直接使用new Handler()创建Handler对象,其将自动与主线程的Looper对象绑定;在非主线程中直接这样创建Handler则会报错,因为Android系统默认情况下非主线程中没有开启Looper,而Handler对象必须绑定Looper对象。

1.手动开启Looper,然后将其绑定到Handler对象上


final Runnable runnable = new Runnable() {@Overridepublic void run() {//执行耗时操作try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}}
};
new Thread() {public void run() {Looper.prepare();new Handler().post(runnable);//在子线程中直接去new 一个handlerLooper.loop();    //这种情况下,Runnable对象是运行在子线程中的,可以进行联网操作,但是不能更新UI}
}.start();

2.通过Looper.getMainLooper(),获得主线程的Looper


final Runnable runnable = new Runnable() {@Overridepublic void run() {//执行耗时操作try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}}
};
new Thread() {public void run() {new Handler(Looper.getMainLooper()).post(runnable);//这种情况下,Runnable对象是运行在主线程中的,不可以进行联网操作,但是可以更新UI}
}.start();

xxx is not an enclosing class

  • 一般出现在内部类中,若要创建内部类的实例,需要有外部类的实例才行,或者是将内部类设置为静态的,添加 static 关键字

public class A {  public class B {  }  
}A a = new A();  
A.B ab = a.new B();  

there is no default constructor available in ...

子类中使用了无参构造方法,而它的父类中至少有一个没有无参的构造方法。

  • 如果一个类没有构造方法,会有一个默认的无参构造方法。
  • 如果显示的定义了带参构造方法则默认的无参构造方法就会失效。

  • 一个类只要有父类,那么在它实例化的时候,一定是从顶级的父类开始创建

子类使用无参构造函数创建子类对象时,会去先递归调用父类的无参构造方法,这时候如果某个类的父类没有无参构造方法就会出错

错误实例:


public class Parent{int aga;public Parent(int age){this.aga = age;}}public class Child extends Parent{public Child(){/** 默认调用父类的无参构造方法 * super();*/}}

如果子类使用带参参构造函数创建子类对象时,没有使用super先调用父类的带参构造方法,这时默认会调用父类的无参构造方法,如果父类没有也会报错

错误实例:


public class Parent{int aga;public Parent(int age){this.aga = age;}}public class Child extends Parent{public Child(int age){/** 默认调用父类的无参构造方法 * super();*/}}

上述也可以在子类调用父类的有参构造函数

public class Child extends Parent{public Child(int age){super(age);}}

JFinal

javax.servlet.ServletContext

BUG :The type javax.servlet.ServletContext cannot be resolved. It is indirectly referenced from required

Solution: 把tomcat/lib目录中的jsp-api.jarservlet-api.jar导入到项目的web/lib目录下。

cast

BUG :Jfinal Db.findFirst java.lang.Long cannot be cast to java.lang.Integer

Solution:return Db.findFirst(sql).getLong("count").intValue();

错误: 编码GBK的不可映射字符

BUG : eclipse导出javadoc时的错误: 编码GBK的不可映射字符

Solution:-encoding UTF-8 -charset UTF-8

solution

JavaScript

数组删除元素

var arr = [1,2,3,4];arr.splice(1,1);/*** Array(3)* 0:1* 1:3* 2:4*/var arr = [1,2,3,4];delete arr[1];/*** Array(3)* 0:1* 1:undefined* 2:3* 3:4*/

delete arr[1],arr[1]变为undefined,数组的索引也保持不变

不要使用包装对象来创建原始类型变量

在js中我们可以使用String()Number()Boolean()构造函数来显式的创建包装对象


// String("test") , 一个字符串对象
// Number(5),一个数值对象
// Boolean(false),一个布尔对象// Don't do it!var x = new Boolean(false);
if (x) {alert('hi');  // Shows 'hi'.
}var x = Boolean(0);
if (x) {alert('hi');  // This will never be alerted.
}
typeof Boolean(0) == 'boolean';
typeof new Boolean(0) == 'object';

script文件异步加载

<script src="path/to/myModule.js" defer></script>
<script src="path/to/myModule.js" async></script>

<script>标签打开defer或async属性,脚本就会异步加载。渲染引擎遇到这一行命令,就会开始下载外部脚本,但不会等它下载和执行,而是直接执行后面的命令。

  • defer与async的区别是:defer要等到整个页面在内存中正常渲染结束(DOM 结构完全生成,以及其他脚本执行完成),才会执行;async一旦下载完,渲染引擎就会中断渲染,执行这个脚本以后,再继续渲染。一句话,defer是“渲染完再执行”,async是“下载完就执行”。另外,如果有多个defer脚本,会按照它们在页面出现的顺序加载,而多个async脚本是不能保证加载顺序的。

cookie只区分域名,不管端口

  • cookie安全

1.1 httponly:设置了httponly属性,无法通过脚本获取到cookie信息

2.2 secure:设置了secure属性,cookie只能通过https安全传输,并不会通过未加密的http连接发送

3.3 sameSite:目前只有chrome和firefox支持,用于定义cookie如果跨域发送

debug

debugger

可以在JavaScript手动添加断点


debugger;

DOM

  • 右击DOM元素,'Force Element State',展开子菜单可以看到几种常见的伪类::active, :hover, :focus, and :visited。可以调试伪类。

  • 右击DOM元素,可以看到一个名为Break on的选项,展开有Subtree Modifications,Attributes Modifications以及Node Removal三个选项。(当JS尝试改变DOM元素时,给元素添加的断点便会触发。)

a) Subtree Modifications,当添加,改变,删除子元素时触发

b) Attributes Modifications,当元素属性被改变时触发

c) Node Removal,当移除元素时触发

Audits

Audits可以检查页面的性能方面存在的问题,并给出优化意见

Jquery

Cannot read property 'msie' of undefined

原因是$.browser这个api从jQuery1.9开始就正式废除,js代码里只要用到$.browser就会报这个错。

jQuery官方说明

1.1 可以替换成1.9之前的版本

2.2 使用插件jQuery Migrate,这个插件会恢复在更新版本中废弃的API

3.3 在jQuery文件之后,$.browser的代码之前 加载以下代码


jQuery.browser={};(function(){jQuery.browser.msie=false; jQuery.browser.version=0;if(navigator.userAgent.match(/MSIE ([0-9]+)./)){ jQuery.browser.msie=true;jQuery.browser.version=RegExp.$1;}})();

$.ajax

data封装不加入JSON.stringify(data),会变成字符串拼接,'name=vinxent&age=21',有点和get方法相像。

若使用JSON.stringify(data),则会传输json对象'{name;'vinxent', age:21}'。

所以,在一般场景来说,get方法无需JSON.stringify,post方法需要。

Jquery动态绑定事件


//Jquery绑定事件$('.div').click(function(){});//Jquery动态绑定事件$('.div').on('click',function(){});<-- 当页面动态刷新时,新加载的元素依然可以绑定事件 -->$(document).on('click','.div',function(){});

Jquery on绑定hover事件

不能用on处理hover事件,因为Jqueryhover事件是一个封装的事件,不是真正的事件。

所以使用mouseentermouseleave来代替鼠标悬浮和离开事件。


$(document).on('mouseenter', '.div', function() {
});$(document).on('mouseleave', '.div', function() {
});

Jquery获取时间并且格式化


Date.prototype.format = function(format) {/** eg:format="YYYY-MM-dd hh:mm:ss";*/var o = {"M+" :this.getMonth() + 1, // month"d+" :this.getDate(), // day"h+" :this.getHours(), // hour"m+" :this.getMinutes(), // minute"s+" :this.getSeconds(), // second"q+" :Math.floor((this.getMonth() + 3) / 3), // quarter"S" :this.getMilliseconds()// millisecond}if (/(y+)/.test(format)) {format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));}for ( var k in o) {if (new RegExp("(" + k + ")").test(format)) {format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k]: ("00" + o[k]).substr(("" + o[k]).length));}}return format;
}var startTime = new Date().format("yyyy-MM-dd 00:00:00");
var endTime = new Date().format("yyyy-MM-dd hh:mm:ss");

滚动条滚动底部

  • scrollTop([val]) 获取匹配元素相对滚动条顶部的偏移。

  • scrollLeft([val]) 获取匹配元素相对滚动条左侧的偏移。

  • scrollHeight 滚动条高度


$(".div").scrollTop( $(".div")[0].scrollHeight);

Jquery size( )和length

size()jQuery 提供的函数,而 length是属性。两者的取值是一样的。

页面之间传值

//页面一location.href = "href2.html?id=3";
   //页面二var _url = document.URL;var _urlParam = _url.split('?')[1];var _value = _urlParam.split('=')[1];

也可以使用jquery.params.js $.query.get("id");

### 灵活运用三目运算符

 (_list.equipStatus ==1?"运行中":(_list.repairStatus ==2?"维修中":"待确认"))

正确引用jQuery

  1. 尽量在body结束前才引入jQuery,而不是在head中。
    2.借助第三方提供的CDN来引入jQuery,同时注意当使用第三方CDN出现问题时,要引入本地的jQuery文件。
    3.如果在</body>前引入script文件的话,就不用写document.ready,因为这时执行js代码时DOM已经加载完毕了。

<body>  <script src="http://lib.sinaapp.com/js/jquery11/1.8/jquery.min.js"></script>  <script>window.jQuery  document.write('<script src="jquery1.8.min.js">\x3C/script>')</script>  
</body> 

优化jQuery选择器


<div id="nav" class="nav">  <a class="home" href="http://www.jquery001.com">jQuery学习网</a>  <a class="articles" href="http://www.jquery001.com/articles/">jQuery教程</a>  
</div>

如果我们选择class为home的a元素时,可以使用下边代码:

$('.home'); //1

$('#nav a.home'); //2

$('#nav').find('a.home'); //3

  1. 方法1,会使jQuery在整个DOM中查找class为home的a元素,性能可想而知。
    2.方法2,为要查找的元素添加了上下文,在这里变为查找id为nav的子元素,查找性能得到了很大提升。
    3.方法3,使用了find方法,它的速度更快,所以方法三最好。

关于jQuery选择器的性能优先级,ID选择器快于元素选择器,元素选择器快于class选择器。因为ID选择器和元素选择器是原生的JavaScript操作,而类选择器不是。

缓存jQuery对象

缓存jQuery对象可以减少不必要的DOM查找,关于这点大家可以参考下缓存jQuery对象来提高性能。


// 糟糕
h = $('#element').height();
$('#element').css('height',h-20);// 建议
$element = $('#element');
h = $element.height();
$element.css('height',h-20);

使用子查询缓存的父元素

正如前面所提到的,DOM遍历是一项昂贵的操作。典型做法是缓存父元素并在选择子元素时重用这些缓存元素。


// 糟糕
var$container = $('#container'),$containerLi = $('#container li'),$containerLiSpan = $('#container li span');
// 建议 (高效)
var$container = $('#container '),$containerLi = $container.find('li'),$containerLiSpan= $containerLi.find('span');

精简jQuery代码

一般来说,最好尽可能合并函数。


// 糟糕
$first.click(function(){$first.css('border','1px solid red');$first.css('color','blue');
});
// 建议
$first.on('click',function(){$first.css({'border':'1px solid red','color':'blue'});
});

减少DOM操作

最小化DOM更新

重布局和重绘是WEB页面中最常见的也是最昂贵的两种操作。
当改变样式,而不改变页面几何布局时,将会发生重绘。隐藏一个元素或者改变一个元素的背景色时都将导致一次重绘。
当对页面结构进行更新时,将导致页面重布局。

//糟糕for(var i=0; i<10000; i++){$("#main table").append("<tr><td>aaaa</td></tr>");}//建议var tablerow = "";for(var i=0; i<10000; i++){tablerow  += "<tr><td>aaaa</td></tr>";}
$("#main table").append(tablerow);

prop和attr方法

对于元素自身的固有属性 使用 prop 对于自定义的属性使用attr方法

例:获取选中的checkbox的value值

$("input[type=checkbox]").each(function() {if(true == $(this).prop("checked")) {alert($(this).attr("value"));}});

each遍历

each实现全选或是取消全选。

$("#selectAll").click(function() {if($("#selectAll").prop("checked")) {$("#selectAll input[type=checkbox]").each(function() {$(this).prop("checked", "true");});} else {$("#selectAll input[type=checkbox]").each(function() {$(this).removeAttr("checked");});}});

layer.js

父页面和子页面传值

1.1 访问父页面值


// "id" 父页面元素
var parentId=parent.$("#id").val();

2.2 访问父页面方法


var parentMethod=parent.getMethod();

3.3 给父页面传值

// "id" 父页面元素parent.$('#id').text('');

4.4 关闭弹出的子页面窗口


//获取窗口索引  var index = parent.layer.getFrameIndex(window.name); //关闭弹出的子页面窗口  parent.layer.close(index);

5.5 子页面调用父页面刷新


parent.location.reload();

uploadify.js

error placeholder element

这是因为input 元素必须有id,并且用id初始化uploadify函数。否则就报错。

chart.js

Uncaught TypeError: Cannot read property 'length' of null

这个问题是因为js代码执行的时候canvas还没有被创建。可以将初始化图表代码片段放到window.onload后面


window.onload = function() {var ctx = document.getElementById("myChart");var lineChart = new Chart(ctx, {type: 'line',data: {labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],datasets: [{label: "2015",data: [10, 8, 6, 5, 12, 8, 16, 17, 6, 7, 6, 10]}]}})
}

The problem is that when your code executes, the canvas has not been created yet. You should wrap your code inside a function and assign that function to window.onload event. You can see the sample code below.

Cannot read property 'transition' of null

Try to call mychart.update() after setting the new data... that solved the problem for me.

Browser

Slow network is detected. Fallback font will be used while loading

新版本的Chrome在网络环境较差的时候会在控制台输出Slow network is detected. Fallback font will be used while loading,但有时会对调试造成不便,可以在chrome配置中禁用该项: 

地址栏输入chrome://flags/#enable-webfonts-intervention-v2,并设置为Disabled;重启Chrome。

AngularJS

$sce

$sce is included by default starting with angular 1.2- so you don't need sanitize anymore in order to get $sce. So, with 1.2, you can pass $sce in as any other service. But make sure your angular is version 1.2 (in case you checked the sanitize version vs core).

获取body元素


// $document 服务$document[0].bodyangular.element(document).find('body')

1487780-20181018105344395-2049328884.png

防抖动输入


<body ng-controller="myCtrl"><div ng-app="App" ng-controller="Ctrl" class="app"><button ng-click="inc()">Add</button><span>{{ val }}</span></div><script>angular.module("App", []).controller("Ctrl", ['$scope', '$debounce', function($scope, $debounce) {$scope.shouldBeFocus = true;$scope.val = 0;$scope.inc = function() {$debounce(increase, 300);};var increase = function() {$scope.val++;}}]).factory('$debounce', ['$rootScope', '$browser', '$q', '$exceptionHandler',function($rootScope, $browser, $q, $exceptionHandler) {var deferreds = {},methods = {},uuid = 0;function debounce(fn, delay, invokeApply) {var deferred = $q.defer(),promise = deferred.promise,skipApply = (angular.isDefined(invokeApply) && !invokeApply),timeoutId, cleanup,methodId, bouncing = false;// check we dont have this method already registeredangular.forEach(methods, function(value, key) {if(angular.equals(methods[key].fn, fn)) {bouncing = true;methodId = key;}});// not bouncing, then register new instanceif(!bouncing) {methodId = uuid++;methods[methodId] = {fn: fn};} else {// clear the old timeoutdeferreds[methods[methodId].timeoutId].reject('bounced');$browser.defer.cancel(methods[methodId].timeoutId);}var debounced = function() {// actually executing? clean method bankdelete methods[methodId];try {deferred.resolve(fn());} catch(e) {deferred.reject(e);$exceptionHandler(e);}if(!skipApply) $rootScope.$apply();};timeoutId = $browser.defer(debounced, delay);// track id with methodmethods[methodId].timeoutId = timeoutId;cleanup = function(reason) {delete deferreds[promise.$$timeoutId];};promise.$$timeoutId = timeoutId;deferreds[timeoutId] = deferred;promise.then(cleanup, cleanup);return promise;}// similar to angular's $timeout canceldebounce.cancel = function(promise) {if(promise && promise.$$timeoutId in deferreds) {deferreds[promise.$$timeoutId].reject('canceled');return $browser.defer.cancel(promise.$$timeoutId);}return false;};return debounce;}]);;</script></body>

this in AngularJS


angular.module("App", []).controller("Ctrl", function($scope) {// this controllerconsole.log("controller",this);$scope.foo = function() {// this scopeconsole.log("foo",this);};var foo2 = function() {// this windowsconsole.log("foo2",this);}$scope.foo();foo2();});

1487780-20181019153511051-584357084.png

angular.copy() angular.extend()

angular.copy(source, [destination]); // source: copy的对象. 可以使任意类型, 包括null和undefined. destination:接收的对象 返回复制或更新后的对象

  • 如果省略了destination,一个新的对象或数组将会被创建出来;

  • 如果提供了destination,则source对象中的所有元素和属性都会被复制到destination中;

  • 如果source不是对象或数组(例如是null或undefined), 则返回source;

  • 如果source和destination类型不一致,则会抛出异常。

angular.extend(destination, source);

  • 复制src对象中的属性到dst对象中. 支持多个src对象. 如果你不想改变一个对象,你可以把dst设为空对象{}: var object = angular.extend({}, object1, object2).

  • 注意: angular.extend不支持递归复制.

Git

push 需要输入用户名和密码

换成ssh方式


git remote -v // origin https://github.com/xxxxxx/xxxx.git (fetch)
// origin https://github.com/xxxxxx/xxxx.git (push)git remote rm origingit remote add origin git@github.com:xxxxx/xxxx.gitgit push origin

git默认用notepad++ 打开


git config --global core.editor "'D:\Notepad++\notepad++.exe' -multiInst -notabbar -nosession -noPlugin '$*'"

npm

npm WARN saveError ENOENT: no such file or directory ... package.json

npm init -f

生成一个package.json

React

render(, document.body);

warning.js:36 Warning: render(): Rendering components directly into document.body is discouraged, since its children are often manipulated by third-party scripts and browser extensions. This may lead to subtle reconciliation issues. Try rendering into a container element created for your app.


ReactDOM.render(<Greeter />, document.getElementById('react_container'));

转载于:https://www.cnblogs.com/chenjy1225/p/9661237.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/249505.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

软件测试问题

1.什么是兼容性测试?兼容性测试侧重哪些方面? 主要检验的是软件的可移植性&#xff0c;检查软件在不同的硬件平台软件平台上是否可以正常的运行。 细分会有&#xff1a;平台的兼容&#xff0c;网络兼容&#xff0c;数据库兼容&#xff0c;数据格式的兼容等。 2.常用的测试方法…

Spring注解源码分析

我们知道如果想使用spring注解你需要在applicationContext.xml配置文件中设置context:component-scan base-packagexxx’这样spring会帮助我们扫描你所设置的目录里面所有的Bean&#xff0c;如果Bean上面有相应的Service,Controller注解&#xff08;当然还有其他的&#xff0c;…

linux查看和修改PATH环境变量的方法

查看PATH&#xff1a;echo $PATH以添加mongodb server为列修改方法一&#xff1a;export PATH/usr/local/mongodb/bin:$PATH//配置完后可以通过echo $PATH查看配置结果。生效方法&#xff1a;立即生效有效期限&#xff1a;临时改变&#xff0c;只能在当前的终端窗口中有效&…

GLog 初始化说明

#include <iostream> #include <glog/logging.h>int main(int argc, char* argv[]) {google::InitGoogleLogging(argv[0]);FLAGS_logtostderr false; // 是否将日志输出到stderr而非文件。FLAGS_alsologtostderr false; //是否将日志输出到文件和stderr&#xff…

Spring ConfigurationClassPostProcessor Bean解析及自注册过程

一bean的自注册过程 二,自注册过程说明 1 configurationclassparser解析流程 1、处理PropertySources注解&#xff0c;配置信息的解析 2、处理ComponentScan注解&#xff1a;使用ComponentScanAnnotationParser扫描basePackage下的需要解析的类(SpringBootApplication注解也包…

新华社:华尔街专家警告2019年美股或面临剧烈调整

新华社&#xff1a;华尔街专家警告2019年美股或面临剧烈调整 2018年08月14日 12:34 新华社新浪财经APP缩小字体放大字体收藏微博微信分享转载于:https://www.cnblogs.com/hjlweilong/p/9664677.html

java定义注解

小伙伴们。今天我们来说说注解、标志 。针对java不同版本来说&#xff0c;注解的出现是在jdk1.5 但是在jdk1.5版本使用注解必须继续类的方法的重写&#xff0c;不能用于实现的接口中的方法实现&#xff0c;在jdk1.6环境下对于继续和实现都是用。 jdk1.5版本内置了三种标准的注…

2018.09.18 while循环

** "loop" 循环 注意要有引号。 **pass 过 #打印 1-100start 1 while start < 101:print("loop",start)start 1 #打印1-49&#xff0c;81-100. 60-80的平方start 1 while start <101 :if start >49 and start < 60:passelif start >5…

2019第二周作业

基础作业 实验代码 #include<stdlib.h> int main(void) {FILE*fp;int num[4],i,b,max;char op;if((fpfopen("c:\\tmj.txt","r"))NULL){ printf("File open error!\n"); exit(0);}for(i0;i<4;i){fscanf(fp,"%d%c",&nu…

实验一(高见老师收)

学 号201521450016 中国人民公安大学 Chinese people’ public security university 网络对抗技术 实验报告 实验一 网络侦查与网络扫描 学生姓名 陈璪琛 年级 2015 区队 五 指导教师 高见 信息技术与网络安全学院 2018年9月18日 实验任务总纲 2018—2019学年…

GitHub笔记(二)——远程仓库的操作

二 远程仓库 1 创建联系 第1步&#xff1a;创建SSH Key。在用户主目录下&#xff0c;看看有没有.ssh目录&#xff0c;如果有&#xff0c;再看看这个目录下有没有id_rsa和id_rsa.pub这两个文件&#xff0c;如果已经有了&#xff0c;可直接跳到下一步。如果没有&#xff0c;打开S…

QT 子窗体 最大化 界面显示不对

QT 子窗体 最大化 复原 遇到的问题 项目中有个需求&#xff0c;主窗体中嵌套子窗体&#xff0c;需要将子窗体最大化显示和复原。 查了很多资料&#xff0c;基本上都是提到&#xff1a;QT中窗口部件QWidget成员函数showFullScreen();是用于将窗口部件全屏显示&#xff0c;但是他…

Spring 钩子之BeanFactoryPostProcessor和BeanPostProcessor

BeanFactoryPostProcessor和BeanPostProcessor这两个接口都是初始化bean时对外暴露的入口之一&#xff0c;和Aware类似&#xff08;PS:关于spring的hook可以看看Spring钩子方法和钩子接口的使用详解讲的蛮详细&#xff09;本文也主要是学习具体的钩子的细节&#xff0c;以便于实…

什么是HTML DOM对象

HTML DOM 对象 HTML DOM Document 对象 Document 对象 每个载入浏览器的 HTML 文档都会成为 Document 对象。 Document 对象使我们可以从脚本中对 HTML 页面中的所有元素进行访问。 提示&#xff1a;Document 对象是 Window 对象的一部分&#xff0c;可通过 window.document 属…

Python3 matplotlib的绘图函数subplot()简介

Python3 matplotlib的绘图函数subplot()简介 一、简介 matplotlib下, 一个 Figure 对象可以包含多个子图(Axes), 可以使用 subplot() 快速绘制, 其调用形式如下 : subplot(numRows, numCols, plotNum) 图表的整个绘图区域被分成 numRows 行和 numCols 列 然后按照从左到右&…

signal(SIGHUP, SIG_IGN);

signal(SIGHUP, SIG_IGN); 的理解转载于:https://www.cnblogs.com/lanjiangzhou/p/10505653.html

spring钩子

Spring钩子方法和钩子接口的使用详解 前言 SpringFramework其实具有很高的扩展性&#xff0c;只是很少人喜欢挖掘那些扩展点&#xff0c;而且官方的Refrence也很少提到那些Hook类或Hook接口&#xff0c;至于是不是Spring官方有意为之就不得而知。本文浅析一下笔者目前看到的S…

【bitset 技巧 分块】bzoj5087: polycomp

神仙zq发现了${n^2\sqrt n}\over 32$做法 Description 你有三个系数为0,1的多项式f(x),g(x),h(x)求f(g(x)) mod h(x)为方便起见&#xff0c;将答案多项式所有系数对2取模输出即可如果f(x)Sigma(Ak * Xk)则f(g(x))Sigma(Ak(g(x))KInput 一共三行&#xff0c;每行一个多项式,分别…

day 012 生成器 与 列表推导式

生成器的本质就是迭代器&#xff0c;写法和迭代器不一样&#xff0c;用法一样。 获取方法&#xff1a; 1、通过生成器函数 2、通过各种推导式来实现生成器 3、通过数据的转换也可以获取生成器 例如&#xff1a; 更改return 为 yield 即成为生成器 该函数就成为了一个生成器函数…

数据库设计注意事项和原则

引言数据库设计是信息系统设计的基础&#xff0c;一个好的数据库设计在满足了软件需求之外&#xff0c;还要易维护、易扩充等等要求。当然&#xff0c;对专家们反复强调的数据的一致性、冗余性、访问效率等问题的解决&#xff0c;很大程度上取决于数据库设计者的经验和专业水平…