3 20 makedowntab记录
资料
Immutable collections for JavaScript
简单来说,用Imutable提供的类数据结构操作后返回的都是一个全新的数据结构
ssh 命令
ssh 用户名@IP地址 -p 端口号
服务端的vscode解决方案
trimmean函数
-
trimmean函数返回数据集的内部平均值。 函数TRIMMEAN 先从数据集的头部和尾部(最高值和最低值)除去一定百分比的数据点,然后再求平均值。 当希望在分析中剔除一部分数据的计算时,可以使用此函数。
-
两个参数, 一个是数组,一个是百分比即 截取掉前后数组的百分比
trimmean( [1,1,1,1,2,2,2,2,3,3,3,3,8,8,8,8] ,20)
//处理后的数组是 [1,1,1,2,2,2,2,3,3,3,3,8,8,8] ,之后再计算平均值
python set
- set() 函数创建一个无序不重复元素集,可进行关系测试,删除重复数据,还可以计算交集、差集、并集等。
x = set('runoob')
y = set('google')
print(x)
# {'r', 'o', 'b', 'n', 'u'}
print(y)
# {'e', 'g', 'o', 'l'}
#交集
print(x & y)
# {'o'}
# 并集
print(x | y)
# {'e', 'r', 'g', 'o', 'l', 'b', 'n', 'u'}
# 差集
print(x - y)
# {'r', 'u', 'b', 'n'}
print(y - x)
# {'g', 'e', 'l'}
js数组去重
var arr = [1,2,1,1,22,4,5,6];
arr1 = [...new Set(arr)];
- 一行代码实现获取一个网页使用了多少种标签
[...new Set([...document.querySelectorAll('*')].map(node => node.tagName))].length;
谷歌浏览器插件推荐
Display Github Trending repositories on Chrome New Tab Extensions
githuber
好句
“ If you want to go fast, go alone. If you want to go far, go together. ”
immutability-helper js工具函数
- 在不更改原始源的情况下改变数据副本
Mutate a copy of data without changing the original source
(npm 说明)[https://www.npmjs.com/package/immutability-helper]
js的 组合 Compose函数
const compose = (fn1, fn2) => args => fn1(fn2(args));
const toUpperCase = value => value.toUpperCase();
const addSuffix = value => `${value} is good!`;
const format = compose(toUpperCase, addSuffix);
format('apple'); // "APPLE IS GOOD!"
注意:输出的结果
思考:顺序
- 代码精华
var compose = (...args) => (initValue) => args.reduceRight((a, c) => c(a), initValue)
- redux源码之compose 模块
/**
* Composes single-argument functions from right to left. The rightmost
* function can take multiple arguments as it provides the signature for
* the resulting composite function.
*
* @param {...Function} funcs The functions to compose.
* @returns {Function} A function obtained by composing the argument functions
* from right to left. For example, compose(f, g, h) is identical to doing
* (...args) => f(g(h(...args))).
*/
export default function compose(...funcs) {
if (funcs.length === 0) {
return arg => arg
}
if (funcs.length === 1) {
return funcs[0]
}
return funcs.reduce((a, b) => (...args) => a(b(...args)))
}
其为众多开源库(比如 Redux) 所采用。
参考链接: 函数式编程之柯里化和组合详解
github资源
动画库
https://github.com/juliangarnier/anime
github资源
css 的 奇技淫巧
(https://github.com/chokcoco/iCSS)[https://github.com/chokcoco/iCSS]
github资源
NSFW.js 是一个在前端检查是否有色情信息的库,可用于图片上传前筛查,基于 tensorflow.js。
https://shift.infinite.red/avoid-nightmares-nsfw-js-ab7b176978b1
Python enumerate() 函数
-
描述
enumerate() 函数用于将一个可遍历的数据对象(如列表、元组或字符串)组合为一个索引序列,同时
列出数据和数据下标,一般用在 for 循环当中。 -
语法
enumerate(sequence, [start=0])
-
参数
sequence – 一个序列、迭代器或其他支持迭代对象。
start – 下标起始位置。 -
example
arr = ['a','b','c'];
print(list(enumerate(arr)))
写出5种css隐藏元素的办法
1.opacity: 0;
2.visibility: hidden;
3.display: none;
4.position: absolute;
top: -9999px;
left: -9999px;
5.clip-path: polygon(0px 0px,0px 0px,0px 0px,0px 0px);
craco
Create React App Configuration Override is an easy and comprehensible configuration layer for create-react-app v2
简单来说,是一个creat-react-app 创建react项目后, 扩展配置项而不使用eject的解决方案。
npm地址 craco
面试题
['1', '2', '3'].map(parseInt)
结果为[1, NaN, NaN]
变形体
- 在30-seconds-of-code看到一个这个题的变形,分享一下
let unary = fn => val => fn(val)
let parse = unary(parseInt)
console.log(['1.1', '2', '0.3'].map(parse))
- 这是今天在 Advanced-Frontend组织 看到一个比较有意思的题目。
主要是讲JS的映射与解析
早在 2013年, 加里·伯恩哈德就在微博上发布了以下代码段:
['10','10','10','10','10'].map(parseInt);
// [10, NaN, 2, 3, 4]
谷歌浏览器插件
react-beautiful-dnd react拖拉
Beautiful and accessible drag and drop for lists with React
写出函数 curry 实现
var add = (a, b, c) => a + b + c
var curryAdd = curry(add)
// 以下输出结果都相同
curryAdd(1, 2, 3) // 6
curryAdd(1, 2)(3) // 6
curryAdd(1)(2)(3) // 6
curryAdd(1)(2, 3) // 6
核心思路: 若传进去的参数个数未达到 curryAdd 的个数,则将参数缓存在闭包变量 lists 中:
function curry(fn, ...args) {
const length = fn.length
let lists = args || []
let listLen
return function (..._args) {
lists = [...lists, ..._args]
listLen = lists.length
if (listLen < length) {
const that = lists
lists = []
return curry(fn, ...that)
} else if (listLen === length) {
const that = lists
lists = []
return fn.apply(this, that)
}
}
}
纯粹性: 纯函数不改变除当前作用域以外的值;
偏函数: 将多个入参的函数转化成两部分;
const add = a => (b, c) => a + b + c
add(1)(2, 3)
函数柯里化: 将多个入参的函数转化为一个入参的函数
const add = a => b => c => a + b + c
add(1)(2)(3)
网络架构
好句
<span style=“color:yellow”">一个成功的团队要有三种人,一种稳,一种能,一种会配合。
<span style=“color:yellow”"> 什么是人才?人才就是做事做到极致的人
达克效应
能力强的人总是低估自己,能力弱的人总是高估自己
- 当你认为你足够好了,你就放松了,也就没有前进的动力。
一个高效傲慢的程序员
“花费我的时间去帮助你,意味着我需要花费精力去帮助别人,而不是提高自己----这对我来说不是一个好的主意。我的建议是:自己多努力,自己弄懂。还可以塑造你自己的心性”