Skip to content

Instantly share code, notes, and snippets.

View brauliodiez's full-sized avatar

Braulio Diez brauliodiez

View GitHub Profile
@brauliodiez
brauliodiez / readme.md
Last active September 1, 2023 04:48
lodash/fp set and flow

lodash/fp - set / flow

In this gist we are going to learn about basic goodies that we get from the library lodash/fp (fp stands for functional programming, great for ensuring immutability).We'll learn just by doing (step by step guided sample + codepens).

We'll cover lodash set and flow functions

Steps

  • We'll use codepen as our playground, navigate to this page:
@brauliodiez
brauliodiez / readme.md
Created June 4, 2017 09:12
javascript currying

Currying

Currying is the act of turning a function into a new function that takes slightly fewer arguments, achieving a slightly more specific task.

http://macr.ae/article/es6-and-currying.html

Steps

Let's start by making a simple function that will sum up two numbers, using currying:

@brauliodiez
brauliodiez / Readme.md
Last active March 10, 2020 16:35
Para poner un pin centrado en cada comunidad autónoma en una mapa de españa, esto es útil para poder usarlo con por ejemplo d3js

Comunidades autonomas - Marcadores centrados

Listado de latitud y longitud, marcadores centrados por cada comunidad autónoma (España).

Posibles utilidades: mapas que montes con d3js.

Ejemplo de uso: https://codesandbox.io/s/hopeful-ellis-rlczx

class Pedido {
constructor() {
this.descuento = 0.90;
this.venta = 100;
}
aplicaDescuento() {
debugger;
console.log(this.venta);
var self = this;
@brauliodiez
brauliodiez / generators.md
Last active January 23, 2019 18:16
Notas del training de generadores (Español)

Conceptos básicos

En javascript cuando llamamos a una función esta se ejecuta de inicio a final.

function logger() {
console.log('Start');
console.log('End');
}
@brauliodiez
brauliodiez / swaggernotes.md
Last active January 4, 2019 12:13
Notes about swagger

Installing swagger globally

npm install -g swagger

Create a new swagger project

swagger project create 
@brauliodiez
brauliodiez / PodsProposal.MD
Last active August 26, 2018 16:27
Pods proposal

Pods proposal

Draft Pods proposal for the Chat solution, topics to discuss:

  • Likely lobby and chat components should be in the same pods.
  • This would just to show how to isolate in pods (core will hold session-info reducer).

Option A)

├───common-app
@brauliodiez
brauliodiez / readme.md
Last active June 4, 2018 10:01
Simple ES6 reduce sample

reduce

Reduce allows us calculate a total, applying an operation on every operation of an array.

This can save us lot of "for" loops (enhannce readibility).

steps

Let's implement a function that will sum up an array.

@brauliodiez
brauliodiez / closure.js
Last active June 3, 2018 08:35
Closure sample
const calculateFinalPrice = function () {
const discount = 0.90;
// simulate ajax call
setTimeout(function() {
const total = 200;
const final = total * discount;
console.log(final)
}, 500);
}
@brauliodiez
brauliodiez / readme.md
Last active April 15, 2018 07:02
Spread Operator simple samples

spread operator

The spread syntax allows an expression to be expanded in places where multiple arguments (for function calls) or multiple elements (for array literals) or multiple variables (for destructuring assignment) are expected.

steps

Copying an object but replacing some properties:

This one we will need bable to make it work