Skip to content

Instantly share code, notes, and snippets.

View qzm's full-sized avatar
🚀
I may be slow to respond.

Aaron Qiu qzm

🚀
I may be slow to respond.
View GitHub Profile
@qzm
qzm / vue.json
Created June 24, 2017 05:51
vue snippet
{
"vue-components": {
"prefix": "vue-components",
"body": [
"<template>\r",
"\r",
"</template>\r",
"<script>\r",
"export default {\r",
" name: '$1',\r",
@qzm
qzm / Vagrantfile
Created June 14, 2017 01:34
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@qzm
qzm / debounce.js
Created June 8, 2017 05:48
JavaScript debounce ES6
/**
* 防止函数过多的执行,默认十秒钟
* @param {any} func 待修改的函数
* @param {number} [wait=10000] 等待时间
*/
function debounce(func, wait = 10000) {
let lastTime = '';
return (...argv) => {
let thisTime = new Date();
if (!lastTime || thisTime - lastTime > wait) {
@qzm
qzm / deepFilter.js
Created June 7, 2017 16:29
js过滤特殊的字符串,例如:😊
/**
* 过滤特殊的字符
* @param {any} 需要被过滤掉字符串
* @returns 过滤后的结果
*/
function deepFilter(src) {
let dst, prop;
let type = Object.prototype.toString.call(src);
if (type === '[object Array]') {
dst = [];
{
"name": "John",
"age": 18,
"gender": "male",
"weight": "75kg"
}
@qzm
qzm / nginx.dockerfile
Last active September 26, 2018 01:44
Nginx 1.12.0 dockerfile --with-http_headers_module
FROM alpine:3.5
MAINTAINER NGINX Docker Maintainers "[email protected]"
ENV NGINX_VERSION 1.12.0
RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \
&& CONFIG="\
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
@qzm
qzm / pipeline.js
Created May 28, 2017 15:43
JavaScript Pipeline
const pipeline = (...args) => args.reduce((l, r) => r(l));
@qzm
qzm / compress.js
Created April 23, 2017 15:57
图片压缩
function compress(img) {
var initSize = img.src.length;
var width = img.width;
var height = img.height;
//如果图片大于四百万像素,计算压缩比并将大小压至400万以下
var ratio;
if ((ratio = width * height / 4000000)>1) {
ratio = Math.sqrt(ratio);
width /= ratio;
@qzm
qzm / upload.html
Created April 23, 2017 15:32
upload
<html>
<body>
<div id="test-image-preview" style="border: 1px solid rgb(204, 204, 204); width: 100%; height: 200px; background-size: contain; background-repeat: no-repeat; background-position: center center;">
</div>
<br/>
<div id="test-file-info"></div>
<br/>
<input type="file" id="test-image-file">
<script type="text/javascript">
@qzm
qzm / deepEqual.js
Last active April 23, 2017 13:51
deep equal
var deepEqual = function (x, y) {
if ((typeof x == "object" && x != null) && (typeof y == "object" && y != null)) {
if (Object.keys(x).length != Object.keys(y).length) {
return false;
}
for (var prop in x) {
if (y.hasOwnProperty(prop)) {
return deepEqual(x[prop], y[prop]);
}
}