Skip to content

Instantly share code, notes, and snippets.

@silianlinyi
silianlinyi / isPhone.js
Created June 29, 2014 07:52
判断是否是手机号码
function isPhone(val) {
if (!/^(((13[0-9]{1})|159|180|181|186|189|(15[0-9]{1}))+\d{8})$/.test(val)) {
return false;
} else {
return true;
}
}
@silianlinyi
silianlinyi / css_resources.md
Created June 29, 2014 07:51 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@silianlinyi
silianlinyi / 0_reuse_code.js
Created June 29, 2014 07:50
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
/* 滚动条 */
::-webkit-scrollbar-thumb:horizontal { /*水平滚动条的样式*/
width: 5px;
background-color: #CCCCCC;
-webkit-border-radius: 6px;
}
::-webkit-scrollbar-track-piece {
background-color: #fff; /*滚动条的背景颜色*/
-webkit-border-radius: 0; /*滚动条的圆角宽度*/
}
// 判断滚动条是否已经到页面底部
$(window).scroll(function() {
var scrollTop = $(this).scrollTop();
var scrollHeight = $(document).height();
var windowHeight = $(this).height();
if (scrollTop + windowHeight == scrollHeight) {
console.log('滚动条已经到达页面底部');
}
});
@silianlinyi
silianlinyi / clearArray.js
Created January 6, 2014 08:05
清空数组
var myArray = [12 , 222 , 1000 ];
myArray.length = 0;
@silianlinyi
silianlinyi / gist:8279664
Created January 6, 2014 08:01
打乱数字数组
var numbers = [5, 458 , 120 , -215 , 228 , 400 , 122205, -85411];
numbers = numbers.sort(function(){ return Math.random() - 0.5});
@silianlinyi
silianlinyi / generateRandomAlphaNum.js
Created January 6, 2014 07:58
生成一组随机的字母数字字符
function generateRandomAlphaNum(len) {
var rdmString = "";
for( ; rdmString.length < len; rdmString += Math.random().toString(36).substr(2));
return rdmString.substr(0, len);
}
@silianlinyi
silianlinyi / random.js
Created January 6, 2014 07:49
Returns a random integer between min and max, inclusive. If you only pass one argument, it will return a number between 0 and that number.
function ramdom(min, max) {
if (max == null) {
max = min;
min = 0;
}
return min + Math.floor(Math.random() * (max - min + 1));
}
@silianlinyi
silianlinyi / spirograph.html
Created December 26, 2013 10:04
利用translate方法进行绘制螺旋图案的例子
<canvas width="300" height="300" id="test"></canvas>
<script type="text/javascript">
var canvas = document.getElementById('test');
var ctx = canvas.getContext('2d');
//绘制螺旋图案的函数
function drawSpirograph(ctx,R,r,O){
var x1 = R-O;
var y1 = 0;
var i = 1;