Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

颜海镜 yanhaijing

🎯
Focusing
Block or report user

Report or block yanhaijing

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Gruntfile.js
/*!
* Grunt
* $ npm install grunt-contrib-uglify grunt-autoprefixer grunt-contrib-cssmin grunt-contrib-imagemin grunt-contrib-sass grunt-contrib-watch grunt-contrib-concat grunt-contrib-clean grunt-contrib-jshint grunt-notify --save-dev
*/
module.exports = function(grunt) {
grunt.initConfig({
// Sass
View addEvent.js
function addEvent(element, event, callback) {
if (element.addEventListener) {
element.addEventListener(event, callback, false)
} else if (element.attachEvent) {
element.attachEvent('on' + event, callback);
} else {
element['on' + event] = callback;
}
}
@yanhaijing
yanhaijing / getQueryString.js
Last active Aug 29, 2015
获取url中的参数
View getQueryString.js
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}
@yanhaijing
yanhaijing / extend.js
Last active Aug 29, 2015
浅拷贝扩展
View extend.js
function extend() {
var target = arguments[0] || {};
var arrs = slice.call(arguments, 1);
var len = arrs.length;
for (var i = 0; i < len; i++) {
var arr = arrs[i];
for (var name in arr) {
target[name] = arr[name];
}
@yanhaijing
yanhaijing / extendDeep.js
Last active Aug 29, 2015
深度扩展函数,来自jquery
View extendDeep.js
function extendDeep() {
var target = arguments[0] || {};
var arrs = slice.call(arguments, 1);
var len = arrs.length;
var copyIsArr;
for (var i = 0; i < len; i++) {
var arr = arrs[i];
for (var name in arr) {
var src = target[name];
@yanhaijing
yanhaijing / import.js
Created Jun 19, 2014
异步载入js文件
View import.js
function importJs(jsurl, fCallback, fError){
if (typeof(fCallback) != "function") fCallback = new Function();
if (typeof(fError) != "function") fError = new Function();
var oScriptEl, oTimeoutHDL, oHead;
oScriptEl = document.createElement("script");
oScriptEl.type = "text/javascript";
oScriptEl.language = "javascript";
oScriptEl.src = jsurl;
oScriptEl.onreadystatechange = doCallback;
@yanhaijing
yanhaijing / qiang
Created May 23, 2014
博客园,抢汤姆大叔的书
View qiang
function qiang(){
var date = new Date();
if(date.getHours() === 14 && date.getMinutes() === 0 && date.getSeconds() >=0){
$.post("http://www.cnblogs.com/mvc/PostComment/Add.aspx", '{"blogApp":"TomXu","postId":3745775,"body":"支持大叔,抢书了,我是颜海镜,http://yanhaijing.com","parentCommentId":0}', function (data) {console.log(data)}, "json");
}else{
setTimeout(function() {qiang()}, 1);
}
}
View sass_and_less_compared.markdown

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@yanhaijing
yanhaijing / auto-follow-github.js
Created Nov 8, 2013
自动follow github帐号
View auto-follow-github.js
(function ($) {
var
followers = ["zedshaw"];
followeds = [];
function follow(id, callback) {
$.post('https://github.com/users/follow', {target: id}, function(data, textStatus, xhr) {
/*optional stuff to do after success */
callback(id, data);
//console.log("成功follow ", id, "此人共有", data.count, "位粉丝");
@yanhaijing
yanhaijing / refresh-website.js
Last active Dec 22, 2015
刷新任意网站,无限制
View refresh-website.js
var total = 0
function loop(){
console.log("=====total count", total++);
$.ajax({
url: "http://mixin.tongda2000.com/?" + Math.random(),
error: function(){
loop();
},
success: function(){
loop();
You can’t perform that action at this time.