Instantly share code, notes, and snippets.

😅
Move Fast. Break Things.

# Garrett R. Morris r3wt

😅
Move Fast. Break Things.
• Walmart
• Hartman, Arkansas, United States
Created June 28, 2022 14:12
Splunk Interview Question - Find first duplicate in sequence whose next value is the sum of its digits squared.
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
 // i did poorly in my interview, the solution i gave worked but it was innefficient. // splunk passed on me, but i couldn't let it go. so here is my final solution of the problem function findFirstDuplicateInSeq( _seq ) { const seq = [..._seq];// clone the array first so we are not mutating it. while(true){ const next = seq[seq.length-1].toString().split('').map(v=>Math.pow(~~v,2)).reduce((a,b)=>a+b,0);// next val is sum of digits squared if(seq.indexOf(next)!==-1){ return seq.length+1;// if seq contains our next value already, we found the first duplicate. return length+1 } seq.push(next);// no match, push the next val in to the sequence
Created February 25, 2019 18:10
Search + Archive Implementation for a Ghost Blog
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
 // begin config const ghost_host = '';//your blogs domain -- see documentation of tryghost/content-api const ghost_key = '';//key to your integration -- see documentation of tryghost/content-api const updateInterval = 60000;//how often the index should update given in milliseconds const requestTimeout = 5000;// maximum time for a search request before it times out given in milliseconds (note this isn't exact, it depends on the load of the event loop) const resultsPerPage = [8];// allowed values for limit. in my case we only allow 8, but made this configurable so users of ghost can benefit // end config const elasticlunr = require('elasticlunr');
Last active July 4, 2021 14:48
@animateable decorator/mixin that can be used to add simple animations to any class object in javascript
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 animateable = (a) => { a.prototype.quad = function(x){ return x ** 2 }; a.prototype.linear = function(x){ return x; }; a.prototype.animate = function({ duration=300, ease=this.quad, start, end, onUpdate, onComplete=()=>{}}){
Created January 14, 2018 20:16
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 random_password = (len=64) => { let chars='abcdefghijklmnopqrstuvwxyz123456789-_=+`~:;>,.<}{[]|)(*&^%\$#@!'; let password = ''; while(password.length < len) { password+= chars.charAt(Math.floor((Math.random() * chars.length) + 1) % chars.length); } return password; };
Last active December 5, 2019 18:24
function bind()
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
 /* partial implementation of Function.prototype.bind */ Function.prototype.bind || (Function.prototype.bind = function(/* context[,arg1,arg2...] */) { var fn = this; var args = Array.prototype.slice.call(this,arguments);//preset args var context = args.shift() || undefined; return function(){ var args2 = args.concat( Array.prototype.slice.call(arguments) );//spec states any passed args should be appended to preset arguments. return fn.apply(context,args2); }; });
Last active February 7, 2017 18:16
a helper for angularfire making things easier.
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
 angular .module('myApp') .factory('\$db',['\$firebaseObject','\$firebaseArray','\$q',function(\$firebaseObject,\$firebaseArray,\$q){ function \$db( type, id ){ var ref = firebase.database().ref(type).child(id); var obj = \$firebaseObject(ref); return \$q(function(resolve,reject){ obj.\$loaded().then(function(){ resolve(obj);
Last active January 5, 2017 01:22
ez tiny grid framework. no jquery!

No media queries are used Since tablets and mobiles are now displaying huge resolutions, if we think its mobile, the body gets a class of `.m`, if we think its a tablet, it gets a class of `.t`. if its neither mobile nor tablet,it gets `.d` unless the screen is wider than 1920px, then it gets `.hd`

• Columns must use class `.col`
• Mobile use class `.m-{desired size}` eg `.m-12`
• Tablet use class `.t-{desired size}` eg `.t-6`
• Desktop use class `.d-{desired size}` eg `.d-4`
• Huge Desktop use class `.hd-{desired size}` eg `.hd-2`
• 12 columns (`.col`). extras `.row`, `.container`, `.container.fluid`
• use `.{size}-hide` to hide eg `.m-hide` would hide for mobile.
Created January 27, 2016 07:34
twig year select
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

Created January 22, 2016 07:28
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

Created September 8, 2015 17:58
a simple way to run cronjobs on nginx/hhvm with JIT capabilities.

cron.sh:

```#!/bin/bash

curl http://localhost/related.php &

curl http://localhost/artist_rank.php &

curl http://localhost/sitemap.php &```