This file contains hidden or 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
// progressive anagram generator | |
// a function that takes in a list of words | |
// and returns a tree structure with an anagram letter at the head of each branch | |
function mapWordsToLetterFrequency (source_words) { | |
return source_words.reduce((accumulator, current_word) => { | |
current_word.letters.forEach(letter => { | |
if (!accumulator[letter]) { | |
accumulator[letter] = 0 |
This file contains hidden or 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
// java style | |
export class PWOService { | |
private selectedStyle; | |
public storeSelectedStyle(style) { | |
this.selectedStyle = style; | |
} | |
public getSelectedStyle() { | |
return this.selectedStyle; |
This file contains hidden or 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 function is highly complex. it has a cyclomatic complexity rating of 7. | |
// it's performance is fine but it's very difficult to read and maintain. | |
// rating generated by this quick tool: http://jshint.com/ | |
function do_something (config) { | |
if (config.prop1) { | |
if (config.prop2) { | |
if (foo === bar) { | |
blah() | |
} | |
} |
This file contains hidden or 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
# first you'll want to use the dig command. this will give you the IP address of the server you've contacted: | |
dig jack.ofspades.com | |
# this should output somewhere around 20 lines depending on your hosting. the important part is in the "answer section": | |
# > ;; ANSWER SECTION: | |
# > jack.ofspades.com. 60 IN A 52.84.14.75 | |
# then run the whois command on the IP address in question: | |
whois 52.84.14.75 |
This file contains hidden or 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
'use strict' | |
/** | |
* JSDoc dictionary that enables `@sideffects` as a tag. | |
*/ | |
exports.defineTags = function (dictionary) { | |
dictionary.defineTag('sideeffects', { | |
onTagged: function (doclet, tag) { | |
doclet.has_sideffects = tag.value || true | |
}, |
This file contains hidden or 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
/** | |
* Demonstration of a stored ajax request in ES6. | |
*/ | |
class ReadingList { | |
// Initialize the instance with an empty variable just so we can null-check it. | |
constructor () { | |
this.article_list = null | |
} | |
// Use a getter for a slightly more concise syntax. |
This file contains hidden or 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 resize_video | |
* @param {string} selector - the selector for the video iframe to resize. | |
* @returns {jQuery object} - the video node | |
* @requires jQuery | |
* @description this function takes a selector for an iframe | |
* and resizes it to have a height that's appropriate for how the video is currently scaled. | |
* This is primarily useful in situations in which you've embedded a video from Youtube | |
* or Vimeo but it's getting black bars around it on some mobile devices because the video | |
* is being scaled down but it still has a fixed height on the iframe. This script assumes |
This file contains hidden or 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
# WARNING: seriously please be careful with this if you don't know what you're doing. | |
# Reverting, resetting, and force-pushing are all actions that can make you lose work. | |
# If you lose that work you will be unhappy and your coworkers will hate you. | |
# You've been warned. | |
# okay, so if you’re on the branch that has the work | |
# (let’s assume master) the flow looks like this: | |
git checkout master | |
# you should already be here but all the same... |
This file contains hidden or 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
window.jQuery(function () { | |
'use strict'; | |
var $parent = $('.gallery-grid-fullwidth'); | |
$('> *', $parent) | |
.sort(function () { | |
return ( Math.round( Math.random() ) - 0.5 ) | |
}) | |
.appendTo($parent); |
This file contains hidden or 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
describe('ProductSwatch Widget', function() { | |
var fixture_markup = '<div>' // replace me with a reference to the above. | |
var product_swatch = null | |
beforeEach(function () { | |
$(document.body).appendChild(fixture_markup) | |
product_swatch = new window.clique.ProductSwatch() | |
}) | |
afterEach(function () { |