type below:
brew update
brew install redis
To have launchd start redis now and restart at login:
brew services start redis
| // 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works | |
| const axios = require('axios'); // promised based requests - like fetch() | |
| function getCoffee() { | |
| return new Promise(resolve => { | |
| setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee | |
| }); | |
| } |
| import React from 'react' | |
| import axios, { post } from 'axios'; | |
| class SimpleReactFileUpload extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state ={ | |
| file:null | |
| } |
type below:
brew update
brew install redis
To have launchd start redis now and restart at login:
brew services start redis
| // Implementation in ES6 | |
| function pagination(c, m) { | |
| var current = c, | |
| last = m, | |
| delta = 2, | |
| left = current - delta, | |
| right = current + delta + 1, | |
| range = [], | |
| rangeWithDots = [], | |
| l; |
| // Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository | |
| $ git ls-files | xargs wc -l |
| <?php | |
| /** | |
| * Usage: <code>CharsetConversion::CP850toUTF8('your_string');</code> | |
| * | |
| * @author Pedro Sanção <pedro at sancao do co> | |
| * @license MIT Licence | |
| */ | |
| class CharsetConversion { |
| find app/src -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.ts"' {} \; |
| /** | |
| * Swap the elements in an array at indexes x and y. | |
| * | |
| * @param (a) The array. | |
| * @param (x) The index of the first element to swap. | |
| * @param (y) The index of the second element to swap. | |
| * @return {Array} The input array with the elements swapped. | |
| */ | |
| var swapArrayElements = function (a, x, y) { | |
| if (a.length === 1) return a; |