Skip to content

Instantly share code, notes, and snippets.

View jsonMartin's full-sized avatar

Jason Martin jsonMartin

View GitHub Profile
@jsonMartin
jsonMartin / poker.js
Created May 23, 2016 03:25
Blurb Poker Solution (JavaScript ES6)
"use strict";
class Card {
constructor(cardCode) {
const faceValues = {'J': 11, 'Q': 12, 'K': 13, 'A': 14}; // Face cards to numeric value dictionary
//Set internal card variables containing individual card properties
this.cardCode = cardCode; // Sets Card Code
this.suit = cardCode.slice(-1); // Sets Suit
this.face = cardCode.slice(0, cardCode.length - 1); // Sets Value
@jsonMartin
jsonMartin / isItEqual__maestro.js
Created June 14, 2016 01:22
My solution to Maestro isItEqual Dev Test question
"use strict";
function isItEqual(obj_1, obj2) {
//Hacky one-liner solution, works in most cases but not if Object has custom ordering
//return JSON.stringify(obj_1) === JSON.stringify(obj2);
//Proper recursive solution:
if(typeof(obj_1) !== typeof(obj2)) { return false; } // Check if obj_1 and obj2 are of different types
if(typeof obj_1 === 'object' && typeof obj2 === 'object') { //Check for Object
if(obj_1 && obj2 && (Object.keys(obj_1).length !== Object.keys(obj2).length)) { return false; } //If obj_1 and obj2 are valid, Check for number of keys in both obj_1 and obj2
@jsonMartin
jsonMartin / isItEqual__maestro.js
Created June 14, 2016 01:25
My solution to Maestro isItEqual Dev Test question Raw
"use strict";
function isItEqual(obj_1, obj2) {
//Hacky one-liner solution, works in most cases but not if Object has custom ordering
//return JSON.stringify(obj_1) === JSON.stringify(obj2);
//Proper recursive solution:
if(typeof(obj_1) !== typeof(obj2)) { return false; } // Check if obj_1 and obj2 are of different types
if(typeof obj_1 === 'object' && typeof obj2 === 'object') { //Check for Object
if(obj_1 && obj2 && (Object.keys(obj_1).length !== Object.keys(obj2).length)) return false; //If obj_1 and obj2 are valid, Check for number of keys in both obj_1 and obj2
/**
* Created by jsonmartin on 6/27/16.
*/
"use strict";
function digitsToNumbers(inputStr) {
if(!inputStr) return []; // Edge case handling, catches for empty inputStr
const digitMaps = {
'2': ['A', 'B', 'C'],
/**
* Created by jsonmartin on 6/27/16.
*/
"use strict";
function digitsToNumbers(inputStr) {
if(!inputStr) return []; // Edge case handling, catches for empty inputStr
const digitMaps = {
'2': ['A', 'B', 'C'],
@jsonMartin
jsonMartin / test.es6
Created October 5, 2016 19:46
Test ES6 code for PHPStorm/Babel integration
class Animal {
constructor(name, voice = "says") {
this._name = name;
this._voice = voice;
}
speak(phrase) {
return `${this._name} ${this._voice} ${phrase}.`;
}
}
/**
Last chair standing: 31
Chair removal order: [1,3,6,10,15,21,28,36,45,55,66,78,91,8,26,44,63,83,5,32,57,82,13,43,74,9,47,81,23,64,4,53,97,51,99,59,17,73,37,96,69,39,14,87,68,50,35,27,20,18,19,25,34,49,67,86,12,54,88,38,84,46,100,77,61,48,41,52,65,85,16,71,24,93,80,89,98,40,94,75,76,7,62,58,90,56,72,33,92,2,11,29,70,22,79,95,30,42,60]
*/
const NUM_CHAIRS = 100
// Each chair is a member item of a doubly linked list, where each chair is linked to the one before & after itself
class Chair {
constructor(number) {
/**
Last chair standing: 31
Chair removal order: [1,3,6,10,15,21,28,36,45,55,66,78,91,8,26,44,63,83,5,32,57,82,13,43,74,9,47,81,23,64,4,53,97,51,99,59,17,73,37,96,69,39,14,87,68,50,35,27,20,18,19,25,34,49,67,86,12,54,88,38,84,46,100,77,61,48,41,52,65,85,16,71,24,93,80,89,98,40,94,75,76,7,62,58,90,56,72,33,92,2,11,29,70,22,79,95,30,42,60]
*/
const NUM_CHAIRS = 100
// Each chair is a member item of a Doubly Linked List, where each chair is linked to the one before & after itself
class Chair {
constructor(number) {
@jsonMartin
jsonMartin / chairRemovalUsingLinkedList.js
Last active October 10, 2017 02:34
Chair removal programming challenge solution using Linked List & ES6 Generator/Iterator
/**
Last chair standing: 31
Chair removal order: [1,3,6,10,15,21,28,36,45,55,66,78,91,8,26,44,63,83,5,32,57,82,13,43,74,9,47,81,23,64,4,53,97,51,99,59,17,73,37,96,69,39,14,87,68,50,35,27,20,18,19,25,34,49,67,86,12,54,88,38,84,46,100,77,61,48,41,52,65,85,16,71,24,93,80,89,98,40,94,75,76,7,62,58,90,56,72,33,92,2,11,29,70,22,79,95,30,42,60]
*/
const NUM_CHAIRS = 100
// Each chair is a member of a Doubly Linked List, where every chair has a reference to the one before & after itself
class Chair {
constructor(number) {
<!-- Video ad includes START -->
<script src="https://www.popsugar.com/static/sugar-videojs-player/vendor/jquery.ba-throttle-debounce.js"></script>
<link href="https://vjs.zencdn.net/5.20.2/video-js.min.css" rel="stylesheet">
<script src="https://vjs.zencdn.net/5.20.2/video.min.js"></script>
<link rel="stylesheet" href="https://www.popsugar.com/static/sugar-videojs-player/vendor/videojs-ima/videojs.ima.css">
<link rel="stylesheet" href="https://www.popsugar.com/static/sugar-videojs-player/vendor/videojs-ima/videojs.ads.css">
<style>
/* Video ad CSS fix for Twinning */
#video-ad-player-container {