Skip to content

Instantly share code, notes, and snippets.

View jmpcyc's full-sized avatar
🎯
Focusing

jmpcyc jmpcyc

🎯
Focusing
View GitHub Profile
@jmpcyc
jmpcyc / validate.html
Created September 15, 2014 07:23
A simple demo of validating input by JavaScript
<!doctype html>
<html lang="zh-cmn-Hans-CN">
<head>
<meta charset="utf-8">
<title>wiki validate password demo</title>
<style type="text/css" rel="stylesheet">
#pwd {
width: 80%;
border-width: 2px;
@jmpcyc
jmpcyc / CenterImage.css
Created September 12, 2014 02:25
Center an Image using CSS
/*center an image */
img.center {
display: block;
margin-left: auto;
margin-right: auto;
}
@jmpcyc
jmpcyc / BackgroundImageFullScreen.css
Last active August 29, 2015 14:06
How to make background image full screen ? Try this.
html {
background: url(img/background.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
@jmpcyc
jmpcyc / ConcurrentCarMonitor
Created December 30, 2013 05:07
委托给线程安全容器的car监视器
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class ConcurrentCarMonitor {
private final ConcurrentHashMap<String,Point> locations;
public ConcurrentCarMonitor(Map<String,Point> locations){
this.locations = new ConcurrentHashMap<String,Point>(locations);
}
@jmpcyc
jmpcyc / CarMonitor
Created December 29, 2013 09:11
Car监视器类
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class CarMonitor {
private final Map<String,MutablePoint> locations;
public CarMonitor(Map<String,MutablePoint> locations){
//确保传入的locations引用在其他作用域修改不会影响类中的locations状态
this.locations = deepClone(locations);
<!DOCTYPE html> <!-- HTML5 doctype 不区分大小写 -->
<html lang="zh-cmn-Hans-CN"> <!-- 更加标准的 lang 属性写法 http://zhi.hu/XyIa -->
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <!-- 优先使用IE最新版本和 Chrome -->
<!-- width=device-width 会导致 iPhone 5 添加到主屏后以 WebAPP 全屏模式打开页面时出现黑边 http://bigc.at/ios-webapp-viewport-meta.orz -->
<meta name ="viewport" content ="initial-scale=1.0, maximum-scale=3, minimum-scale=1, user-scalable=no">
@jmpcyc
jmpcyc / bind.js
Created May 28, 2013 16:57
ECScript3中模仿ECScript5中的bind方法
Function.prototype.bind = Function.prototype.bind || function(o){
var args = [];
var self = arguments.callee;
var len = arguments.length;
if(len > 1){
for(var i = 1; i < len; i++){
args.push(arguments[i]);
@jmpcyc
jmpcyc / pratice.js
Created May 23, 2013 05:56
javascript练习草稿
/* var name = "stignded";
name.length = 5;
//alert(name.toUpperCase());
//alert(name);
//alert(eval(name + "H"));
var tenSquare = (function (x){return x*x;}(10));
alert(tenSquare);
var obj1 = {name:"Stig"};
@jmpcyc
jmpcyc / common.js
Created May 21, 2013 01:32
js给对象增加属性
function(/* object */o,/* property */name,/* predicate function */predicate){
var index = 0;
o["set" + name] = function(v){
if(predicate && !predicate(v)){
throw new Error("invalid value");
}
else{
@jmpcyc
jmpcyc / uniqueInteger.js
Created May 21, 2013 01:06
js作用域和闭包特性
var uniqueInteger = (function(){
var index = 0;
function f (){
return index++;
}
return f();