const obj = {
[variable]: value,
}
const total = ['age', 'name', 'favourite'].map(key => dataLists.reduce((sum, data) => ({
[global] | |
timeout = 60 | |
index-url = http://pypi.douban.com/simple | |
[install] | |
trusted-host=pypi.douban.com |
import join from 'lodash/join' // es6, most useful when used with webpack. | |
const isArray = require('lodash/isArray') // node.js style. |
const isArray = arr => Object.prototype.toString.call(arr) === '[object Array]' | |
const isObject = obj => Object.prototype.toString.call(obj) === '[object Object]' | |
/** | |
* Deep copy properties from src, and return cloned object | |
* @param {Object} src source object to clone from | |
*/ | |
const deepClone = src => { | |
const dest = {} | |
const copy = (src, dest) => { |
class File(object): | |
def __init__(self, file_name, method): | |
self.file_obj = open(file_name, method) | |
def __enter__(self): | |
return self.file_obj | |
def __exit__(self, type, value, traceback): | |
self.file_obj.close() |
#! /usr/bin/env bash | |
# sudo passwd root: set password for root user | |
sudo passwd root # for root user | |
sudo passwd $USER # for current logged in user. | |
# Add a new user | |
sudo adduser <qm> | |
# add epel yum repository |
const obj = {
[variable]: value,
}
const total = ['age', 'name', 'favourite'].map(key => dataLists.reduce((sum, data) => ({
'C:\Users\Administrator/Desktop/7-42.pdf' is wrong. | |
should be 'C:\\Users\\Administrator/Desktop/7-42.pdf' | |
because \ is preserved to escape character. | |
const str = 'C:\\Users\\Administrator/Desktop/7-42.pdf' | |
str.replace(/\//g, '\\') | |
// => 'C:\\Users\\Administrator\\Desktop\\7-42.pdf' | |
// 1, Object.is | |
Object.is('hello', 'hello') | |
// => true | |
Object.is(+0, -0) | |
// => false | |
Object.is(NaN, NaN) | |
// => true |
// regex 分组的一个好例子 | |
const pattern = /^(0*([1-9]\d{1,3})\ +)?([1-9]\d{7,})$/ | |
const str = '086 18118771840' | |
pattern.exec(str) | |
/* => [ '086 18118771840', '086 ', '86', '18118771840' ] | |
* 这里,用正则来匹配想要的字段,加上括号,即可自动分组, | |
* 应用: 根据条件提取字段,分组甚至能够在正则表达式里面直接使用。 | |
*/ |
[ | |
{ "key": "ctrl+`", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus" }, | |
{ "key": "ctrl+`", "command": "workbench.action.terminal.focus", "when": "!terminalFocus" } | |
] | |
// Paste above code into F1: Open KeyboardShortcuts preferences. yourself keybinds.json |