Skip to content

Instantly share code, notes, and snippets.

View treyeckels's full-sized avatar

Trey Eckels treyeckels

View GitHub Profile
<p class=MsoNormal style='margin-top:14.0pt;margin-right:0in;margin-bottom:
0in;margin-left:.5in;margin-bottom:.0001pt;text-indent:-.25in;mso-list:l0 level1 lfo1'>
<![if !supportLists]><span
lang=EN style='font-size:13.5pt;line-height:115%;font-family:Roboto;mso-fareast-font-family:
Roboto;mso-bidi-font-family:Roboto;color:#001F3F'><span style='mso-list:Ignore'>●<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><![endif]><span
lang=EN style='font-size:13.5pt;line-height:115%;font-family:Roboto;mso-fareast-font-family:
Roboto;mso-bidi-font-family:Roboto;color:#001F3F'>An intuitive, customizable
user interface.</span>
<span lang=EN>
@treyeckels
treyeckels / nimstones.java
Last active January 16, 2020 23:57
nim stones
import java.util.Scanner;
import java.util.Random;
import java.lang.Math;
public class nimbackup {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int userchoice;
//so this thing is about to introduce itself
@treyeckels
treyeckels / getObject.js
Created July 13, 2018 22:56
JavaScript: Safely lookup an object literal's nested property without getting an NPE if there are undefined keys. Inspired by Python's dictionary get method.
/**
* Retrieves a nested object value without triggering an
* NPE if one of the keys is undefined and if an NPE is encountered will return
* a default value if one is passed in
*
* @param {Object.<*>} obj Object literal trying to crawl
* @param {string} path Path to property you are trying to retrieve
* represented as a string with dot notation
* @param {*=} defaultValue Whatever you want returned if the lookup
* fails
@treyeckels
treyeckels / PubSub.js
Last active November 20, 2015 05:35
Simple Implementation of a Pub/Sub Singleton
/**
* @file A simple Singleton Implementation of the observer pattern to facilitate
* global communication of app events between app modules while maintaining decoupled
* and encapsulated modules
*
* @example
* var ObjectA,
* ObjectB;
*
* ObjectA.pubSub = PubSub.getInstance();
// let's do some event delegation here as we could have hundreds of links and want to mitigate the number of event handlers
// using underscore bind to avoid using "self = this"
$('#formLinksContainer').on('click', '.formLink', _.bind(function(evt) {
evt.preventDefault();
var $link = $(evt.target),
position = $link.data('position'),
$prev = $(".prev"),
$next = $(".next"),
appState = this.getApplicationState(position);
// set disabled attr
getApplicationState: function(position) {
return this.applicationState[position];
}
/**
* We have 3 states for which our page can be in:
* 1. First page of form
* 2. In-Between first and last pages of form
* 3. Last page of form
* Based on these page states, the form previous and next
* buttons become enabled or disabled
*/
applicationState: {
first: {
@treyeckels
treyeckels / button-partial.hbs
Last active August 29, 2015 14:14
Handlebars: Dynamically retrieving data context from data file so that you can include the same partial on all pages
<!-- Provides extra visual weight and identifies the primary action in a set of buttons -->
<button type="button" class="btn btn-primary">{{ buttonText }}</button>