Skip to content

Instantly share code, notes, and snippets.

View zzbo's full-sized avatar
🎯
Focusing

zhenbo.zheng zzbo

🎯
Focusing
View GitHub Profile
@zzbo
zzbo / setRem.js
Last active August 29, 2015 14:19
//移动设备设置rem, 参考m.taobao.com
;function (window) {
var v = window.devicePixelRatio;
var dpr = v ? (v >= 3 ? 3 : (v >= 2 ? 2 : 1)) : 1;
var scale = 1 / dpr;
var doc = window.document;
var html = doc.documentElement;
var viewport = doc.createElement('meta');
viewport.setAttribute('name', 'viewport');
module.exports = function(str){
return "module.exports = '"
+ str
.replace(/'/g, "\\'")
.replace(/\r\n|\r|\n/g, "\\n")
+ "';";
};
@zzbo
zzbo / dos2Unix.js
Last active December 15, 2015 04:26
简易dos文件格式转unix
//简易dos文件格式转unix
module.exports = function(str){
return str.replace(/(?:\r(\n)|\^M$|\x0D$)/g, '$1');
};
@zzbo
zzbo / textareaAdaptive.css
Last active January 18, 2016 07:39
textarea 自适应高度
#textarea {
display: block;
margin:0 auto;
overflow: hidden;
width: 550px;
font-size: 14px;
height: 18px;
line-height: 24px;
padding:2px;
}
@zzbo
zzbo / EventEmitter.js
Last active September 29, 2017 07:03
EventEmitter
let isFunction = function (obj) {
return typeof obj === 'function' || false;
};
class EventEmitter {
constructor() {
this.listeners = new Map();
}
on(label, callback) {
this.listeners.has(label) || this.listeners.set(label, []);
function isSupportWebp() {
return !![].map && document.createElement('canvas').toDataURL('image/webp').indexOf('data:image/webp') == 0;
}
@zzbo
zzbo / ssh-sequelize.js
Created June 22, 2018 07:39
sequelize with tunnel-ssh
// sequelize config
var sequelize = new sequelize('database', 'user', 'pass', {
host: '127.0.0.1',
dialect: 'mysql',
port: 3306,
pool: {
max: 10,
min: 0,
idle: 20000
@zzbo
zzbo / mysqlQueryResultToJSON.html
Last active March 2, 2019 13:46
mysql <5.7 query result transfer to json
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>mysql query result to json</title>
<style>
.mysql-query-result-input, .mysql-query-result-input-wrap {
width: 600px;