Skip to content

Instantly share code, notes, and snippets.

View jruif's full-sized avatar
🤝
working

Jruif jruif

🤝
working
View GitHub Profile
function fakeParseJSON(str) {
let i = 0;
const value = parseValue();
expectEndOfInput();
return value;
function parseObject() {
if (str[i] === "{") {
i++;
@jruif
jruif / bash-colors.md
Created September 9, 2021 08:28 — forked from iamnewton/bash-colors.md
The entire table of ANSI color codes.

Regular Colors

Value Color
\e[0;30m Black
\e[0;31m Red
\e[0;32m Green
\e[0;33m Yellow
\e[0;34m Blue
\e[0;35m Purple
@jruif
jruif / takeLatest.js
Last active December 27, 2018 11:18
模拟takeLatest,处理竞态问题
function takeLatest(asyncFunc) {
let index = 0;
return (...argv) => {
function execNext(func, reqIndex) {
return (...argv2) => {
if (reqIndex === index) {
func.call(this, ...argv2);
}
};
}
@jruif
jruif / calculator.js
Last active December 20, 2018 05:20
薪酬计算器
function parseMoney(num) {
return Math.floor(num * 100) / 100;
}
const gongjijin = {
// 个人缴纳部分
person: {
base: 0.12,
add: 0 // 补充住房公积金
},
@jruif
jruif / statist.sh
Last active September 28, 2017 07:22 — forked from demonnico/statist.sh
统计项目中代码行数
//.js文件的行数
find . -name "*.js" | xargs wc -l
//.js .jsx .css .scss 文件内容总行数
find . -name "*.js" -or -name "*.jsx" -or -name "*.css" -or -name "*.scss" |xargs grep -v "^$"|wc -l
@jruif
jruif / *state-machine-component.md
Last active September 7, 2017 18:01 — forked from developit/*state-machine-component.md
265b lib for building pure functional state machine components. https://npm.im/state-machine-component

state-machine-component

A tiny (265 byte) utility to create state machine components using two pure functions.

🔥 JSFiddle Demo

Usage

The API is a single function that accepts 2 pure functions as arguments:

/*
* Utility to only call Redux updates in RequestAnimationFrame's
* Also uses React-dom's batchedUpdates
*/
import raf from 'raf';
import { unstable_batchedUpdates as batchedUpdates } from 'react-dom';
let rafID;
let notifyFunc;
function animFrame() {
@jruif
jruif / A.markdown
Created June 23, 2017 08:41 — forked from larrybotha/A.markdown
Fix SVGs not scaling in IE9, IE10, and IE11

Fix SVG in <img> tags not scaling in IE9, IE10, IE11

IE9, IE10, and IE11 don't properly scale SVG files added with img tags when viewBox, width and height attributes are specified. View this codepen on the different browsers.

Image heights will not scale when the images are inside containers narrower than image widths. This can be resolved in 2 ways.

Use sed in bash to remove width and height attributes in SVG files

As per this answer on Stackoverflow, the issue can be resolved by removing just the width and height attributes.

方法名             类似   Mounted 是否可以调用setState 可以做什么?                                  
constructor               initialize()     否     否                   初始化没有副作用的方法/属性      
componentWillMount       beforeDomReady() 否     不建议        只有在createClass中才需要使用的构造函数      
render                   render           否     禁止             渲染但是请不要设置任何state                      
componentDidMount         domReady()       是      是                   DOM已经构建好,可以调用数据初始化jQuery插件  
componentWillReceiveProps onChange() 如有需要可以接收Prop来更新state
componentWillUpdate beforeRender() 在组件接收到新的props或者state但还没有render时被执行
shouldComponentUpdate shouldRender()
@jruif
jruif / pleiades.geojson
Last active June 19, 2017 07:25
test map
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.