Skip to content

Instantly share code, notes, and snippets.

View srbying's full-sized avatar

Steven Byington srbying

View GitHub Profile
@srbying
srbying / gist:f77a2ad5234882674874054239129722
Last active August 29, 2019 17:54
Cycle detection in a directed unweighted graph
class Graph {
constructor() {
this.adjList = {}
}
addVertex(vertex) {
this.adjList[vertex] = []
}
addEdge(vertex1, vertex2) {
@srbying
srbying / Stack.js
Created December 21, 2017 00:03
A Javascript implementation of the stack data structure.
/**
* A Javascript implementation of the stack data structure.
* @Param {size} The maxsize of the stack
*/
var Stack = (function(size) {
let stack = [],
MAXSIZE = size || 0;
function Stack(size) {
@srbying
srbying / Queue.js
Created December 20, 2017 23:37
A Javascript implementation of the queue data structure.
/**
* A Javascript implementation of the queue data structure.
* @Param {size} The maxsize of the queue
*/
var Queue = (function(size) {
let queue = [],
MAXSIZE = size || 0;
function Queue(size) {
@srbying
srbying / BinarySearchTree.js
Last active August 22, 2019 23:36
A simple implementation of a Binary Search Tree in javascript
/**
* A simple implementation of a Binary Search Tree in javascript.
* Author: Steven Byington
**/
let BinarySearchTree = (function() {
function BinarySearchTree(data) {
this.data = data;
this.left = null;
this.right = null;
@srbying
srbying / LinkedList.js
Last active October 30, 2017 21:21
A Linked List implementation for javascript
///////////////////////////////////////////////////
// //
// Node //
// //
///////////////////////////////////////////////////
function Node(data, next) {
this.data = data;
this.next = next;
}
@srbying
srbying / anchor-smooth-scroll.directive.js
Created October 6, 2017 05:18
A directive that adds a smooth scroll animation from one element to another
/**
* Smooth Scroll allows the user to apply a scrolling animation to a given element.
*
* Example:
* <div smooth-scroll anchor-smooth-scroll="scrolled" anchor-padding="{top: 25}"></div>
* <div id="scrolled"></div>
*/
(function() {
'use strict';
@srbying
srbying / emptyObj.js
Created July 26, 2017 03:42
A recursive function to empty an object of all falsey values
function emptyObj(object) {
if (!isObject(object)) {
throw new TypeError(arguments[0] + ' is not of type Object');
}
let ret = function(object) {
// Loop through object
for (let prop in object) {
@srbying
srbying / karma-jenkins.conf.js
Created July 19, 2017 05:01
This is a basic configuration for setting up Karma to run with Jenkins. It uses PhantomJs as a headless browser, and babel to tranpile es6 to es5. PhantomJs 2.1 does not currently itilize es6 features. Finally it exports a junit report xml file to be used by Jenkins.
/**
* This is a basic configuration for setting up Karma to run with Jenkins. It uses PhantomJs as a headless browser, and babel to tranpile es6 to es5. PhantomJs 2.1
* does not currently itilize es6 features. Finally it exports a junit report xml file to be used by Jenkins.
/*/
// Dependencies Needed
// npm install babel-core, babel-loader babel-polyfill babel-preset-es2015 karma karma-babel-preprocessor karma-html-reporter karma-html2js-preprocessor karma-jasmine karma-junit-reporter phantomjs phantomjs-prebuilt --save-dev
// Karma configuration
// http://karma-runner.github.io/0.10/config/configuration-file.html