Skip to content

Instantly share code, notes, and snippets.

@turbotree
turbotree / 详情
Created September 9, 2014 02:43
汉字所占字节与编码方式有关
public static void main(String []args) throws UnsupportedEncodingException {
// 运行结果:2
System.out.println("柳峰".getBytes("ISO8859-1").length);
// 运行结果:4
System.out.println("柳峰".getBytes("GB2312").length);
// 运行结果:4
System.out.println("柳峰".getBytes("GBK").length);
// 运行结果:6
System.out.println("柳峰".getBytes("UTF-8").length);
}
@turbotree
turbotree / 垂直居中
Created September 5, 2014 03:48
CSS垂直水平完全居中手册
它是一行的吗?
  有时侯元素可以表现像垂直居中,只是因为它们有相等的上下padding
  
  
  .link {
padding-top: 30px;
padding-bottom: 30px;
}
@turbotree
turbotree / 点击一个body隐藏块
Created August 13, 2014 11:08
点击一个body隐藏块
var run = true;
function aa(){
run = false;
}
$("body").click(function(){
if(run){
$("#cancel").hide();
$("#fahuo").hide();
@turbotree
turbotree / 使用Jquery异步提交表单
Created August 8, 2014 04:13
使用Jquery异步提交表单
$.ajax({
url:"mobileSurveyAction_addSurvey.action",//提交地址
data:$("#form1").serialize(),//将表单数据序列化
type:"POST",
dataType:"json",
success:function(result){
if (result.success == '100'){
$("#mySection").hide();
$(".footer").hide();
$("#alertMsg").show();
@turbotree
turbotree / 省市表
Created March 20, 2014 08:51
中国省市表(mysql版)
DROP TABLE IF EXISTS `province`;
CREATE TABLE `province` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=gbk;
-- ----------------------------
-- Records of province
-- ----------------------------
INSERT INTO `province` VALUES ('1', '北京市');
@turbotree
turbotree / gist:9287453
Last active August 29, 2015 13:56 — forked from fankay/gist:5255473
在Java中调用存储过程
DELIMITER //
CREATE PROCEDURE insert_test(IN uname VARCHAR(50),IN uaddress VARCHAR(50))
BEGIN
INSERT INTO t_test(username,address) VALUES(uname,uaddress);
END//
DELIMITER ;
@turbotree
turbotree / youjian.html
Created November 29, 2013 14:43
自定义右键行为(通过事件对象获得鼠标的坐标(x,y))
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>demo</title>
<style type="text/css">
html{
@turbotree
turbotree / DownImages
Created November 4, 2013 01:53
利用jsoup获取网页图片链接并下载到本地
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
@turbotree
turbotree / 两种重写equals的方法
Created October 30, 2013 01:54
两种重写equals的方法
public class User {
private String name;
private String code;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@turbotree
turbotree / Account
Last active December 25, 2015 14:29 — forked from KingSirLee/Account
数组版Atm系统
public class Account {
private String username;
private String password;
private double money;
private boolean enable;
public String getUsername() {
return username;
}