Skip to content

Instantly share code, notes, and snippets.

View graph.js
class Graph {
constructor(numberOfVertices) {
this.size = numberOfVertices;
this.list = new Map();
}
addVertex(v) {
this.list.set(v, []);
}
addEdge(v, w) {
this.list.get(v).push(w);
@josh-stevens
josh-stevens / TextScramble.js
Created Feb 14, 2019
Cool text scramble effect (use Roboto Mono 100 + #FAFAFA + #757575 for colors
View TextScramble.js
import React, { Component, Fragment } from 'react';
const chars = '!<>-_\\/[]{}-=+*^?#________';
class TextScramble extends Component {
constructor(props) {
super(props);
this.string = props.children;
this.length = this.string.length;
this.queue = [];
@josh-stevens
josh-stevens / BST.js
Created Feb 10, 2019
Basic Binary Search Tree in Javascript
View BST.js
class Node {
constructor(value, parent) {
this.value = value;
this.parent = parent || null;
this.left = null;
this.right = null;
}
insert(value) {
if (value > this.value) {
if (this.right === null) {
@josh-stevens
josh-stevens / elevator8.js
Last active Oct 19, 2018
Solution for elevator challenge 8
View elevator8.js
{
init: function(elevators, floors) {
elevators.forEach(elevator => {
elevator.on('floor_button_pressed', (num) => {
elevator.goToFloor(num);
});
});
floorHandler = (floor) => {
let closest, idle;
View keybase.md

Keybase proof

I hereby claim:

  • I am josh-stevens on github.
  • I am joshstevens (https://keybase.io/joshstevens) on keybase.
  • I have a public key ASAE3Kf-wxBVJU1OnAi_FfQph91OvTG2C5Ex-53GxOC30go

To claim this, I am signing this object: