This file contains hidden or 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 times = [ 1, 3, 4, 2 ]; | |
const sleep = ms => | |
new Promise(res => { | |
const t = ms * 1000; | |
setTimeout(res, t) | |
}) | |
const myPromise = num => | |
sleep(num).then(() => { |
This file contains hidden or 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 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; | |
}); | |
}); |
This file contains hidden or 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 capitalize(str) { | |
return str.replace(/\b\w/g, l => l.toUpperCase()) | |
.replace(/\s/g, ''); | |
} |
This file contains hidden or 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 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' | |
], |
This file contains hidden or 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
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 |
This file contains hidden or 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
server { | |
listen 80 default_server; | |
listen [::]:80 default_server ipv6only=on; | |
root /home/javier/sites/sitename/public; | |
index index.php index.html index.htm; | |
server_name server_domain_or_IP; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; |
This file contains hidden or 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
// Module Design Pattern | |
var Car = (function() { | |
var manufacturer = "hyundai"; | |
var wheels = 4; | |
var price = 149000; | |
var isAdmin = false; | |
var loginAdmin = function(u, p) { | |
if (u === 'admin' && p === '123') { | |
isAdmin = true; | |
console.log('Welcome admin'); |
This file contains hidden or 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
// | |
// This function can be used to decode a string with token_id from openId response | |
// | |
function decode_tokenid(token){ | |
var elements = Array(); | |
elements[0] = atob(token.split(".")[0]); | |
elements[1] = atob(token.split(".")[1]); | |
return elements; | |
} |
This file contains hidden or 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 clear_string | |
* | |
* Function used to user strings as usernames, filenames | |
* This function removes the accents, white-spaces and symbols from characters in a string | |
*/ | |
if (! function_exists('clear_string')) | |
{ | |
function clear_string($str = '') | |
{ |
This file contains hidden or 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 Triangle() { | |
this.a; | |
this.b; | |
this.c; | |
this.setSides = function(a, b, c) { | |
this.a = a; | |
this.b = b; | |
this.c = c; | |
}; |
NewerOlder