Skip to content

Instantly share code, notes, and snippets.

Avatar

Nya NyaGarcia

View GitHub Profile
@NyaGarcia
NyaGarcia / docker-compose.yml
Created Apr 16, 2019
docker-compose.yml file for dockerizing mongoDB
View docker-compose.yml
version: "3.1"
services:
db:
container_name: mongoDB
image: mongo:latest
restart: always
volumes:
- ./pokeData:/data/db
environment:
@NyaGarcia
NyaGarcia / async Array.map
Last active Apr 29, 2019
Using async await inside of Array.map()
View async Array.map
function getCalculatedRoutes(routes: Array<any>): Promise<any> {
return Promise.all(
routes.map(async (route: any) => {
const distance = await getDistance();
route.distance = distance;
route.cost = calculateCost(distance);
return route;
})
);
}
@NyaGarcia
NyaGarcia / docker-compose.yml
Last active Sep 2, 2019
MongoDB Compose file with named .env file
View docker-compose.yml
version: '3.1'
services:
db:
container_name: Mongo-db
image: mongo:latest
restart: always
volumes:
- ./myData:/data/db
env_file:
@NyaGarcia
NyaGarcia / docker-compose.yml
Last active Sep 5, 2019
MongoDB Compose file with environment variables
View docker-compose.yml
version: '3.1'
services:
db:
container_name: Mongo-db
image: mongo:latest
restart: always
volumes:
- ./myData:/data/db
environment:
@NyaGarcia
NyaGarcia / docker-compose.yml
Last active Sep 5, 2019
MongoDB Compose file using string interpolation to assign values to the environment variables
View docker-compose.yml
version: '3.1'
services:
db:
container_name: Mongo-db
image: mongo:latest
restart: always
volumes:
- ./myData:/data/db
environment:
@NyaGarcia
NyaGarcia / merge-object-arrays.js
Created Sep 12, 2019
Merging object arrays with spread operator
View merge-object-arrays.js
const pokemon = [
{ name: 'Squirtle', type: 'Water' },
{ name: 'Bulbasur', type: 'Plant' }];
const morePokemon = [{ name: 'Charmander', type: 'Fire' }];
const pokedex = [...pokemon, ...morePokemon];
console.log(pokedex); //Result: [ { name: 'Squirtle', type: 'Water' }, { name: 'Bulbasur', type: 'Plant' }, { name: 'Charmander', type: 'Fire' } ]
@NyaGarcia
NyaGarcia / merge-arrays.js
Last active Sep 12, 2019
Merging arrays with the spread operator
View merge-arrays.js
const pokemon = ['Squirtle', 'Bulbasur', 'Charmander'];
const morePokemon = ['Totodile', 'Chikorita', 'Cyndaquil'];
const pokedex = [...pokemon, ...morePokemon];
console.log(pokedex); //Result: [ 'Squirtle', 'Bulbasur', 'Charmander', 'Totodile', 'Chikorita', 'Cyndaquil' ]
@NyaGarcia
NyaGarcia / spread-array-examples.js
Created Sep 12, 2019
Three examples of how the spread operator works with arrays
View spread-array-examples.js
const numbers = [1, 2, 3];
console.log(...numbers); //Result: 1 2 3
const pokemon = ['Squirtle', 'Bulbasur', 'Charmander'];
console.log(...pokemon); //Squirtle Bulbasur Charmander
const pokedex = [
{ name: 'Squirtle', type: 'Water' },
{ name: 'Bulbasur', type: 'Plant' },
{ name: 'Charmander', type: 'Fire' }
View keybase.md

Keybase proof

I hereby claim:

  • I am nyagarcia on github.
  • I am nyachan (https://keybase.io/nyachan) on keybase.
  • I have a public key ASCX_KYHXdj9trZ43Hq4aShjNWxZxVQ-XNDJM8IMc9sV1go

To claim this, I am signing this object:

@NyaGarcia
NyaGarcia / immutable-object.js
Created Sep 14, 2019
Copying an object immutably with the spread operator
View immutable-object.js
const mySquirtle = {
name: 'Squirtle',
type: 'Water',
hp: 100
};
const anotherSquirtle = { ...mySquirtle };
anotherSquirtle.hp = 0;
console.log(anotherSquirtle); //Result: { name: 'Squirtle', type: 'Water', hp: 0 }
You can’t perform that action at this time.