Skip to content

Instantly share code, notes, and snippets.

View daronwolff's full-sized avatar
🏠
Working from home

daronwolff daronwolff

🏠
Working from home
  • Me
  • México
View GitHub Profile
@daronwolff
daronwolff / create_ssh_key
Last active March 1, 2017 21:20
Create and send ssh key. Ubuntu 16
ssh-keygen -t rsa
echo "alias myserver='ssh [email protected]'" >> $HOME/.bashrc
cat $HOME/.ssh/id_rsa.pub | ssh [email protected] 'cat >> .ssh/authorized_keys'
source $HOME/.bashrc
myserver
@daronwolff
daronwolff / webpack.config.js
Created February 13, 2017 22:10
boilerplate webpack react
var webpack = require('webpack');
var path = require('path');
module.exports = {
devtool: 'inline-source-map',
entry: [
'webpack-dev-server/client?http://127.0.0.1:8080/',
'webpack/hot/only-dev-server',
'./src'
],
@daronwolff
daronwolff / capitalize.js
Created March 29, 2017 15:54
CapitalizeString and remove white spaces
function capitalize(str) {
return str.replace(/\b\w/g, l => l.toUpperCase())
.replace(/\s/g, '');
}
@daronwolff
daronwolff / resolveObject.js
Created April 13, 2017 16:43
This function is similar to Promise.all but this receives an object. The param names from promisesObject is used to clasify the information
function resolveObject(promisesObject) {
const data = {};
let ready = Promise.resolve(null);
Object.keys(promisesObject).forEach((name) => {
const promise = promisesObject[name];
ready = ready.then(() => promise)
.then((value) => {
data[name] = value;
});
});
@daronwolff
daronwolff / sequentially.js
Created June 16, 2017 20:18
Executing promises sequentially
const times = [ 1, 3, 4, 2 ];
const sleep = ms =>
new Promise(res => {
const t = ms * 1000;
setTimeout(res, t)
})
const myPromise = num =>
sleep(num).then(() => {