This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Given a string `substr`, getMovieTitles() must perform the following tasks: | |
1. Query https://jsonmock.hackerrank.com/api/movies/search/?Title=substr (replace substr). | |
2. Initialize the titles array to store total string elements. Store the Title of each movie meeting the search criterion in the titles array. | |
3. Sort titles in ascending order and return it as your answer. | |
*/ | |
const https = require('https'); | |
function getTotalPageCount(url, callback) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
main(){ | |
declare timestamp; | |
declare -i downtime; | |
while true; do | |
packet_loss=$(ping google.com -q -c 1 | grep -oe '\d\+.\d\+%') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {Redirect} from 'react-router-dom'; | |
class Login extends React.Component { | |
state = { | |
redirectToReferrer: false | |
}; | |
login = () => { | |
fakeAuth.authenticate(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Route, Redirect } from "react-router-dom"; | |
const PrivateRoute = ({component: Component, isAuthenticated, ...rest}) => ( | |
<Route {...rest} render={props => ( | |
isAuthenticated | |
? | |
(<Component {...props}/>) | |
: | |
(<Redirect to={{pathname: '/login', state: {from: props.location}}}/>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Switch><Route exact path="/" component={Home}/> | |
<Route path="/items" component={Items}/> | |
<Route path="/category" component={Category}/> | |
<Route path="/login" component={Login}/>}/> | |
<PrivateRoute | |
path="/admin" | |
component={Admin} | |
isAuthenticated={fakeAuth.isAuthenticated} | |
/> | |
</Switch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A JS implementation of a queue | |
class Queue { | |
constructor() { | |
this.list = []; | |
this.length = 0; | |
} | |
enqueue(value) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// An JS implementation of a stack | |
class Stack { | |
constructor() { | |
this.list = []; | |
this.length = 0; | |
} | |
push(value) { | |
this.length++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Stack { | |
constructor() { | |
this.list = []; | |
this.length = 0; | |
} | |
push(value) { | |
this.length++; | |
this.list.push(value); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// An implementation of a binary search function | |
const myList = [2, 4, 5, 8, 9, 13, 22, 37, 40, 52, 58, 67, 89, 106]; | |
const binarySearchFunc = (listToSearch, itemToSearchFor) => { | |
let start = 0; | |
let end = listToSearch.length - 1; | |
let middle = Math.floor((start + end) / 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOMServer from 'react-dom/server'; | |
import express from 'express'; | |
import puppeteer from 'puppeteer'; | |
import App from "./src/App"; | |
const app = express(); | |
const fs = require('fs'); | |
const args = process.argv.slice(2); |