Skip to content

Instantly share code, notes, and snippets.

View cheng470's full-sized avatar
🌴
On vacation

cheng470 cheng470

🌴
On vacation
View GitHub Profile
@cheng470
cheng470 / TestSort.java
Created March 29, 2019 03:18
java.util.Arrays.sort方法中的排序算法在JDK7中已经被替换了。如果违法了比较的约束新的排序算法也许会抛出llegalArgumentException异常。JDK6中的实现则忽略了这种情况。
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* 复现jdk7排序兼容问题
*
* @author jianchengxu
*/
@cheng470
cheng470 / GenChapterName.java
Created September 26, 2018 14:29
生成中文书籍章节
package com.cheng470;
/**
* <p>
* Description:生成中文书籍章节
* </p>
*
* @author XuJianCheng
* @version 1.0
* @since 2018/9/23
@cheng470
cheng470 / config.properties
Created February 7, 2015 08:29
Mybatis 第一个例子优化,优化配置文件
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/test
username=root
password=123456
@cheng470
cheng470 / User.java
Created February 7, 2015 08:05
Mybatis 不使用配置文件例子
package com.test.bean;
public class User {
private Integer id;
private String name;
private String password;
public Integer getId() {
return id;
}
@cheng470
cheng470 / User.java
Created February 7, 2015 06:56
Mybatis 第一个例子
package com.test.bean;
public class User {
private Integer id;
private String name;
private String password;
public Integer getId() {
return id;
}
@cheng470
cheng470 / UserTest.java
Last active August 29, 2015 14:14
Java JDBC with mysql
package com.test.dao.jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.junit.Test;
@cheng470
cheng470 / iife.demo1.js
Last active August 29, 2015 14:12
使用立即调用的函数表达式创建局部作用域
function wrapElements(a) {
var result = [], i, n;
for (i = 0, n = a.length; i < n; i++) {
result[i] = function() { return a[i]; };
}
return result;
}
var wrapped = wrapElements([10, 20, 30, 40, 50]);
var f = wrapped[0];
@cheng470
cheng470 / iife.js
Last active August 29, 2015 14:12
反对使用IIFE的其中一个理由是可读性差,如果你有大量的JavaScript代码都在一段IIFE里,要是想查找IIFE传递的实际参数值,必须要滚动到代码最后。幸运的是,你可以使用一个更可读的模式:
+function () {
};
(function () {
});
void function() {
@cheng470
cheng470 / isReallyNaN.js
Created December 23, 2014 05:41
由于 NaN 是 JavaScript 中唯一一个不等于其自身的值,因此,你可以随时通过检查一个值是否等于其自身的方式来测试该值是否是 NaN。
function isReallyNaN(x) {
return x !== x;
}
@cheng470
cheng470 / echarts.html
Created December 16, 2014 03:04
ECharts Hello World
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>ECharts</title>
</head>
<body>
<!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" style="height:400px"></div>