Skip to content

Instantly share code, notes, and snippets.

View kirasiris's full-sized avatar
😍
In love with JavaScript!!

Kevin Uriel Fonseca kirasiris

😍
In love with JavaScript!!
View GitHub Profile
@kirasiris
kirasiris / Login.js
Last active January 4, 2021 01:45
TFAuthenticationWithNodeJSandMongoDB
///
///
/// AS THE FILE TITLE SUGGEST, THIS IS WHERE YOU SEND YOUR USERNAME AND/OR PASSWORD DATA
///
///
import React, { useEffect, useState } from 'react';
import { Link, withRouter } from 'react-router-dom';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import Helmet from 'react-helmet';
// per https://docs.npmjs.com/misc/scripts, npm exposes a bunch of variables to
// the environment prefixed with npm_config_*, npm_package_* and npm_lifecycle_*.
// Here's a list of all variables exposed in my setup.
npm_config_access=
npm_config_allow_same_version=
npm_config_also=
npm_config_always_auth=
npm_config_argv='{"remain":[],"cooked":["run","foo"],"original":["run","foo"]}'
npm_config_auth_type=legacy
export const addPost = (formData, files, setUploadPercentage) => async dispatch => {
try {
// ATTACH FILES
let fileKeys = [];
for(let file of files) {
const uploadConfig = await axios.get(`${API}/api/v1/uploads/getS3url?type=${file.type}`);
await axios.put(uploadConfig.data.url, file, {
@kirasiris
kirasiris / handleTwoInputs.js
Created April 22, 2020 23:44
Throws an error.
const [avatar, setAvatar] = useState('');
const [avatarname, setAvatarName] = useState('Choose File');
const [cover, setCover] = useState('');
const [covername, setCoverName] = useState('Choose File');
const [uploadPercentage, setUploaderPercentage] = useState(0);
const handleChange = name => e => {
setProducerData({...producerData, [name]: e.target.value});
setAvatar(e.target.files[0]);
setAvatarName(e.target.files[0].name);
@kirasiris
kirasiris / example.json
Created April 3, 2020 02:36
A example displaying JSON data from an Application I'm working on.
"data": [
{
"skills": [],
"languages": [],
"featured": "no",
"status": "published",
"_id": "5e22cb366eb08933b0de664e",
"title": "My second resume",
"email": "kebin1421@hotmail.com",
"address": "10153 Red Bluff Ln Fort Worth, TX",
@kirasiris
kirasiris / component.js
Last active February 19, 2020 02:45
Load CSS and JavaScript files dynamically on React!
import useCSS from 'PATH_TO_useCSS_FILE';
import useScript from 'PATH_TO_useScript_FILE';
/*
* useCSS usage
*/
useCSS("https://www.w3schools.com/w3css/4/w3.css", "head");
useCSS("https://www.w3schools.com/w3css/4/w3.css", "body");
/*
@kirasiris
kirasiris / MathMethods.cs
Last active February 19, 2020 02:45
TO COMPLETE!! Needs string validation!
using System;
namespace Unit2_Calculator_AzuaraFonseca {
class MathMethods {
public void showMenu() {
Console.WriteLine("|----------------------------------------------|");
Console.WriteLine("| A: Addition |");
Console.WriteLine("| B: Substraction |");
Console.WriteLine("| C: Multiplication |");
@kirasiris
kirasiris / Car.cs
Last active January 29, 2020 03:18
Example of creating a class in C#. The right way.
/*
* Each class should have a getter and a setter.
*/
using static System.Console;
namespace FourthConsoleApplicationUnitMethods {
class Car {
public string brand = "";
@kirasiris
kirasiris / MethodOverloading.cs
Created January 29, 2020 02:20
An example on creating Overloading in C#
using static System.Console;
namespace FourthConsoleApplicationUnitMethods
{
class UnitMethods {
// Method Overloading
static int Add(int a, int b) {
int result = a + b;
return result;
@kirasiris
kirasiris / Page.js
Created September 20, 2019 01:54
Here it is whole CRUD system lol.
import axios from 'axios';
import { setAlert } from '../alert';
import {
GET_PAGES,
CLEAR_PAGE,
PAGE_ERROR,
// UPDATE_LIKES,
DELETE_PAGE,
ADD_PAGE,
GET_PAGE,