Skip to content

Instantly share code, notes, and snippets.

@liuwenzhuang
liuwenzhuang / ionic2-fixed-item-row-flex-error.scss
Created August 31, 2017 06:57
Ionic 2 iOS8 Item and Row style error
.item-block, .row {
display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */
display: -moz-box; /* OLD - Firefox 19- (buggy but mostly works) */
display: -ms-flexbox; /* TWEENER - IE 10 */
display: -webkit-flex; /* NEW - Chrome */
display: flex;
}
@liuwenzhuang
liuwenzhuang / border-iOS-Android-Consistency.scss
Last active August 31, 2017 07:03
解决border在iOS和Android上的渲染不同的问题,绝对1px的border
@mixin fine-line-top {
position: absolute;
display: block;
background-image: linear-gradient(180deg, #dedede 0%, #dedede 50%, transparent 50%, transparent 100%);
background-size: 100% 1px;
content: ' ';
left: 0;
right: 0;
top: 0;
@liuwenzhuang
liuwenzhuang / emojis.json
Created January 3, 2018 06:06 — forked from oliveratgithub/emojis.json
Emoji-list with emojis, names, shortcodes, unicode and html entities [massive list]
{
"emojis": [
{"emoji": "👩‍👩‍👧‍👧", "name": "family_mothers_two_girls", "shortname": "", "unicode": "", "html": "👩‍👩‍👧‍👧", "category": "p", "order": ""},
{"emoji": "👩‍👩‍👧‍👦", "name": "family_mothers_children", "shortname": "", "unicode": "", "html": "👩‍👩‍👧‍👦", "category": "p", "order": ""},
{"emoji": "👩‍👩‍👦‍👦", "name": "family_mothers_two_boys", "shortname": "", "unicode": "", "html": "👩‍👩‍👦‍👦", "category": "p", "order": ""},
{"emoji": "👨‍👩‍👧‍👧", "name": "family_two_girls", "shortname": "", "unicode": "", "html": "👨‍👩‍👧‍👧", "category": "p", "order": ""},
{"emoji": "👨‍👩‍👧‍👦", "name": "family_children", "shortname": "", "unicode": "", "html": "👨‍👩‍👧‍👦", "category": "p", "order": ""},
{"emoji": "👨‍👩‍👦‍👦", "name": "family_two_boys", "shortname": "", "unicode": "", "html": "👨&zw
@liuwenzhuang
liuwenzhuang / convertIntlJsonToObjectForDefineMessages.js
Created January 30, 2018 11:46
为React-Intl提供json文件作为输入源,将其转换为在代码中defineMessages需要的对象
const fs = require('fs');
const readline = require('readline');
const writableStream = fs.createWriteStream('intl.js', {
flags: 'w',
autoClose: true
});
const rl = readline.createInterface({
input: fs.createReadStream('en.json'),
@liuwenzhuang
liuwenzhuang / getBodyScrollTop.js
Created February 1, 2018 10:29
获取文档body滚动高度
const scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
@liuwenzhuang
liuwenzhuang / IconFont.js
Created February 7, 2018 06:17
React应用使用iconfont图标(使用CSS Modules)
/**
* 首先在http://iconfont.cn/新建图标项目,根据http://iconfont.cn/help/detail?spm=a313x.7781069.1998910419.d8cf4382a&helptype=code
* 文档下载配置相应字体文件、js文件、css文件等。
* 使用方式:
* 单色图标:<IconFont type='ICON_NAME' />
* 多色图标:<IconFont type='MULTI_COLOR_ICON' symbol />
*/
import PropTypes from 'prop-types';
import styles from "./IconFont.less";
@liuwenzhuang
liuwenzhuang / IconFont.js
Created February 7, 2018 06:17
React应用使用iconfont图标(使用CSS Modules)
/**
* 首先在http://iconfont.cn/新建图标项目,根据http://iconfont.cn/help/detail?spm=a313x.7781069.1998910419.d8cf4382a&helptype=code
* 文档下载配置相应字体文件、js文件、css文件等。
* 使用方式:
* 单色图标:<IconFont type='ICON_NAME' />
* 多色图标:<IconFont type='MULTI_COLOR_ICON' symbol />
*/
import PropTypes from 'prop-types';
import styles from "./IconFont.less";
@liuwenzhuang
liuwenzhuang / isPlainObject.js
Last active February 25, 2018 05:50
判断是否为Plain Object(Plain Object意为用JSON形式定义的普通对象或者new Object()创建的简单对象)
/**
* @param {any} obj The object to inspect.
* @returns {boolean} True if the argument appears to be a plain object.
*/
function isPlainObject(obj) {
if (typeof obj !== 'object' || obj === null) return false;
let proto = obj;
while (Object.getPrototypeOf(proto) !== null) {
proto = Object.getPrototypeOf(proto);
@liuwenzhuang
liuwenzhuang / localStorage.js
Created March 13, 2018 06:07
localStorage在无痕模式下存在,但调用其方法会抛异常; localStorage is exist in incognito mode, but invoking functions of localStorage will throw exceptions.
/**
* 是否支持localStorage
*/
function isSupportStorage() {
if(!localStorage) return false;
try {
localStorage.setItem('__test__', '__test__');
localStorage.removeItem('__test__');
return true;
} catch(e) {
@liuwenzhuang
liuwenzhuang / heap_sort.js
Created March 14, 2018 03:08
堆排序,首先建立大头堆,然后将根元素与最后一个叶子节点交换(此时不一定符合堆的定义,调整成堆),重复此步骤
/**
* 在数组中按下标交换数据
* @param {Array} arr 数据源
* @param {number} prev 需交换的下标之一
* @param {number} next 需交换的下标之一
*/
function swap(arr, prev, next) {
var temp = arr[prev];
arr[prev] = arr[next];
arr[next] = temp;