Skip to content

Instantly share code, notes, and snippets.

/*
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) {
#!/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\+%')
import React from 'react';
import {Redirect} from 'react-router-dom';
class Login extends React.Component {
state = {
redirectToReferrer: false
};
login = () => {
fakeAuth.authenticate(() => {
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}}}/>)
<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>
@edmondatto
edmondatto / Queue.js
Last active August 30, 2018 17:40
A JavaScript implementation of a Queue by extending an array
// A JS implementation of a queue
class Queue {
constructor() {
this.list = [];
this.length = 0;
}
enqueue(value) {
@edmondatto
edmondatto / Stack.js
Created August 30, 2018 17:32
A JavaScript implementation of a Stack by extending an array
// An JS implementation of a stack
class Stack {
constructor() {
this.list = [];
this.length = 0;
}
push(value) {
this.length++;
@edmondatto
edmondatto / Stack.js
Created August 30, 2018 17:19
A JavaScript implementation of a stack
class Stack {
constructor() {
this.list = [];
this.length = 0;
}
push(value) {
this.length++;
this.list.push(value);
}
@edmondatto
edmondatto / BinarySearch.js
Created August 30, 2018 15:40
Implementation of the binary search algorithm in JavaScript
// 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);
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);