Skip to content

Instantly share code, notes, and snippets.

View erockdotdev's full-sized avatar

Eric Sanchez erockdotdev

View GitHub Profile
@erockdotdev
erockdotdev / writing-yaml.md
Last active January 10, 2022 19:58
Writing YAML

YAML is a superset of JSON

The basic structure of YAML is a hash map -

hash map

key: value
### Keybase proof
I hereby claim:
* I am erockdotdev on github.
* I am erockdanger (https://keybase.io/erockdanger) on keybase.
* I have a public key ASA7LSOzhJwsKz1RHmLpvkp4mLkrfS0Vwb0jfXJX3V1bbwo
To claim this, I am signing this object:
// Given 2 positive integers find out if the 2 numbers have the same frequency of digits
function numberToArrStr(num){
return num.toString().split('');
};
function incrementFrequency(obj){
return function(n){
obj[n] = ++obj[n] || 1
};
@erockdotdev
erockdotdev / gist:51dcad5b16c6d8652777960f74aa56f4
Last active July 1, 2020 14:26
Really Really Helpful Links
Executing Shell Commands with Node.js
https://stackabuse.com/executing-shell-commands-with-node-js/
Configuring automatic backups for Contentful
https://www.contentful.com/blog/2019/05/15/configuring-automatic-backups-for-contentful/
VS code change es-lint settings
https://bit.ly/3g6Lwde
CTRL + SHIFT + P, type workspace settings (JSON) and press ENTER.
Slice vs Splice
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];
slice // immutable ( does not mutate original array )
Add new heroku remote ( if you rename an app in heroku run this step before renaming remotes)
heroku git:remote -a [app name].
Add remote with name
heroku git:remote -a [app name] -r [remote]
exmaple: heroku git:remote -a erock-dot-dev-staging -r staging
Remove heroku remote
git remote rm [remote name]
function outterFunction() {
let score = 0;
return function innerFunctio() {
if (score === 0) {
console.log("you have no points");
} else {
console.log(`you have ${score} points`);
}
score += 1;
};
const person = {
firstName: "Eric",
lastName: "Sanchez",
get fullName() {
return `${this.firstName} ${this.lastName}`;
},
set fullName(name) {
const updateName = name.split(" ");
this.firstName = updateName[0];
this.lastName = updateName[1];
@erockdotdev
erockdotdev / Class with getters and setters example
Created February 9, 2020 01:27
Class with getters and setters example
class Company {
constructor(brand){
this.brandName = brand;
}
get name() {
return this.brandName
}
set name(brand) {
this.brandName = brand;
}
@erockdotdev
erockdotdev / scrappy react hooks example
Created January 10, 2020 20:48
scrappy react hooks example with useState, useEffect and fetch
import React, { useState, useEffect } from "react";
function App() {
// implied setState in second param
const [buttonText, setButtonText] = useState("What is This?");
const [input, updateInput] = useState("placeholder");
const [swapiData, setData] = useState();