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 / 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.
@leohxj
leohxj / rdr.bash
Created June 22, 2018 02:15
转换 8080 -> 80 端口 #bash
echo "
rdr pass inet proto tcp from any to any port {80,8080} -> 127.0.0.1 port 8080
" | sudo pfctl -ef -
@leohxj
leohxj / interface.ts
Created March 29, 2018 14:35
typescript duck typing
interface IItem
{
id: number,
title: string
};
function print(item: IItem)
{
console.log(item.id + " > " + item.title);
}
var i : IItem = {
@leohxj
leohxj / settings.json
Created March 28, 2018 14:57
vscode flow workspace settings
{
"flow.useNPMPackagedFlow": true,
"javascript.validate.enable": false
}