This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://osxdaily.com/2010/09/06/change-your-mac-hostname-via-terminal/ | |
# check hostname | |
hostname | |
# change hostname | |
sudo hostname -s YourHostName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vim: syntax=javascript | |
let test = 'This is a javascript file' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Child = React.createClass({ | |
render: function() { | |
return (<div>I'm the child</div>); | |
} | |
}); | |
var ShowHide = React.createClass({ | |
getInitialState: function () { | |
return { childVisible: false }; | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// includes() startsWith() endsWith() | |
s = 'Hello world!' | |
s.includes('o') // true | |
s.startsWith('Hello') // true | |
s.endsWith('!') // true | |
// 这三个方法都支持第二个参数,表示开始搜索的位置。 | |
s.includes('Hello', 6) // false | |
s.startsWith('world', 6) // true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Array.from方法用于将两类对象转为真正的数组: | |
1. 类似数组的对象(array-like object) | |
2. 可遍历(iterable)的对象(包括ES6新增的数据结构Set和Map)*/ | |
// example1 | |
let arrayLike = { '0': 'a', '1': 'b', '2': 'c', length: 3 } | |
let arr2 = Array.from(arrayLike); // ['a', 'b', 'c'] | |
// example 2 | |
Array.from('hello') // ['h', 'e', 'l', 'l', 'o'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let m = new Map() | |
let o = {p: 'Hello World'} | |
m.set(o, 'content') | |
m.get(o) // "content" | |
m.has(o) // true | |
m.delete(o) // true | |
m.has(o) // false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 基本用法 | |
console.log(1, ...[2, 3, 4], 5) // 1 2 3 4 5 | |
// 该运算符主要用于函数调用 | |
// 例子1:函数定义 | |
function push(array, ...items) { | |
array.push(...items) | |
} | |
// 例子2:函数调用 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="typewriter"> | |
<h1>The cat and the hat.</h1> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npm install --save electron-localshortcut | |
const electronLocalshortcut = require('electron-localshortcut'); | |
const BrowserWindow = require('electron').BrowserWindow; | |
const win = new BrowserWindow(); | |
win.loadUrl('https://github.com'); | |
win.show(); | |
electronLocalshortcut.register(win, 'Ctrl+A', () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To send events to particular window you can use webContents.send(EVENT_NAME, ARGS) (see docs). webContents is a property of a window instance: | |
// main process | |
storeWindow.webContents.send('store-data', store); | |
// To listen for this event being sent, you need a listener in a window process (renderer): | |
// renderer process | |
// ipcRenderer is provided by electron package. You can import it like this: var ipcRenderer = require('electron').ipcRenderer; or es6 import { ipcRenderer } from 'electron'; | |
import { ipcRenderer } from 'electron'; | |
ipcRenderer.on('store-data', function (store) { |