Skip to content

Instantly share code, notes, and snippets.

View lilywang711's full-sized avatar
🎯
working

lily wang lilywang711

🎯
working
View GitHub Profile

Git 比较不同版本文件差异的常用命令格式:

git diff                                       查看尚未暂存的文件更新了哪些部分

git diff filename 查看尚未暂存的某个文件更新了哪些

git diff –cached                    查看已经暂存起来的文件和上次提交的版本之间的差异

git diff –cached filename 查看已经暂存起来的某个文件和上次提交的版本之间的差异
@lilywang711
lilywang711 / gist:2c863ef197378621e224cc95a478d440
Last active July 25, 2018 07:36
window.open() not working on safari

因安全机制,window.open在safari 浏览器中屏蔽掉了, 解决办法如下

let newTab = window.open()
setTimeout(() => {
  newTab = 'https://www.baidu.com'
}, 500)
@lilywang711
lilywang711 / gulpfile.js
Created November 5, 2018 04:14
gulp 构建html、编译sass、混淆js、压缩图片
const gulp = require('gulp')
const sass = require('gulp-sass')
const cssnano = require('gulp-cssnano')
const rename = require('gulp-rename')
const connect = require('gulp-connect')
const babel = require('gulp-babel')
const uglify = require('gulp-uglify-es').default
const imagemin = require('gulp-imagemin')
gulp.task('convertCSS', function () {
//获取指定form中的所有的<input>对象
function getElements(formId) {
var form = document.getElementById(formId);
var elements = new Array();
var tagElements = form.getElementsByTagName('input');
for (var j = 0; j < tagElements.length; j++){
elements.push(tagElements[j]);
}
return elements;
@lilywang711
lilywang711 / ajax.js
Last active November 27, 2018 14:35
ajax.js
const ajax = (options = {}) => {
options.method = (options.method || "GET").toUpperCase()
options.dataType = options.dataType || 'json'
options.async = options.async || true
let xhr = null
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest()
} else {
xhr = new ActiveXObject('Microsoft.XMLHTTP')
}
@lilywang711
lilywang711 / groupTest.md
Created December 28, 2018 09:23
深圳程序员开发群test

深圳程序员开发群test

var search = location.search.substring(1);
JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}')
@lilywang711
lilywang711 / formatDate.js
Created April 18, 2019 08:20
格式化日期
function time(time = +new Date()) {
var date = new Date(time + 8 * 3600 * 1000);
return date.toJSON().substr(0, 19).replace('T', ' ');
}
time(); // "2019-04-18 16:20:22"
export const hasClass = function(obj, cls) {
return obj.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
};
export const addClass = function(obj, cls) {
if (!hasClass(obj, cls)) obj.className += ' ' + cls;
};
export const removeClass = function(obj, cls) {
if (hasClass(obj, cls)) {
// 获取 url 的查询参数,转为 object
const decodeURI = (url = window.location.search) => {
return url.replace(/([^?&=]+)=([^&]+)/g,(_,k,v)=>q[k]=v)
}
// 1. 判断两个对象是否严格相等,保证isEqual(NaN, NaN)返回true。
// 2. 与Object.is 的区别在于对+0和-0的比较
function isEqual(a, b) {
return (a === b || (a !== a && b !== b));
}