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
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
use App\Models\Lead; | |
use App\Models\LeadMeta; | |
use App\Transformers\LeadTransformer; | |
class ApiLeadsController extends Controller | |
{ | |
// The transformer reformats the data to uncouple it from the shcema structure |
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
// code pen url: https://codepen.io/jaspercreel/pen/RgXjEp | |
// Declaring a node and list class outside of the hash class avoids binding issues with this | |
// The node class should only be created with a key value pair | |
class Node { | |
constructor(key, value) { | |
this[key] = value; | |
this.next = null; | |
} |
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
// This store locator makes use the moment.js plugin to help deal with timezones. | |
/* | |
Location objects are tailored to a specific model and expected to have a title, address, open and close time, as well as | |
an array of specific features used for filtering | |
*/ | |
/* | |
The initial locator object. Consolidating all the markers, stores, infowindows, |
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
/* | |
For this particular example the constraint is you cannot take two possibilities | |
that are next to each other. A real world example might be that you cannot invest multiple months | |
in a row and want to have the best chance at the best ROI. Kind of dumb but the point is | |
if there are constraints you want to track the best possible values for every sequence of moves, | |
only keeping track of the best possible outcomes | |
*/ | |
const bestOutcome = (arr) => { | |
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
$breakpoints: ( | |
"phone": 400px, | |
"phone-wide": 480px, | |
"phablet": 560px, | |
"tablet-small": 640px, | |
"tablet": 768px, | |
"tablet-wide": 991px, | |
"desktop": 1200px, | |
"desktop-wide": 1440px | |
); |
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
// It is expected that the array will be sorted, otherwise you will not get a proper search | |
// code pen url: https://codepen.io/jaspercreel/pen/yoYYVN | |
const binSearch = (arr, key) => { | |
if (!Array.isArray(arr)) { | |
console.log('This binary search requires an array'); | |
return; | |
} | |
if (!key) { |
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
const Sorter = function (arr = [], key = null, def = null) { | |
state = { | |
arr, | |
key, | |
def | |
} | |
const proto = { | |
type: 'Sorter', |
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
function kthLargestInBST(t, k) { | |
var check = function (value) { | |
k--; | |
if (k === 0) {return value;} | |
else {return false;} | |
} | |
var loop = function (node) { | |
if (!node) {return false} | |
return loop(node.left) || check(node.value) || loop(node.right) |
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
function largestValuesInTreeRows(t) { | |
function depthSearch(current) { | |
let values = []; | |
let depth = 0; | |
function traverse(current, depth) { | |
if (!current) { | |
return; | |
} | |
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
// Parts of this function were borrowed from http://blog.andrewray.me/how-to-clone-a-nested-array-in-javascript/ | |
// Link to code pen: https://codepen.io/jaspercreel/pen/jLmEWL | |
function trueClone(item) { | |
let copy, i; | |
if (Array.isArray(item)) { | |
copy = item.slice(0); | |
for (i = 0; i < copy.length; i++) { | |
copy[i] = trueClone(copy[i]); |
OlderNewer