Skip to content

Instantly share code, notes, and snippets.

@camilomontoyau
camilomontoyau / tip.js
Created August 28, 2017 18:51
javascript tip of the day 2017-08-28
let g = {
a: 'r',
b: 5,
c: ''
};
console.log('(g.a)', (g.a)); //(g.a) r
console.log('(g.b)', (g.b)); //(g.b) 5
console.log('(g.c)', (g.c)); //(g.c)
console.log('(g.d)', (g.d)); //(g.d) undefined
@camilomontoyau
camilomontoyau / gist:8fcff915d84a57f70978c82342b4644e
Created July 1, 2018 22:45
partitions of a number in javascript
const reducer = (accumulator, currentValue) => accumulator + currentValue;
const hasElementGreaterThanOne = (array = []) => {
let begin = array.length - 2;
let result = false;
if (begin > 0) {
for (let i = begin; i > 0; i--) {
if (array[i] > 1) {
result = i;
break;
@camilomontoyau
camilomontoyau / index.js
Created October 2, 2018 20:11
npm dropbox upload files via streams
const dropboxV2Api = require('dropbox-v2-api');
const path = require('path');
const fs = require('fs');
const {token} = process.env;
const dropbox = dropboxV2Api.authenticate({
token
});
const dropboxUploadStream = dropbox(
@camilomontoyau
camilomontoyau / index.js
Created October 2, 2018 20:07
npm dropbox sdk example for nodejs file updload
const { Dropbox } = require('dropbox');
const fs = require('fs');
const path = require('path');
const fetch = require('isomorphic-fetch');
const {DROPBOX_AUTH} = process.env
var dbx = new Dropbox({ accessToken: DROPBOX_AUTH, fetch });
fs.readFile(path.join(__dirname, '/test.txt'), 'utf8', function(err, contents) {
@camilomontoyau
camilomontoyau / main.js
Created October 6, 2018 15:35
react starbucks
const container = document.getElementById('container');
const segundo = document.createElement('div');
segundo.id = 'segundo';
segundo.innerText = 'hola soy segundo';
container.appendChild(segundo);
@camilomontoyau
camilomontoyau / paso1.html
Created November 11, 2018 14:47
react es solamente js
<html>
<head>
<title>un título</title>
<meta charset="UTF-8" />
</head>
<body>
<div>esto es un div</div>
</body>
</html>
@camilomontoyau
camilomontoyau / paso2.html
Created November 11, 2018 14:51
react es js
<html>
<head>
<title>un título</title>
<meta charset="UTF-8" />
</head>
<body>
<script type="text/javascript"></script>
</body>
</html>
@camilomontoyau
camilomontoyau / paso3.html
Created November 11, 2018 14:54
react es js
<html>
<head>
<title>un título</title>
<meta charset="UTF-8" />
</head>
<body>
<script type="text/javascript">
const div = document.createElement("div");
div.innerText = "hola soy un div";
document.body.appendChild(div);
@camilomontoyau
camilomontoyau / paso4.html
Created November 11, 2018 15:22
react es js
<html>
<head>
<title>un título</title>
<meta charset="UTF-8" />
</head>
<body>
<div id="app"></div><!-- este es un div con el fin de que toda la interfaz gráfica sea insertada en el mismo -->
<script type="text/javascript"> //Aquí comienza el navegador a entender código javascript
@camilomontoyau
camilomontoyau / paso5.html
Created November 11, 2018 17:08
react es js
<html>
<head>
<title>un título</title>
<meta charset="UTF-8" />
</head>
<body>
<div id="app"></div>
<script type="text/javascript">
const div = document.createElement("div");
div.innerText = "hola soy un div";