Skip to content

Instantly share code, notes, and snippets.

View CITGuru's full-sized avatar
🏠
Working from home

Oyetoke Tobiloba CITGuru

🏠
Working from home
View GitHub Profile
@CITGuru
CITGuru / app.js
Created January 26, 2020 00:02
App.js - Live DB
const express = require("express");
const cors = require("cors");
require("dotenv").config();
const app = express();
const { LiveDB } = require("./db");
// Middleware
app.use(express.json());
app.use(cors());
@CITGuru
CITGuru / ReactComponentExercise.js
Last active December 8, 2019 15:44
ReactComponentExercise.js.txt (Original)
/**
* This React class is intended to query an endpoint that will return an alphanumeric string, after clicking a button.
* This component is passed a prop "apiQueryDelay", which delays the endpoint request by N milliseconds. There is a
* second button to disable this functionality and have the endpoint request run immediately after button click.
* This data is then to be displayed inside a simple container.
* The "queryAPI" XHR handler will return the endpoint response in the form of a Promise (such as axios, fetch).
* The response object will look like the following: {data: "A0B3HCJ"}
* The containing element ref isn't used, but should remain within the class.
* Please identify, correct and comment on any errors or bad practices you see in the React component class below.
* Additionally, please feel free to change the code style as you see fit.
@CITGuru
CITGuru / Article.js
Last active December 3, 2019 00:53
Article Component 3
import React, { useState, useEffect } from "react";
import axios from "axios";
import useInfiniteScroll from "./useInfinite"
const Article = () => {
const [data, setData] = useState([]);
const [page, setPage] = useState(1);
const [isFetching, setIsFetching] = useInfiniteScroll(moreData);
const loadData = () =>{
@CITGuru
CITGuru / useInfinite.js
Created December 3, 2019 00:27
use infinite scroll
import { useState, useEffect } from "react";
const useInfiniteScroll = callback => {
const [isFetching, setIsFetching] = useState(false);
useEffect(() => {
window.addEventListener("scroll", isScrolling);
return () => window.removeEventListener("scroll", isScrolling);
}, []);
@CITGuru
CITGuru / Article.js
Last active December 3, 2019 00:53
Article Component 2
import React, { useState, useEffect } from "react";
import axios from "axios";
const Article = () => {
const [data, setData] = useState([]);
const [page, setPage] = useState(1);
const [isFetching, setIsFetching] = useState(false);
const loadData = () =>{
@CITGuru
CITGuru / Article.js
Last active December 3, 2019 00:54
React Component - Article (useInfiniteScroll)
import React, { useState, useEffect } from "react";
import axios from "axios";
const Article = () => {
const url = "https://medrum.herokuapp.com/articles";
const [data, setData] = useState([]);
useEffect(() => {
axios.get(url).then(res => {
setData(res.data);
});
@CITGuru
CITGuru / Article.js
Last active December 3, 2019 00:55
React Component - Article (useInfiniteScroll)
import React, { useState, useEffect } from "react";
import axios from "axios";
const Article = () => {
const url = "https://medrum.herokuapp.com/articles";
const [data, setData] = useState([]);
useEffect(() => {
axios.get(url).then(res => {
setData(res.data);
});
@CITGuru
CITGuru / get_all_links.py
Created November 17, 2019 06:23
Get all links from a website
@CITGuru
CITGuru / API.md
Last active September 23, 2019 09:05

API

Authentication

Login

route: /login method: POST

Request Body

@CITGuru
CITGuru / List.js
Created August 15, 2019 08:46
List Component
import React, { useState, useEffect } from "react";
import axios from "axios";
const List = () => {
const url = "https://medrum.herokuapp.com/articles";
const [data, setData] = useState([]);
useEffect(() => {
axios.get(url).then(res => {
setData(res.data);
});