Skip to content

Instantly share code, notes, and snippets.

View akhil-gautam's full-sized avatar
:electron:
Taking tea 🫖

Akhil Gautam akhil-gautam

:electron:
Taking tea 🫖
  • Hyderabad
View GitHub Profile
const API_URL =
'https://newsapi.org/v2/top-headlines?country=us&apiKey=65fe12450a1942bab3176e10e8c48062';
const getParentEl = () => document.querySelector('.list');
const getNews = () => {
fetch(API_URL)
.then((res) => res.json())
.then((res) => {
createList(res.articles);
@akhil-gautam
akhil-gautam / App.js
Created May 12, 2019 14:41
App.js file which is the root file which will be mounted to the dom and where routing will be configured.
import React, { Suspense, lazy } from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import './App.css';
// importing the Home component by default
import Home from './Components/Home';
// importing other components using Dynamic Import
const About = lazy(() =>
@akhil-gautam
akhil-gautam / ServerMonitor.tsx
Created April 24, 2019 16:39
Authorize my ServerMonitor component so that only Admins can see it
import * as React from 'react';
import { withAuthorization } from './withAuthorization';
// you can specify interface for props and state, I left it as 'any'
class ServerMonitor extends React.Component<any, any> {
render(){
return(
@akhil-gautam
akhil-gautam / withAuthorization.tsx
Created April 24, 2019 16:26
A Higher-Order Component to Authorize your React Components
import * as React from 'react';
// other parameters like allowed roles can also be passed to this HOC
// depending on your requirement.
export const withAuthorization = (OriginalComponent:any) => {
return class extends React.Component {
render(){
@akhil-gautam
akhil-gautam / config.yml
Created November 17, 2018 06:18
circleCI configuration
withDocker: &withDocker
docker:
- image: circleci/node:9.6
version: 2
jobs:
build:
working_directory: ~/ProjectDirectory
<<: *withDocker
steps:
- checkout
@akhil-gautam
akhil-gautam / firebase.json
Last active November 17, 2018 04:06
firebase.json file for multiple hsoting on firebase
{
"hosting": [
{
"target": "appone",
"public": "dist1",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],