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
function promiseWrap (value) { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log(value) | |
resolve(value * 2) | |
}, 100 * value) | |
}) | |
} | |
const values = [1, 2, 3] |
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
getters: { | |
filterProducts: state => type => { // only use state | |
return state.products.filter(p => p.type === type) | |
}, | |
filteredLength: (state, getters) => type => { // want to use getters | |
return getters.filterProducts(type).length | |
} | |
} |
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
const trace = message => x => { | |
console.log(message, x) | |
return x | |
} | |
Promise.resolve('foo') | |
.then(trace('received response')) // logs "received response foo" | |
.then(res => /* do something */) |
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
function run (input, parameters) { | |
const iTerm = Application('iTerm2') | |
iTerm.activate() | |
const windows = iTerm.windows() | |
var window = iTerm.currentWindow() | |
var tab = window.currentTab() | |
var session = tab.currentSession() |
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
// Use polyfill | |
// http://iamdustan.com/smoothscroll/ | |
window.scroll({ top: 2500, left: 0, behavior: 'smooth' }); | |
document.querySelector('.hello').scrollIntoView({ behavior: 'smooth' }); |
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
timeout(1000).then(() => { | |
console.log('done') | |
}) |
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
function getDate (args) { | |
const d = new Date() | |
return [d.getDate(), d.getMonth() + 1, d.getFullYear()] | |
} | |
const [day, month, year] = getDate() |
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
cd my-site/htdocs | |
# Link the current directory in ~/.valet/Sites | |
# Which is a default park by valet | |
valet link | |
# Rename the generated symlink to your domain | |
mv ~/.valet/Sites/htdocs ~/.valet/my-domain |
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
function update(progress) { | |
// Update the state of the world for the elapsed time since last render | |
} | |
function draw() { | |
// Draw the state of the world | |
} | |
function loop(timestamp) { | |
var progress = timestamp - lastRender |
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
function update(progress) { | |
// Update the state of the world for the elapsed time since last render | |
} | |
function draw() { | |
// Draw the state of the world | |
} | |
function loop(timestamp) { | |
var progress = timestamp - lastRender |