Skip to content

Instantly share code, notes, and snippets.

View z2015's full-sized avatar
🎯
Focusing

William Zhou z2015

🎯
Focusing
View GitHub Profile
@z2015
z2015 / ChineseNameReg.md
Created July 7, 2016 06:26
Js Chinese Regex
var reg = /^([\u4e00-\u9fa5]+)(·[\u4e00-\u9fa5]+)?$/;
var filter=/^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/; 
@z2015
z2015 / base.md
Last active July 7, 2016 01:19
convert numbers between different bases in JavaScript?

#The API

##To convert to a number from a hex string:

parseInt(string, radix)

string: Required. The string to be parsed radix: Optional. A number (from 2 to 36) that represents the numeral system to be used ##To convert from a number to a hex string:

@z2015
z2015 / flipslider.css
Last active July 5, 2016 03:24
Tmall Like flipsnap effect.
.zebra-fushi-slider {
position: relative;
height: 11.09333333em;
background: url(//img.alicdn.com/tps/i3/TB1dTp0IpXXXXbcXFXXt1Aj_XXX-1125-780.jpg) top left no-repeat;
background-size: 100%;
}
.zebra-fushi-slider .viewport {
width: 16em;
overflow: hidden;
@z2015
z2015 / forLoop.js
Created July 5, 2016 01:22
For Loop inner Object Assignment with Test.
require('chai').should();
var expect = require('chai').expect;
var assert = require('chai').assert;
function xybkPushSame(dt){
var xybk = [];
var obj = {};
for (let i=0; i<dt.length; i++){
obj.title = dt[i].title;
obj.id = dt[i].id;
@z2015
z2015 / ejs.block.js
Created June 27, 2016 10:04
Sails.js - How to inject a js file to a specific route?
<%- blocks.localScripts %>
<% block('localScripts', '<script src="https://maps.googleapis.com/maps/api/js"></script>') %>
// you can add as many as you like
res.locals.scripts = [
'//maps.googleapis.com/maps/api/js',
];
return res.view();
<!--SCRIPTS-->
<!--SCRIPTS END-->
@z2015
z2015 / index.html
Created June 23, 2016 05:03
CSS only custom Checkbox and Radio UI
<h2>CSS only custom Checkbox and Radio UI <small><a href="http://bootstrapsale.com">http://bootstrapsale.com</a></small></h2>
<div class="box">
<div class="checkbox">
<label>
<input type="checkbox" />
<i class="input-helper"></i>
<span>Maecenas faucibus mollis interdum.</span>
</label>
</div>
@z2015
z2015 / firefox.md
Created June 21, 2016 08:17
Stop Firefox DPI Scaling (when Windows setting is at 125%)
@z2015
z2015 / node_env.md
Created June 12, 2016 05:58
NPM cross platform define environment variable
@z2015
z2015 / credential.helper.md
Created June 8, 2016 07:41
Skip password typing when push git
function easyTab(tab, content){
return this instanceof easyTab ? this.init(tab, content) : new easyTab(tab, content);
};
easyTab.prototype.init = function(tab, content) {
this.el = {
tab: tab,
content: content
};
document.querySelector(this.el.tab).addEventListener('click', this, false);