Skip to content

Instantly share code, notes, and snippets.

View leohxj's full-sized avatar
💯
Focusing

Leo Hui leohxj

💯
Focusing
View GitHub Profile
@leohxj
leohxj / deepEquals.js
Last active November 28, 2018 09:33
#react
function deepEquals(a, b, ca = [], cb = []) {
// Partially extracted from node-deeper and adapted to exclude comparison
// checks for functions.
// https://github.com/othiym23/node-deeper
if (a === b) {
return true;
} else if (typeof a === "function" || typeof b === "function") {
// Assume all functions are equivalent
// see https://github.com/mozilla-services/react-jsonschema-form/issues/255
return true;
width: 120px;
flex: auto;
display: -webkit-box;
text-overflow: ellipsis;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
import PropTypes from 'prop-types';
import React from 'react';
import styles from './index.less';
export default function Banner({ hasLogo }) {
const logo = hasLogo ? <div className={styles.logo} /> : null;
return <div className={styles.container}>{logo}</div>;
}
@leohxj
leohxj / delProps.jsx
Created October 9, 2018 02:40
#react
// 已经有组件的情况下,展示对应组件
const props = { ...this.props };
// delete props.code;
return <Component {...props} />;
@leohxj
leohxj / sigmoid01.js
Last active September 29, 2018 07:36
s曲线收敛函数
/**
* 一个s曲线收敛函数, x可以是负无穷到正无穷的任何值, 输出结构永远在0-1之间, x约小, 结果约趋近于0, 越大, 越趋近于1.
* p值决定s曲线的坡度, 越大曲线约陡峭
* 使用场景: 性能打分, 要求分数在0-100之间,100分是满分; 一个程序的运行时间t, 越低分越高.
* 那么问题来了, t值是一个0到正无穷之间的取值, 把它映射到0-100分之间
*/
const sigmoid01 = ( x, p = 1 ) => {
return 1 / ( 1 + Math.pow( Math.E, -x/p) );
}
@leohxj
leohxj / find_and_kill_port.bash
Last active September 13, 2018 06:39
#bash #mac
lsof -i tcp:8080
kill -9 kid
@leohxj
leohxj / settings.json
Created September 11, 2018 11:57
#settings
{
"psi-header.templates": [
{
"language": "*",
"template": [
"@file 文件描述",
"@description 详细说明",
"",
"@author <<author>> <<<authoremail>>>",
"",
@leohxj
leohxj / hyperguide.md
Created September 9, 2018 15:09 — forked from IanCarrasco/hyperguide.md
How to Create a Hyper Terminal at a Folder

How to open hyper at current directory.

1.Go to the forked cd_to github repository and download the latest release.(zipped) Download From Github.

2.Within cd_to, open the Hyper folder and drag the cd_to.app file into your Applications folder MacDown Screenshot.

3.Now open up Automator and create a new service. File>New>Service(gear icon).Be sure to save the service with an effective name like "Hyper Terminal at Folder" MacDown Screenshot

@leohxj
leohxj / install node
Created September 9, 2018 06:38
#node
nvm install --lts
nvm alias default lts/*
nvm use default
@leohxj
leohxj / .postcssrc
Created June 27, 2018 14:44
[postcss vw设置] 设置 postcss-px-to-viewport
module.exports = {
"plugins": {
"postcss-preset-env":{},
"postcss-px-to-viewport": {
viewportWidth: 750, // (Number) The width of the viewport.
viewportHeight: 1334, // (Number) The height of the viewport.
unitPrecision: 3, // (Number) The decimal numbers to allow the REM units to grow to.
viewportUnit: 'vw', // (String) Expected units.
selectorBlackList: ['.ignore', '.hairlines'], // (Array) The selectors to ignore and leave as px.
minPixelValue: 1, // (Number) Set the minimum pixel value to replace.