Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jovey-zheng's full-sized avatar
🎯
Focusing

Jovey Zheng jovey-zheng

🎯
Focusing
View GitHub Profile
@jovey-zheng
jovey-zheng / trello-css-guide.md
Created November 17, 2015 06:42 — forked from bobbygrace/trello-css-guide.md
Trello CSS Guide

Trello CSS Guide

“I perfectly understand our CSS. I never have any issues with cascading rules. I never have to use !important or inline styles. Even though somebody else wrote this bit of CSS, I know exactly how it works and how to extend it. Fixes are easy! I have a hard time breaking our CSS. I know exactly where to put new CSS. We use all of our CSS and it’s pretty small overall. When I delete a template, I know the exact corresponding CSS file and I can delete it all at once. Nothing gets left behind.”

You often hear updog saying stuff like this. Who’s updog? Not much, who is up with you?

This is where any fun you might have been having ends. Now it’s time to get serious and talk about rules.

Writing CSS is hard. Even if you know all the intricacies of position and float and overflow and z-index, it’s easy to end up with spaghetti code where you need inline styles, !important rules, unused cruft, and general confusion. This guide provides some architecture for writing CSS so it stays clean and ma

@jovey-zheng
jovey-zheng / filereader.js
Last active December 30, 2015 03:27
FileReader() sample
handleFileChoose() {
const fileReader = new FileReader();
const imgUrl = document.getElementById('openFile').files[0];
if (imgUrl) {
fileReader.readAsDataURL(imgUrl);
fileReader.onloadend = () => {
document.getElementById('avatarImg').src = fileReader.result;
}
}
}
@jovey-zheng
jovey-zheng / bgCover.css
Last active March 8, 2016 09:02
CSS: background fixed and cover.
.bg-cover {
background: url('xxx.jpg') no-repeat;
background-attachment: fixed;
background-size: cover;
}
@jovey-zheng
jovey-zheng / autoLoading.js
Last active April 13, 2016 08:26
when user scroll some position then auto loading data ...
handleAppend() {
const top = window.pageYOffset ||
document.documentElement.scrollTop ||
document.body.scrollTop;
if (!isEmpty(data)
&& (top + window.innerHeight) / document.body.scrollHeight > 0.9
&& !isloading // false
) {
//do something ...
@jovey-zheng
jovey-zheng / merge.js
Created May 20, 2016 02:31
merge array based on lodash.
var _ = require('lodash');
module.exports = function (source, target) {
var joinArrays = function (a, b) {
if (_.isArray(a) && _.isArray(b)) {
return a.concat(b);
};
if (_.isPlainObject(a) && _.isPlainObject(b)) {
return _.merge(a, b, joinArrays);
};
@jovey-zheng
jovey-zheng / _.chunk.js
Created July 28, 2016 01:07
Transform an array to some chunk array.
function chunk(arr, chunk) {
var res = [],
len = arr.length,
_len = Math.ceil(arr.length / chunk),
_chunk = 0;
chunk = chunk > len ? len : chunk;
for (var i = 0; i < _len ;i++) {
var _arr = [];
@jovey-zheng
jovey-zheng / DateFormat.js
Last active July 28, 2016 05:41
Format Date.
class DateFormat {
constructor(tmp) {
this.tmp = +tmp || Date.now();
}
duration(format = 'HH:mm:ss') {
let hour = ~~(this.tmp/1000/60/60);
let minutes = ~~((this.tmp/1000/60)%60);
let seconds = ~~((this.tmp/1000)%60);
@jovey-zheng
jovey-zheng / numtoCl.js
Created August 3, 2016 09:45
Transform Number to Chinese.
(function(global){
var numtoCL = {}
var Maxnumb = 9007199254740992;
numtoCL.toS = function(num,m){
var op = {
ch: '零一二三四五六七八九'
,ch_u: '个十百千万亿'
,other: '负点'
,toCL: this.toCL
function isRepeat(arr){
var hash = {};
for (var item of arr) {
if (hash[item]) {
return true;
}
hash[item] = false;
}
// 简单的缓存工具
// 匿名函数创造了一个闭包
const cache = (function() {
const store = {};
return {
get(key) {
return store[key];
},
set(key, val) {