Skip to content

Instantly share code, notes, and snippets.

View camilomontoyau's full-sized avatar

camilo montoya camilomontoyau

View GitHub Profile
@camilomontoyau
camilomontoyau / scope.js
Created October 21, 2020 14:54
javascript scope
const a = 1;
const b = 2;
const c = 3;
(function firstFunction() {
const b = 5;
const c = 6;
(function secondFunction() {
const b = 8;
(function thirdFunction() {
@camilomontoyau
camilomontoyau / async.js
Last active October 21, 2020 14:56
async order
const p = () => Promise.resolve(5);
const y = async () => {
const t = await p();
console.log(t);
};
y();
console.log('hello');
@camilomontoyau
camilomontoyau / test.js
Created September 11, 2020 19:29 — forked from getify/test.js
fun call-stack experiment
function foo() {
baz();
}
function bar() {
baz();
}
function baz() {
console.log(`baz() was called from: ${whereWasICalledFrom()}`);
@camilomontoyau
camilomontoyau / index.js
Created May 1, 2020 15:58
ejemplo conexión mongo con mongoose y nodejs
const mongoose = require('mongoose');
(async()=>{
await mongoose.connect('mongodb://nodeco-test-user:nodecotest1234@ds163822.mlab.com:63822/nodeco-test-01-mayo', {
useNewUrlParser: true,
useUnifiedTopology: true
});
})()
@camilomontoyau
camilomontoyau / useBreadcrumbEllipsis.js
Last active April 8, 2020 17:42
react hook for listening window resize event
function useBreadcrumbEllipsis(crumbs, windowWidth) {
if(!crumbs.length) {
return [];
}
let _crumbs = _.cloneDeep(crumbs);
let processedCrumbs = [];
let totalCharactersSize = 0;
let pastTotalCharactersSize = 0;
let maxCharactersSize = 0;
switch(true) {
@camilomontoyau
camilomontoyau / scope.js
Created September 3, 2019 19:36
scope.js
/* for (var i = 1; i <= 5; i++) {
(function() {
setTimeout(function timer() {
console.log(i);
}, i * 1000);
})();
} */
/* for (var i = 1; i <= 5; i++) {
(function() {
@camilomontoyau
camilomontoyau / daniel2.js
Created November 21, 2018 19:37
async await
const getReview = async slug => {
try {
const userUid = await knex('user')
.where({
company_name: slug
})
.select('uid');
const userReviews = await axios.get(
`${url}/quotes/v1/reviews/?user=${user_uid}`,
@camilomontoyau
camilomontoyau / paso16.html
Created November 12, 2018 04:41
react es JS
<html>
<body>
<div>
<div>PROP: <span>hola soy un texto estático</span></div>
<div>ESTADO: <span id="clicks">0</span></div>
<button id="boton">click acá</button>
</div>
<script type="text/javascript">
const clicksElement = document.getElementById('clicks');
const boton = document.getElementById('boton');
<html>
<head>
<title>un título</title>
<meta charset="UTF-8" />
<style>
.letra-color-azul {
color: blue;
}
</style>
</head>
@camilomontoyau
camilomontoyau / paso14.html
Created November 12, 2018 02:55
react es js
<html>
<head>
<title>un título</title>
<meta charset="UTF-8" />
<style>
.letra-color-azul {
color: blue;
}
</style>
</head>