Skip to content

Instantly share code, notes, and snippets.

View MaraAlexa's full-sized avatar

Mara Alexa MaraAlexa

View GitHub Profile
@MaraAlexa
MaraAlexa / github-basic.js
Created February 26, 2019 14:13
Create new Repo on Github, clone it to your local comp, add changes and push them on Github
// Create a new Github Repo
on Github website click +
// clone the Github repo on your comp
git clone 'url_repo_from_github'
// Check remotes (references to repos that are not on my comp)
git remote -v
// if you don't have an origin remote, create one
function fetchCatAvatars(userId) {
return fetch(`https://catappapi.herokuapp.com/users/${userId}`)
.then(response => response.json())
.then(user => {
const promises = user.cats.map(catId =>
fetch(`https://catappapi.herokuapp.com/cats/${catId}`)
.then(response => response.json())
.then(catData => catData.imageUrl))
return Promise.all(promises)
})
function fetchCatAvatars(userId) {
return fetch(`https://catappapi.herokuapp.com/users/${userId}`)
.then(response => response.json())
.then(user => {
const promises = user.cats.map(catId =>
fetch(`https://catappapi.herokuapp.com/cats/${catId}`)
.then(response => response.json())
.then(catData => catData.imageUrl))
return Promise.all(promises)
})
const fetch = require("node-fetch");
async function showGitHubUser(handle) { // add async keyword
const url = `https://api.github.com/users/${handle}`;
const response = await fetch(url); // await takes in a promise and pauses the execution until the promise is settled
const user = await response.json(); // wait for the json response as well
console.log(user.name);
console.log(user.location);
}
// MUTATIONS - Vuex mutations are essentially events: each mutation has a name and a handler - Mutations mutate the state
- is the only way to modify state
- doesn't care about business logic, it just care about "state"
const store = new Vuex.Store({
state: {
count: 1
},
mutations: {
INCREMENT (state) {
@MaraAlexa
MaraAlexa / vuex.js
Created January 9, 2018 09:17
Action vs Mutations
// Mutations- the only way to MODIFY stATE - doesn't care about business logic, it just care about "state"
// are essentially events: each mutation has a name and a handler.
const store = new Vuex.Store({
state: {
count: 1
},
mutations: {
INCREMENT (state) {
// mutate state
@MaraAlexa
MaraAlexa / terminal.js
Created November 22, 2017 12:23
Install node on Linux MInt
// NOTE:install node package from nodejs website. After instalation follow the instructions from this gihub page:
https://github.com/nodejs/help/wiki/Installation
Instructions step by step:
1.
Install node and then follow the instructions from point 1 in terminal
2.
// to go to .profile:
@MaraAlexa
MaraAlexa / initiateReactNativeReduxApp.js
Last active November 15, 2017 12:36
start a React Native App with Redux
// initiate a React Native App
react-native init ReactNativeReduxApp
// go to your app folder
cd ReactNativeReduxApp
// run the ios simulator
react-native run-ios
// add dependencies
@MaraAlexa
MaraAlexa / new_repo_terminal.js
Created November 8, 2017 10:33
connect git with github
// initiate git (local new repo)
git init
// save all the files in your new local repo
git add .
// commit them
git commit -m "First commit"
// connect git with github repo
@MaraAlexa
MaraAlexa / terminal.js
Last active November 7, 2017 09:50
Deploy with Now
// UPDATING NEW VERSION (from github)
// Clone the version from github
git clone (paste copied url)
// Add dependencies
cd (your_project)
yarn
// deploying a new version