text:
(function(w, d) {

'use strict';

/**
 * Library core: constructor, prototype
 * @param {string|object} selector
 * @param {string|object} context - optional
 * @returns {object} Grindstone
 */

	var Grindstone = function(selector, context) {
		var set = this;
		if (selector) {
			var ctx, elems;
			if (typeof selector === 'string') {
				if (context) {
					if (typeof context === 'string') {
						ctx = d.querySelectorAll(context);
					} else if(priv.isElementArray(context)) {
						ctx = context;
					} else {
						ctx = [context];
					}
					Array.prototype.forEach.call(ctx, function(item) {
						elems = item.querySelectorAll(selector);
						Array.prototype.forEach.call(elems, function(el) {
							if (set.indexOf(el) === -1) {
								set.push(el);
							}
						});
					});
				} else {
					set.push.apply(set, d.querySelectorAll(selector));
				}
			} else if (priv.isElementArray(selector)) {
				set.push.apply(set, selector);
			} else {
				set.push(selector);
			}
		}
		this.set = set; // Backwards compatibility.
		return this;
	};

	Grindstone.prototype = [];

	var $ = function(selector, context) {
		return new Grindstone(selector, context);
	};

	$.fn = Grindstone.prototype;

	// private functions
	var priv = {};

	priv.prop = function(obj, property) {
		return obj.hasOwnProperty(property);
	};

	priv.createInteraction = function(touchEvt, mouseEvt) {
		return 'ontouchend' in d ? touchEvt : mouseEvt;
	};

	// This also returns true for Grindstone objects.
	priv.isElementArray = function(obj) {
		return obj instanceof Array
	};

	priv.matchesFuncName = Element.prototype.matches ? 'matches' :
		Element.prototype.matchesSelector ? 'matchesSelector' :
		Element.prototype.webkitMatchesSelector ? 'webkitMatchesSelector' :
		Element.prototype.mozMatchesSelector ? 'mozMatchesSelector' :
		Element.prototype.msMatchesSelector ? 'msMatchesSelector' :
		undefined;

/**
 * Submit a GET or POST AJAX request
 * @param {object} - { properties => values }
 * @returns {object} xmlhttp
 *
 * Acceptable properties of "opts" are:
 * - method (GET or POST)
 * - url (data path)
 * - async (true or false)
 * - success (callback to invoke if successful)
 * - error (callback to invoke if unsuccessful)
 * - header (adds a custom HTTP header to the request)
 * - headerValue (value of the custom HTTP header)
 */

	$.ajax = function(opts) {

		var method, url, async, success, error, header, headerValue, xmlhttp;

		if (typeof opts === 'object') {
			method   = priv.prop(opts, 'method')   ? opts.method   : null;
			url      = priv.prop(opts, 'url')      ? opts.url      : null;
			async    = priv.prop(opts, 'async')    ? opts.async    : true;
			success  = priv.prop(opts, 'success')  ? opts.success  : null;
			error    = priv.prop(opts, 'error')	   ? opts.error	   : function(){};
		} else {
			throw new Error('XHR properties are not properly defined.');
		}

		xmlhttp = new XMLHttpRequest();
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState === 4) {
				if (xmlhttp.status === 200) {
					success(xmlhttp);
				} else {
					error(xmlhttp);
				}
			}
		};
		xmlhttp.open(method, url, async);

		if (priv.prop(opts, 'header') && priv.prop(opts, 'headerValue')) {
			xmlhttp.setRequestHeader(header, headerValue);
		} else {
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
		}

		xmlhttp.send(null);

		return xmlhttp;
	};

/**
 * Append a new child element to the current object
 * @param {string|object} element
 * @returns {object} current instance of Grindstone
 */

	$.fn.append = function(element) {
		this.each(function() {
			if (typeof element === 'string') {
				if (element.match(/(<).+(>)/)) {
					this.innerHTML += element;
				} else {
					var self = this;
					var dom = d.querySelectorAll(element);
					dom = Array.prototype.slice.call(dom);
					dom.forEach(function(item) {
						self.appendChild(item);
					});
				}
			} else {
				this.appendChild(element);
			}
		});
		return this;
	};

/**
 * Set or return the value of the specified attribute
 * @param {string} attribute
 * @param {string} value - optional
 * @returns {object|string} current instance of Grindstone or attribute value
 */

	$.fn.attr = function(attribute, value) {
		var elemAttribute;
		this.each(function() {
			if (value || value === '') {
				this.setAttribute(attribute, value);
			} else {
				elemAttribute = this.getAttribute(attribute);
			}
		});
		return value ? this : elemAttribute;
	};

/**
 * Determine if the current element has the specified attribute
 * @param {string} attribute
 * @returns {boolean} true or false
 */

	$.fn.hasAttr = function(attribute) {
		var exists;
		this.each(function() {
			if (attribute) exists = $(this).attr(attribute) !== null;
		});
		return exists;
	};

/**
 * Remove the the specified attribute
 * @param {string} attribute
 * @returns {object} current instance of Grindstone
 */

	$.fn.removeAttr = function(attribute) {
		this.each(function() {
			if (attribute) this.removeAttribute(attribute);
		});
		return this;
	};

/**
 * Adjust the styles of selected elements or return the requested value
 * @param {object|string} styles - style properties
 * @param {string} value - style value
 * @returns {object|string} current instance of Grindstone or style value
 */

	$.fn.css = function(styles, value) {
		var returnedStyle, returnStyle;
		this.each(function() {
			if (typeof styles === 'object') {
				var self = this;
				var stl = Object.keys(styles);
				stl.forEach(function(key) {
					self.style[key] = styles[key];
				});
			} else if (typeof styles === 'string' && (value === undefined || value === null)) {
				returnedStyle = this.style[styles];
				returnStyle = true;
			} else if (typeof styles === 'string') {
				this.style[styles] = value;
			}
		});
		return returnStyle ? returnedStyle : this;
	};

/**
 * Determine if the elements have the specified class
 * @param {string} cls - className
 * @returns {boolean} true or false
 */

	$.fn.hasClass = function(cls) {
		var hasCls;
		this.each(function() {
			hasCls = this.classList.contains(cls);
		});
		return hasCls;
	};

/**
 * Add a class to the current set of elements
 * @param {string} cls - className
 * @returns {object} current instance of Grindstone
 */

	$.fn.addClass = function(cls) {
		var classes = cls.split(' ');
		this.each(function() {
			var self = this;
			classes.forEach(function(clsName) {
				self.classList.add(clsName);
			});
		});
		return this;
	};

/**
 * Remove a class from the current set of elements
 * @param {string} cls - className
 * @returns {object} current instance of Grindstone
 */

	$.fn.removeClass = function(cls) {
		var classes = cls.split(' ');
		this.each(function() {
			var self = this;
			classes.forEach(function(clsName) {
				self.classList.remove(clsName);
			});
		});
		return this;
	};

/**
 * Toggle the specified class
 * @param {string} cls - className
 * @returns {object} current instance of Grindstone
 */

	$.fn.toggleClass = function(cls) {
		var classes = cls.split(' ');
		this.each(function() {
			var self = this;
			classes.forEach(function(clsName) {
				self.classList.toggle(clsName);
			});
		});
		return this;
	};

/**
 * Clone the elements in the set
 * @returns {object} the cloned elements as a new instance of Grindstone
 */

	$.fn.clone = function() {
		return this.map(function() {
			return this.cloneNode(true);
		});
	};

/**
 * Assign a data-value to a set of elements or return the current value of an element
 * @param {string} valueName - data property
 * @param {string} valueContent - new value, optional
 * @returns {object|number} current instance of Grindstone or the current data-value of an element
 */

	$.fn.data = function(valueName, valueContent) {
		if (valueContent) {
			this.each(function() {
				$(this).attr('data-' + valueName, valueContent);
			});
			return this;
		} else {
			var elemValue;
			this.each(function() {
				elemValue = $(this).attr('data-' + valueName);
			});
			return elemValue;
		}
	};

/**
 * Remove a data-value from a set of elements
 * @param {string} valueName - data property
 * @returns {object} current instance of Grindstone
 */

	$.fn.removeData = function(valueName) {
		this.each(function() {
			$(this).removeAttr('data-' + valueName);
		});
		return this;
	};

/**
 * Debounce a given function
 * @param {function} fn - function to debounce
 * @param {number} wait - wait time in milliseconds
 * @param {boolean} immediate - invoke immediately?
 * @returns {function} invoke debounce
 */

	$.debounce = function(fn, wait, immediate) {
	    var timeout;
	    var debounce = function() {
	        var context = this;
	        var args = arguments;
	        var later = function() {
	            timeout = null;
	            if (!immediate) fn.apply(context, args);
	        };
	        var callNow = immediate && !timeout;
	        clearTimeout(timeout);
	        timeout = setTimeout(later, wait);
	        if (callNow) fn.apply(context, args);
	    };
	    return debounce;
	};

/**
 * Adjust the height of the selected elements or return the current height value of the first element in the set
 * @param {number} num - new height in px, optional
 * @returns {object|number} current instance of Grindstone or current height of the first element
 */

	$.fn.height = function(num) {
		if (typeof num === 'number' || num === 0) {
			this.each(function() {
				this.style.height = num + 'px';
			});
			return this;
		} else {
			var self = this.set[0];
			if (self === d) {
				return d.body.clientHeight;
			} else if (self === w) {
				return w.innerHeight;
			} else {
				return this.set[0].offsetHeight;
			}
		}
	};

/**
 * Adjust the width of the selected elements or return the current width value of the first element in the set
 * @param {number} num - new width in px, optional
 * @returns {object|number} current instance of Grindstone or current width of the first element in the set
 */

	$.fn.width = function(num) {
		if (typeof num === 'number' || num === 0) {
			this.each(function() {
				this.style.width = num + 'px';
			});
			return this;
		} else {
			var self = this.set[0];
			if (self === d) {
				return d.body.clientWidth;
			} else if (self === w) {
				return w.innerWidth;
			} else {
				return this.set[0].offsetWidth;
			}
		}
	};

/**
 * Show a set of hidden elements
 * @param {delay} delay - in milliseconds, optional
 * @returns {object} current instance of Grindstone
 */

	$.fn.show = function(delay) {
		if (delay) {
			var self = this;
			setTimeout(function() {
				$.fn.show.call(self);
			}, delay);
		} else {
			this.each(function() {
				if (this.style.display === 'none') {
					this.style.display = $(this).data('_prevdisplay') || '';
					$(this).removeData('_prevdisplay');
				}
			});
		}
		return this;
	};

/**
 * Hide a set of elements
 * @param {delay} delay - in milliseconds, optional
 * @returns {object} current instance of Grindstone
 */

	$.fn.hide = function(delay) {
		if (delay) {
			var self = this;
			setTimeout(function() {
				$.fn.hide.call(self);
			}, delay);
		} else {
			this.each(function() {
				if (this.style.display !== 'none') {
					if (this.style.display) {
						$(this).data('_prevdisplay', this.style.display);
					}
					this.style.display = 'none';
				}
			});
		}
		return this;
	};

/**
 * Trigger a function by double-tapping or double-clicking
 * @param {function} callback
 * @returns {object} current instance of Grindstone
 */

	$.fn.doubleTap = function(callback) {
		var active, interaction;
		this.each(function() {
			active = false;
			interaction = 'ontouchend' in d ? 'touchend' : 'click';
			$(this).on(interaction, function() {
				if (active) {
					callback();
					return active = false;
				}
				active = true;
				setTimeout(function() {
					return active = false;
				}, 350);
			});
		});
		return this;
	};

/**
 * Iterate through each item in the set and execute the callback
 * @param {function} callback
 * @returns {object} current instance of Grindstone
 */

	$.fn.each = function(callback) {
		var set = this.set;
		set = Array.prototype.slice.call(set);
		set.forEach(function(item) {
			callback.call(item);
		});
		return this;
	};

/**
 * Return the DOM element at the specified index of the current as a new instance of Grindstone
 * @param {number} index
 * @returns {object} new instance of Grindstone specific to one element
 */

	$.fn.eq = function(index) {
		return $(this.set[index]);
	};

/**
 * Assign an event listener
 * @param {string} action - event(s)
 * @param {function} callback
 * @returns {object} current instance of Grindstone
 */

	$.fn.on = function(action, callback) {
		this.each(function() {
			var self = this;
			var events = action.split(' ');
			events.forEach(function(evt) {
				self.addEventListener(evt, callback, false);
			});
		});
		return this;
	};

/**
 * Remove an event listener
 * @param {string} action - event(s)
 * @param {function} callback
 * @returns {object} current instance of Grindstone
 */

	$.fn.off = function(action, callback) {
		this.each(function() {
			var self = this;
			var events = action.split(' ');
			events.forEach(function(evt) {
				self.removeEventListener(evt, callback, false);
			});
		});
		return this;
	};

/**
 * Check if any of the elements match the given selector or callback function
 * @param {string|function} filterBy - selector or callback function, return true to include
 * @returns {boolean} true if at least one of the elements matches the given selector
 */

	$.fn.is = function(filterBy) {
		if (typeof filterBy === 'function') {
            for (var i = 0; i < this.length; i++) {
                if (filterBy.call(this[i], i, this[i])) {
                    return true;
                }
            }
		} else {
            for (var i = 0; i < this.length; i++) {
                if (this[i][priv.matchesFuncName](filterBy)) {
                    return true;
                }
            }
        }
		return false;
	};

/**
 * Map each element to an array of values
 * @param {function} callback - return the value to be included, or null or undefined to skip
 * @returns {object} Grindstone object of included values returned from the callback
 */

	$.fn.map = function(callback) {
        var newSet = $();
        for (var i = 0; i < this.length; i++) {
            var ret = callback.call(this[i]);
            if (ret !== undefined && ret !== null) {
                newSet.push(ret);
            }
        }
        return newSet;
	};

/**
 * Filter the elements by the selector or callback function
 * @param {string|function} filterBy - selector or callback function, return true to include
 * @returns {object} new instance of Grindstone with the reduced set of matching elements
 */

	$.fn.filter = function(filterBy) {
        return $.fn.map.call(this, function() {
            if ($(this).is(filterBy)) {
                return this;
            }
        });
	};

/**
 * Excludes matching elements and includes not matching elements.
 * @param {string|function} filterBy - selector or callback function, return true to include
 * @returns {boolean} new instance of Grindstone with the reduced set of not matching elements
 */

	$.fn.not = function(filterBy) {
        return $.fn.map.call(this, function() {
            if (!$(this).is(filterBy)) {
                return this;
            }
        });
	};

/**
 * Get the first element
 * @returns {object} new instance of Grindstone with the first element
 */

    $.fn.first = function() {
        return $(this.set[0]);
    }

/**
 * Get the last element
 * @returns {object} new instance of Grindstone with the last element
 */

    $.fn.last = function() {
        return $(this.set[this.set.length - 1]);
    }

/**
 * Focus on the first element in the set or trigger a callback when some element is focused on
 * @param {function} callback - optional
 * @returns {object} current instance of Grindstone
 */

	$.fn.focus = function(callback) {
		if (typeof callback === 'function') {
			this.each(function() {
				$(this).on('focus', callback);
			});
		} else {
			this.set[0].focus();
		}
		return this;
	};

/**
 * Return the DOM element at the specified index of the current set
 * @param {number} index
 * @returns {object} the DOM element
 */

	$.fn.get = function(index) {
		return this.set[index];
	};

/**
 * Replace an element's inner HTML or return the current value
 * @param {string} content - optional
 * @returns {object|string} current instance of Grindstone or current value of an element's inner HTML
 */

	$.fn.html = function(content) {
		var text;
		this.each(function() {
			if (content || content === '') {
				this.innerHTML = content;
			} else {
				text = this.innerHTML;
			}
		});
		return content ? this : text;
	};

/**
 * Insert new content before a target element
 * @param {string|object} content
 * @returns {object} current instance of Grindstone
 */

	$.fn.before = function(content) {
		this.each(function() {
			if (typeof content === 'string') {
				if (content.match(/(<).+(>)/)) {
					this.insertAdjacentHTML('beforebegin', content);
				} else {
					var self = this;
					var dom = d.querySelectorAll(content);
					dom = Array.prototype.slice.call(dom);
					dom.forEach(function(item) {
						self.parentNode.insertBefore(item, self);
					});
				}
			} else {
				this.parentNode.insertBefore(content, this);
			}
		});
		return this;
	};

/**
 * Insert new content after a target element
 * @param {string|object} content
 * @returns {object} current instance of Grindstone
 */

	$.fn.after = function(content) {
		this.each(function() {
			if (typeof content === 'string') {
				if (content.match(/(<).+(>)/)) {
					this.insertAdjacentHTML('afterend', content);
				} else {
					var self = this;
					var dom = d.querySelectorAll(content);
					dom = Array.prototype.slice.call(dom);
					dom.forEach(function(item) {
						self.parentNode.insertBefore(item, self.nextSibling);
					});
				}
			} else {
				this.parentNode.insertBefore(content, this.nextSibling);
			}
		});
		return this;
	};

/**
 * Create hover and active states
 * @param {object} classes - hoverClass => value, activeClass => value, optional
 * @returns {object} current instance of Grindstone
 */

	$.fn.mouseable = function(classes) {

		var hoverClass, activeClass;

		if (classes) {
			if (typeof classes === 'object') {
				hoverClass  = priv.prop(classes, 'hoverClass')  ? classes['hoverClass']  : 'over';
				activeClass = priv.prop(classes, 'activeClass') ? classes['activeClass'] : 'down';
			} else {
				throw new Error('Classes parameter for mouseable() must be an object with properties "hoverClass" and/or "activeClass".');
			}
		} else {
			hoverClass  = 'over';
			activeClass = 'down';
		}

		var events = {
			hover:  priv.createInteraction('touchstart', 'mouseenter'),
			remove: priv.createInteraction('touchend', 'mouseleave'),
			down:   priv.createInteraction('touchstart', 'mousedown'),
			up: 	priv.createInteraction('touchend', 'mouseup mouseleave')
		};

		this.each(function() {

			$(this)
				.on(events.hover, function() {
					$(this).addClass(hoverClass);
				})
				.on(events.remove, function() {
					$(this).removeClass(hoverClass)
				})
				.on(events.down, function() {
					$(this).addClass(activeClass);
				})
				.on(events.up, function() {
					$(this).removeClass(activeClass);
				});
		});

		return this;
	};

/**
 * Return the left or top value of the selector, relative to the document
 * @param {string} position - "left" or "top"
 * @returns {number} offset value in px
 */

	$.fn.offset = function(position) {
		if (position && typeof position === 'string') {
			if (position !== 'left' && position !== 'top') {
				throw new Error('offset() position must be either "left" or "top".');
			} else {
				var elem = this.set[0];
				if (position === 'left') {
					var offsetLeft = 0;
				    do {
				        if (!isNaN(elem.offsetLeft)) offsetLeft += elem.offsetLeft;
				    } while (elem = elem.offsetParent);
				    return offsetLeft;
				} else if (position === 'top') {
					var offsetTop = 0;
				    do {
				        if (!isNaN(elem.offsetTop)) offsetTop += elem.offsetTop;
				    } while (elem = elem.offsetParent);
				    return offsetTop;
				}
			}
		} else {
			throw new Error('offset() position must be a string: acceptable values are "left" and "top".');
		}
	};

/**
 * Prepend a new element or new content
 * @param {object|string} element
 * @returns {object} current instance of Grindstone
 */

	$.fn.prepend = function(element) {
		this.each(function() {
			if (typeof element === 'string') {
				if (element.match(/(<).+(>)/)) {
					this.insertAdjacentHTML('afterbegin', element);
				} else {
					var self = this;
					var dom = d.querySelectorAll(element);
					dom = Array.prototype.slice.call(dom);
					dom.forEach(function(item) {
						self.insertBefore(item, self.firstChild);
					});
				}
			} else {
				this.insertBefore(element, this.firstChild);
			}
		});
		return this;
	};

/**
 * Trigger a function when the DOM content is loaded
 * @param {function} callback
 * @returns {object} current instance of Grindstone
 */

	$.fn.ready = function(callback) {
		if (typeof callback === 'function') {
			this.each(function() {
				$(this).on('DOMContentLoaded', callback);
			});
		}
		return this;
	};

/**
 * Trigger a function on the load event
 * @param {function} callback
 * @returns {object} current instance of Grindstone
 */

	$.fn.load = function(callback) {
		if (typeof callback === 'function') {
			this.each(function() {
				$(this).on('load', callback);
			});
		}
		return this;
	};

/**
 * Remove elements from the DOM
 * @param {object} target - target element(s), optional: if omitted, the element(s) invoking this method will be removed
 * @returns {object} current instance of Grindstone
 */

	$.fn.remove = function(target) {
		if (target) {
			var elems = d.querySelectorAll(target);
			elems = Array.prototype.slice.call(elems);
			this.each(function() {
				var self = this;
				elems.forEach(function(el) {
					self.removeChild(el);
				});
			});
		} else {
			this.each(function() {
				this.parentNode.removeChild(this);
			});
		}
		return this;
	};

/**
 * Replace an element with some other content
 * @param {object|string} content
 * @returns {object} current instance of Grindstone
 */

	$.fn.replaceWith = function(content) {
		this.each(function() {
			this.outerHTML = content ? content : "";
		});
		return this;
	};

/**
 * Capture the resize event from a set of elements and execute a function
 * @param {function} callback
 * @returns {object} current instance of Grindstone
 */

	$.fn.resize = function(callback) {
		if (typeof callback === 'function') {
			this.each(function() {
				$(this).on('resize', callback);
			});
		}
		return this;
	};

/**
 * Capture the scroll event and execute a function
 * @param {function} callback
 * @returns {object} current instance of Grindstone
 */

	$.fn.scroll = function(callback) {
		if (typeof callback === 'function') {
			this.each(function() {
				$(this).on('scroll', callback);
			});
		}
		return this;
	};

 /**
 * Scroll an element to a specific top position relative to its another parent container
 * Return the current top offset of an element, relative to its parent container
 * @param {number} top - offset in px, optional
 * @returns {object|number} current instance of Grindstone or top offset
 */

	$.fn.scrollTop = function(top) {
		var topOffset;
		this.each(function() {
			switch (this) {
				case w:
					if (typeof top === 'number') {
						this.scrollTo(0, top);
					} else {
						topOffset = this.pageYOffset;
					}
					break;
				case d:
					if (typeof top === 'number') {
						this.body.scrollTop = top;
					} else {
						topOffset = this.body.scrollTop;
					}
					break;
				default:
					if (typeof top === 'number') {
						this.scrollTop = top;
					} else {
						topOffset = this.scrollTop;
					}
			}
		});
		return typeof top === 'number' ? this : topOffset;
	};

/**
 * Scroll an element to a specific left position relative to its another parent container
 * Return the current left offset of an element, relative to its parent container
 * @param {number} left - offset in px, optional
 * @returns {object|number} current instance of Grindstone or left offset
 */

	$.fn.scrollLeft = function(left) {
		var leftOffset;
		this.each(function() {
			switch (this) {
				case w:
					if (typeof left === 'number') {
						this.scrollTo(left, 0);
					} else {
						leftOffset = this.pageXOffset;
					}
					break;
				case d:
					if (typeof left === 'number') {
						this.body.scrollLeft = left;
					} else {
						leftOffset = this.body.scrollLeft;
					}
					break;
				default:
					if (typeof left === 'number') {
						this.scrollTop = left;
					} else {
						leftOffset = this.scrollLeft;
					}
			}
		});
		return (typeof left === 'number') ? this : leftOffset;
	};

/**
 * Submit a form or trigger a function when a form is submitted
 * @param {function} callback - optional
 * @returns {object} current instance of Grindstone
 */

	$.fn.submit = function(callback) {
		if (typeof callback === 'function') {
			this.each(function() {
				$(this).on('submit', callback);
			});
		} else {
			this.each(function() {
				this.submit();
			});
		}
		return this;
	};

    priv.elementProp = function(set, propName, selector) {
        return $.fn.map.call(set, function() {
            var find = this;
            while (true) {
                var element = find[propName];
                if (!element) {
                    break;
                }
                if (element.nodeType != 1) {
                    find = element;
                    continue;
                }
                if (!selector || $(element).is(selector)) {
                    return element;
                }
                break;
            }
        });
    };

/**
 * Get the parent element as a Grindstone object
 * @param {string} selector - only get the parent if it matches the selector, optional
 * @returns {object} parents instance of Grindstone
 */

	$.fn.parent = function(selector) {
        return priv.elementProp(this, 'parentNode', selector);
	};

/**
 * Get the next element as a Grindstone object
 * @param {string} selector - only get the element if it matches the selector, optional
 * @returns {object} instance of Grindstone
 */

	$.fn.next = function(selector) {
        return priv.elementProp(this, 'nextSibling', selector);
	};

/**
 * Get the previous element as a Grindstone object
 * @param {string} selector - only get the element if it matches the selector, optional
 * @returns {object} instance of Grindstone
 */

	$.fn.prev = function(selector) {
        return priv.elementProp(this, 'previousSibling', selector);
	};

    priv.children = function(set, nodeType, selector) {
        var newSet = $();
        for (var i = 0; i < set.length; i++) {
            for (var child = set[i].firstChild; child; child = child.nextSibling) {
                if (nodeType === undefined || nodeType === child.nodeType) {
                    if (!selector || $(child).is(selector)) {
                        newSet.push(child);
                    }
                }
            }
        }
        return newSet;
    };

/**
 * Get the children elements as a Grindstone object
 * @param {string} selector - only get the element if it matches the selector, optional
 * @returns {object} children instance of Grindstone
 */

	$.fn.children = function(selector) {
        return priv.children(this, 1, selector);
	};

/**
 * Get all the children as a Grindstone object, including text and comments.
 * @returns {object} children instance of Grindstone
 */

	$.fn.contents = function() {
        return priv.children(this);
	};

/**
 * Dispatch a custom event
 * @param {number} evt - custom event
 * @returns {object|number} current instance of Grindstone or top offset
 */

	$.fn.trigger = function(evt) {
		var customEvent = new Event(evt);
		this.each(function() {
			this.dispatchEvent(customEvent);
		});
		return this;
	};

/**
 * Return or assign the value of an element
 * @param {string} newValue - optional
 * @returns {object|string} current instance of Grindstone or the value of the first element in the set
 */

	$.fn.val = function(newValue) {
		if (typeof newValue === 'string') {
			this.each(function() {
				this.value = newValue;
			});
			return this;
		} else {
			return this.set[0].value;
		}
	};

/**
 * Wrap the outer structure of the set of elements
 * @param {string} structure - HTML structure, opening tags only
 * @returns {object} current instance of Grindstone
 */

	$.fn.wrap = function(structure) {
		this.each(function() {
			if (typeof structure === 'string') {
				var contents = this.outerHTML;
				var wrap = structure;
				this.outerHTML = wrap + contents;
			} else {
				throw new Error('wrap() structure must be a string.');
			}
		});
		return this;
	};

/**
 * Wrap the inner structure of the set of elements
 * @param {string} structure - HTML structure, opening tags only
 * @returns {object} current instance of Grindstone
 */

	$.fn.wrapInner = function(structure) {
		this.each(function() {
			if (typeof structure === 'string') {
				var contents = $(this).html();
				var wrap = structure;
				$(this).html(wrap + contents);
			} else {
				throw new Error('wrapInner() structure must be a string.');
			}
		});
		return this;
	};

	return w.Grindstone = w.$ = $;

})(window, document);


text:
Imports System
Namespace Test
    Public Class VBTestClass
        Public Function OptionalRefParam(Optional ByRef param2 As String = "superduper") As String
            param2 = param2 + " edited"
            Return param2
        End Function

        Public Function OptionalNullableRefParam(Optional ByRef param2 As System.Nullable(Of Int32) = 30) As Nullable(Of Int32)
            If param2.HasValue Then
                param2 = param2 + 100
                Return param2
            Else
                param2 = 55
                Return param2
            End If
        End Function
    End Class
End Namespace

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE html>

	<title>Object constructor</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
	<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlxtree.css"/>

Initialize object on page


text:
namespace DemoCore
{
    using System;
    using System.Collections.Generic;

    using HelixToolkit.Wpf.SharpDX;

    /// <summary>
    /// Base ViewModel for Demo Applications?
    /// </summary>
    public abstract class BaseViewModel : ObservableObject
    {
        public const string Orthographic = "Orthographic Camera";

        public const string Perspective = "Perspective Camera";

        private string cameraModel;

        private Camera camera;

        private RenderTechnique renderTechnique;

        private string subTitle;

        private string title;

        public string Title
        {
            get
            {
                return this.title;
            }
            set
            {
                this.SetValue(ref title, value, "Title");
            }
        }

        public string SubTitle
        {
            get
            {
                return this.subTitle;
            }
            set
            {
                this.SetValue(ref subTitle, value, "SubTitle");
            }
        }

        public RenderTechnique RenderTechnique
        {
            get
            {
                return this.renderTechnique;
            }
            set
            {
                this.SetValue(ref renderTechnique, value, "RenderTechnique");
            }
        }

        public List<string> ShadingModelCollection { get; private set; }

        public List<string> CameraModelCollection { get; private set; }

        public string CameraModel
        {
            get
            {
                return this.cameraModel;
            }
            set
            {
                if (this.SetValue(ref cameraModel, value, "CameraModel"))
                {
                    OnCameraModelChanged();
                }
            }
        }

        public Camera Camera
        {
            get
            {
                return this.camera;
            }

            protected set
            {
                this.SetValue(ref this.camera, value, "Camera");
                this.CameraModel = value is PerspectiveCamera
                                       ? Perspective
                                       : value is OrthographicCamera ? Orthographic : null;
            }
        }

        protected OrthographicCamera defaultOrthographicCamera = new OrthographicCamera { Position = new System.Windows.Media.Media3D.Point3D(0, 0, 5), LookDirection = new System.Windows.Media.Media3D.Vector3D(-0, -0, -5), UpDirection = new System.Windows.Media.Media3D.Vector3D(0, 1, 0), NearPlaneDistance = 1, FarPlaneDistance = 100 };

        protected PerspectiveCamera defaultPerspectiveCamera = new PerspectiveCamera { Position = new System.Windows.Media.Media3D.Point3D(0, 0, 5), LookDirection = new System.Windows.Media.Media3D.Vector3D(-0, -0, -5), UpDirection = new System.Windows.Media.Media3D.Vector3D(0, 1, 0), NearPlaneDistance = 0.5, FarPlaneDistance = 150 };

        public event EventHandler CameraModelChanged;

        protected BaseViewModel()
        {
            // camera models
            CameraModelCollection = new List<string>()
            {
                Orthographic,
                Perspective,
            };

            // on camera changed callback
            this.CameraModelChanged += (s, e) =>
            {
                if (this.cameraModel == Orthographic)
                {
                    //if (this.Camera != null)
                    //{
                    //    var newCamera = new OrthographicCamera();
                    //    this.Camera.CopyTo(newCamera);
                    //    newCamera.NearPlaneDistance = znear;
                    //    newCamera.FarPlaneDistance = zfar;
                    //    this.Camera = newCamera;

                    //}
                    //else
                    {
                        this.Camera = this.defaultOrthographicCamera;
                    }
                }
                else if (this.cameraModel == Perspective)
                {
                    //if (this.Camera != null)
                    //{
                    //    var newCamera = new PerspectiveCamera();
                    //    this.Camera.CopyTo(newCamera);
                    //    newCamera.NearPlaneDistance = znear;
                    //    newCamera.FarPlaneDistance = zfar;
                    //    this.Camera = newCamera;
                    //}
                    //else
                    {
                        this.Camera = this.defaultPerspectiveCamera;
                    }
                }
                else
                {
                    throw new HelixToolkitException("Camera Model Error.");
                }
            };

            // default camera model
            this.CameraModel = Perspective;

            this.Title = "Demo (HelixToolkitDX)";
            this.SubTitle = "Default Base View Model";
            this.RenderTechnique = Techniques.RenderPhong;
        }

        protected virtual void OnCameraModelChanged()
        {
            var eh = this.CameraModelChanged;
            if (eh != null)
            {
                eh(this, new EventArgs());
            }
        }
    }
}


text:
import json

from raven.contrib.flask import Sentry

from flask.ext import restful
from flask.ext.cors import CORS
from flask import Flask, make_response, jsonify, request

from pastry.db import mongo
from pastry.encoder import APIEncoder
from pastry.routes import register_routes

def register_errors(app):
    @app.errorhandler(404)
    def page_not_found(path):
        return jsonify({
            'message': 'URL not found: {}'.format(request.path)
        }), 404
    return app

def json_renderer(data, code, headers=None):
    dumped = json.dumps(data, cls=APIEncoder)
    resp = make_response(dumped, code)
    resp.headers.extend(headers or {})
    return resp

def create_app(config):
    app = Flask(__name__)
    app = register_errors(app)
    CORS(app, allow_headers=['Content-Type', 'Auth-Token'])
    app.config.from_object(config)
    if 'SENTRY_DSN' in app.config:
        Sentry(app)
    mongo.init_app(app)

    api = restful.Api(app)
    api.representations.update({
        'application/json': json_renderer
    })
    register_routes(api)
    return app


text:
package edu.utk.phys.fern;
// --------------------------------------------------------------------------------------------------------------
//  Class ShowIsotopeValues to pop up window to display current value of
//  the variable being displayed
// --------------------------------------------------------------------------------------------------------------

import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

class ShowIsotopeValues extends JFrame  {

    Font titleFont = new java.awt.Font("SanSerif", Font.BOLD, 12);
    FontMetrics titleFontMetrics = getFontMetrics(titleFont);
    Font buttonFont = new java.awt.Font("SanSerif", Font.BOLD, 10);
    FontMetrics buttonFontMetrics = getFontMetrics(buttonFont);
    Font textFont = new java.awt.Font("SanSerif", Font.PLAIN, 12);
    FontMetrics textFontMetrics = getFontMetrics(textFont);

    Color panelForeColor = Color.black;
    Color panelBackColor = new Color(230,230,230);
    Color disablebgColor = new Color(220,220,220);
    Color disablefgColor = new Color(180,180,180);
    Color textfieldColor = new Color(255,255,255);

    JPanel panel0, panel1;
    JPanel cboxPanel;
    JTextField variable,Y;
    JLabel variableL, YL;

    int ZZ, NN;

    // ---------------------------------------------------------------------
    //  Public constructor
    // ---------------------------------------------------------------------

    public ShowIsotopeValues (int width, int height, String title, String text, int t, double [][][] twa){

		// Bug fix, see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7027598
		// and http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=83582
		variable.setDropTarget(null);
		Y.setDropTarget(null);

        ZZ = IsotopePad.protonNumber;
        NN = IsotopePad.neutronNumber;
        String symbol = Cvert.returnSymbol(ZZ);
        //String arg = "("+ZZ+","+NN+")";
        String nn = (" " +(ZZ+NN)+"-"+symbol);
        nn+= " (t="+Cvert.gg.decimalPlace(5,StochasticElements.timeNow[t])+" s)";

        this.pack();
        this.setSize(width,height);
        this.setTitle(title);

        // Define a GridBagConstraint object for GridBagLayout
        // manager used below.

        GridBagConstraints gs = new GridBagConstraints();
        gs.weightx = 100;
        gs.weighty = 100;
        gs.gridx = 0;
        gs.gridy = 0;
        gs.ipadx = 0;
        gs.ipady = 0;
        gs.gridwidth = 1;
        gs.gridheight = 1;
        gs.fill = GridBagConstraints.NONE;
        gs.anchor = GridBagConstraints.NORTH;
        gs.insets = new Insets(10,10,10,10);

        // Main container (all but bottom button panel)

        cboxPanel = new JPanel();
        cboxPanel.setLayout(new GridBagLayout());

        // Top label

        JLabel reacLabel = new JLabel(nn,JLabel.CENTER);
        reacLabel.setFont(titleFont);
        gs.gridwidth = 1;
        cboxPanel.add(reacLabel,gs);

        // Mass fraction widgets on panel0

        gs.anchor = GridBagConstraints.CENTER;
        gs.gridy = GridBagConstraints.RELATIVE;

        panel0 = new JPanel();

        variableL = new JLabel(text, JLabel.LEFT);
        variableL.setFont(textFont);
        panel0.add(variableL);

        variable = new JTextField(9);
        variable.setFont(textFont);
        variable.setEditable(false);
        panel0.add(variable);

        cboxPanel.add(panel0,gs);

        // Add the container for the value of the variable to the frame

        this.add(cboxPanel,"Center");

        // Put stuff on the bottom panel botPanel and add to frame

        JPanel botPanel = new JPanel();
        botPanel.setBackground(MyColors.gray204);

        JButton dismissButton = new JButton("Cancel");
        dismissButton.setFont(buttonFont);
        botPanel.add(dismissButton);

        this.add("South", botPanel);

        // Read any values already set and place in fields

        String temp;
        if(twa[ZZ][NN][t] != 0) {
            temp = Cvert.gg.decimalPlace(7, twa[ZZ][NN][t]);
        } else {temp = "";}
        variable.setText(temp);

        // Add inner class event handler for Dismiss button

        dismissButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae){
            hide();
            dispose();
            }
        });

        // Add window closer (inner class)

        this.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                hide();
                dispose();
            }
        });

    }  // End constructor method

}   /* End class ShowIsotopeValues */


text:
package org.akomantoso;

import java.io.File;
import java.io.IOException;
import junit.framework.TestCase;
import org.akomantoso.api.AnValidator;
import org.akomantoso.api.AnValidatorError;
import org.akomantoso.api.AnVersion;

/**
 * Test the validation of Akoma Ntoso documents, returns line number
   and column number when validation fails
 * @author Ashok Hariharan
 */
public class TestAnValidatorTest_CSD06 extends TestCase {

    AnVersion _version = new AnVersion(3, "CSD06");
    // test file 1 - this should validte
    File _validate1  = new File("./src/test/java/testdocs/akomantoso_doc_csd06.xml");
    // test file 2 - this should fail
    File _validate2  = new File("./src/test/java/testdocs/akomantoso_act_csd06.xml");

    AnValidator _validator = new AnValidator();

    public TestAnValidatorTest_CSD06(String testName) throws IOException {
        super(testName);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
    }

    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
    }

    /**
     * Test of validate method, of class AnValidator.
     */
    public void testValidate() throws Exception {
        System.out.println("validate");
        // file 1 should validate
        AnValidatorError result = _validator.validate(_version, _validate1);
        assertEquals("Validation of file failed when it should have succeeded",
                result.isError(), false);
        // file 2 should fail, but failure should match specific line and col number
        result = _validator.validate(_version, _validate2);
        assertEquals("Validation of file succeeded when it should have failed",
                result.isError(), true);
        System.out.println("error details : ");
        System.out.println(" line : " + result.getLineNumber() + ", "
                + "col : " + result.getColumnNumber());
        assertEquals("line number should be 209 !", result.getLineNumber(), (Integer)17);
        assertEquals("col number should be 131 !", result.getColumnNumber(), (Integer)99);
    }
}


text: <!DOCTYPE html>


text:
import os.path
from docutils import nodes
import sys
import re

__Reference_re = re.compile('\s*(.*)\s+<(.*)>\s*$', re.MULTILINE + re.DOTALL)

def api_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
    """
    Role `:api:` bridges generated API documentation by tool like EpyDoc
    with Sphinx Python Documentation Generator.

    Other tools, other than EpyDoc, can be easily supported as well.

    First generate the documentation to be referenced, i.e. with EpyDoc::

        $ mkdir -p doc/html/api
        $ epydoc -o doc/html/api ...

    Next step is to generate documentation with Sphinx::

        $ sphinx-build doc doc/html

    """
    basedir = 'api'
    prefix = 'html/' # fixme: fetch it from configuration
    exists = lambda f: os.path.exists(prefix + f)

    # assume module is references

    #print 'Text "%s"' % (text,)
    mo = __Reference_re.match(text)
    label = None
    if mo is not None:
        ( label, text ) = mo.group(1, 2)
    name = text.strip()

    uri = file = '%s/%s-module.html' % (basedir, text)
    chunks = text.split('.')

    #print 'Trying module file %s' % (file,)

    # if not module, then a class
    if not exists(file):
        name = text.split('.')[-1]
        uri = file = '%s/%s-class.html' % (basedir, text)
    #print 'Trying class file %s' % (file,)

    # if not a class, then function or class method
    if not exists(file):
        method = chunks[-1]
        fprefix = '.'.join(chunks[:-1])
        # assume function is referenced
        file = '%s/%s-module.html' % (basedir, fprefix)
        #print 'Trying method file %s' % (file,)
        if exists(file):
            uri = '%s#%s' % (file, method)
        else:
            # class method is references
            file = '%s/%s-class.html' % (basedir, fprefix)
            if exists(file):
                name = '.'.join(chunks[-2:]) # name should be Class.method
                uri = '%s/%s-class.html#%s' % (basedir, fprefix, method)

    if label is None:
        label = name
    if exists(file):
        node = nodes.reference(rawtext, label, refuri=uri, **options)
    else:
        # cannot find reference, then just inline the text
        print 'WARNING: Unable to find %s in API' % (text,)
        node = nodes.literal(rawtext, text)

    return [node], []

def ticket_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
    """
    Role `:ticket:` generates references to Trac tickets.
    """
    trac_root = 'https://sourceforge.net/apps/trac/pyxb_114'

    # assume module is references

    #print 'Text "%s"' % (text,)
    mo = __Reference_re.match(text)
    label = None
    if mo is not None:
        ( label, text ) = mo.group(1, 2)
    ticket = text.strip()

    uri = '%s/ticket/%s' % (trac_root, ticket)
    if label is None:
        label = '#%s' % (ticket,)
    node = nodes.reference(rawtext, label, refuri=uri, **options)

    return [node], []

def pyex_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
    """
    Role `:pyex:` generates reference to Python exception classes.
    """

    pyex_fmt = 'http://docs.python.org/library/exceptions.html#exceptions.%s'
    mo = __Reference_re.match(text)
    label = None
    if mo is not None:
        ( label, text ) = mo.group(1, 2)
    exc = text.strip()
    print 'Python exception %s as %s' % (text, label)

    uri = pyex_fmt % (exc,)
    if label is None:
        label = '%s' % (exc,)
    node = nodes.reference(rawtext, label, refuri=uri, **options)

    return [node], []

def setup(app):
    app.add_role('api', api_role)
    app.add_config_value('epydoc_basedir', 'api', False)
    app.add_config_value('epydoc_prefix', 'doc/html/', False)
    app.add_role('ticket', ticket_role)
    app.add_config_value('epydoc_track_root', 'http://sourceforge.net/apps/track/project', False)
    app.add_role('pyex', pyex_role)


text:
/*global describe, before, it */
'use strict';
var assert = require('yeoman-generator').assert
  , helpers = require('yeoman-generator').test
  , path = require('path');

describe('Module generator', function () {

  // generate default app
  // appName different than directory for code coverage
  // stub installDependencies for code coverage
  before(function (done) {
    helpers
      .run(path.join(__dirname, '../app'))
      .withPrompts({
        appName: 'temp-module',
        markup: 'html',
        appScript: 'js',
        controllerAs: false,
        passFunc: true,
        namedFunc: true,
        testScript: 'js',
        testDir: 'app',
        style: 'less',
        bower: []
      })
      .withGenerators([
        path.join(__dirname, '../module'),
        path.join(__dirname, '../route'),
        path.join(__dirname, '../controller'),
        path.join(__dirname, '../view')
      ])
      .on('end', done);
  });

  describe('adding a new empty module', function () {
    before(function (done) {
      helpers
        .run(path.join(__dirname, '../module'), {
          tmpdir: false
        })
        .withArguments(['testGroup'])
        .withOptions({
          empty: true
        })
        .withGenerators([
          path.join(__dirname, '../route'),
          path.join(__dirname, '../controller'),
          path.join(__dirname, '../view')
        ])
        .on('end', done);
    });

    it('should not create a controller and view', function () {
      assert.noFile([
        'app/test-group/test-group-controller.js',
        'app/test-group/test-group-controller_test.js',
        'app/test-group/test-group.tpl.html',
        'e2e/test-group/test-group.po.js',
        'e2e/test-group/test-group_test.js'
      ]);
    });
  });

  // trailing slash to test trailing slash removal
  describe('adding a new module', function () {
    before(function (done) {
      helpers
        .run(path.join(__dirname, '../module'), {
          tmpdir: false
        })
        .withArguments(['test/'])
        .withGenerators([
          path.join(__dirname, '../route'),
          path.join(__dirname, '../controller'),
          path.join(__dirname, '../view')
        ])
        .on('end', done);
    });

    it('should add test files', function () {
      assert.file([
        'app/test/test.js',
        'app/test/test.less',
        'app/test/test.tpl.html',
        'app/test/test-controller.js',
        'app/test/test-controller_test.js'
      ]);
    });

    it('should add comma to ui.router in app/app.js', function () {
      assert.fileContent('app/app.js', /    \'ui.router\',/);
    });

    it('should add test to app/app.js deps', function () {
      assert.fileContent('app/app.js', /    \'test\'/);
    });
  });

  describe('adding a deep level camelCase module', function () {
    before(function (done) {
      helpers
        .run(path.join(__dirname, '../module'), {
          tmpdir: false
        })
        .withArguments(['home/myDoor'])
        .withOptions({
          'app-script': 'coffee'
        })
        .withGenerators([
          path.join(__dirname, '../route'),
          path.join(__dirname, '../controller'),
          path.join(__dirname, '../view')
        ])
        .on('end', done);
    });

    describe('adding a deeper level module', function () {
      before(function (done) {
        helpers
          .run(path.join(__dirname, '../module'), {
            tmpdir: false
          })
          .withArguments(['home/myDoor/handle'])
          .withGenerators([
            path.join(__dirname, '../route'),
            path.join(__dirname, '../controller'),
            path.join(__dirname, '../view')
          ])
          .on('end', done);
      });

      it('should add door.handle to app/home/my-door.coffee', function () {
        assert.fileContent('app/home/my-door/my-door.coffee', /    \'myDoor.handle\'/);
      });

      it('should name module in app/home/my-door/my-door.coffee home.myDoor', function () {
        assert.fileContent('app/home/my-door/my-door.coffee', /angular[^$]*.module[^$]*\'home.myDoor\'/);
      });
    });

    it('should add comma to ui.router in app/home/home.js deps', function () {
      assert.fileContent('app/home/home.js', /    \'ui.router\',/);
    });

    it('should add home.door to app/home/home.js deps', function () {
      assert.fileContent('app/home/home.js', /    \'home.myDoor\'/);
    });
  });

  describe('adding a deep level hyphenated module', function () {
    before(function (done) {
      helpers
      .run(path.join(__dirname, '../module'), {
        tmpdir: false
      })
      .withArguments(['home/my-module'])
      .withGenerators([
        path.join(__dirname, '../route'),
        path.join(__dirname, '../controller'),
        path.join(__dirname, '../view')
      ])
      .on('end', done);
    });

    it('should create home.myModule in app/home/my-module/my-module.js', function () {
      assert.fileContent('app/home/my-module/my-module.js', /angular[^$]*.module[^$]*\'home.myModule\'/);
    });

    it('should add home.myModule in app/home/home.js', function () {
      assert.fileContent('app/home/home.js', /    \'home.myModule\'/);
    });

    it('should add myModule state to app/home/my-module/my-modules.js', function () {
      assert.fileContent('app/home/my-module/my-module.js', /[.]state\(\'myModule\', /);
    });

  });

  describe('adding a deep level Typescript module', function () {
    before(function (done) {
      helpers
        .run(path.join(__dirname, '../module'), {
          tmpdir: false
        })
        .withArguments(['home/myHouse'])
        .withOptions({
          'app-script': 'ts'
        })
        .withGenerators([
          path.join(__dirname, '../route'),
          path.join(__dirname, '../controller'),
          path.join(__dirname, '../view')
        ])
        .on('end', done);
    });

    it('should add comma to ui.router in app/home/home.js deps', function () {
      assert.fileContent('app/home/home.js', /    \'ui.router\',/);
    });

    it('should add home.myHouse to app/home/home.js deps', function () {
      assert.fileContent('app/home/home.js', /    \'home.myHouse\'/);
    });

    describe('adding a deeper level module', function () {
      before(function (done) {
        helpers
        .run(path.join(__dirname, '../module'), {
          tmpdir: false
        })
        .withArguments(['home/myHouse/handle'])
        .withOptions({
          'app-script': 'ts'
        })
        .withGenerators([
          path.join(__dirname, '../route'),
          path.join(__dirname, '../controller'),
          path.join(__dirname, '../view')
        ])
          .on('end', done);
      });

      it('should add myHouse.handle to app/home/my-house.ts', function () {
        assert.fileContent('app/home/my-house/my-house.ts', /    \'myHouse.handle\'/);
      });

      it('should name module in app/home/my-house/my-house.ts home.myHouse', function () {
        assert.fileContent('app/home/my-house/my-house.ts', /angular[^$]*.module[^$]*\'home.myHouse\'/);
      });

    });

  });

});


text:
package main

import (
	"bufio"
	"errors"
	"fmt"
	"os"
	"strings"
	"time"

	"github.com/urfave/cli"
)

func main() {
	app := cli.NewApp()
	app.Name = "rubusy"
	app.Usage = "cron job schedule searcher"
	app.UsageText = "rubusy [-l line] [-fr from] [-p] [--line value] [--from value] [--plain] [file]"
	app.Version = "0.0.1"
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "job, j",
			Usage: "specific job search of the input.",
		},
		cli.StringFlag{
			Name:  "from, fr",
			Usage: "specific schedule search from time formatted like 2006-01-02-15-04",
		},
		cli.BoolFlag{
			Name:  "plain, p",
			Usage: "only result is written to standard output.",
		},
	}
	app.Action = func(c *cli.Context) error {
		// 検索範囲
		t := time.Now()
		str := c.String("from")
		if str != "" {
			const layout = "2006-01-02-15-04"
			// 時刻変換に失敗したらエラー
			var err error
			t, err = time.Parse(layout, str)
			if err != nil {
				return cli.NewExitError("error: from format is something wrong", 1)
			}
		}

		timeCondition := searchRange{
			from: t,
			to:   t.Add(time.Duration(24*365) * time.Hour),
		}

		plain := c.Bool("plain")
		if !plain {
			fmt.Println(timeCondition)
			fmt.Println("==============================================")
		}

		var jobs []CronJob
		targetJob := c.String("job")
		if targetJob != "" {
			var err error
			job, err := Parse(targetJob)
			if err != nil {
				return cli.NewExitError("error: cron format is something wrong.", 1)
			}
			jobs = []CronJob{job}

		} else {
			fileName := c.Args().Get(0)
			var err error
			jobs, err = readCrontabFile(fileName)
			if err != nil {
				if err == ErrParseJob {
					return cli.NewExitError("error: cron format is something wrong.", 1)
				}
				return cli.NewExitError("error: read crontab file failed", 1)
			}
		}

		if len(jobs) == 0 {
			fmt.Println("Probably nothing to do. no cron tasks.")
			return nil
		}

		for _, job := range jobs {
			from := timeCondition.from
			to := timeCondition.to
			cond := from
			for cond.Before(to) {
				ok, job := job.match(cond)
				if ok {
					fmt.Printf("%v : %s\n", job.schedule.Format("2006/01/02 15:04"), job.line)
					break
				}
				cond = cond.Add(time.Duration(1) * time.Minute)
			}
		}

		return nil
	}

	app.Run(os.Args)
}

// ErrCrontabFile はcrontabファイルが不正だった場合に発生するエラー
var ErrCrontabFile = errors.New("crontab file is something wrong")

// ErrParseJob はcronのフォーマットが不正だった場合に発生するエラー
var ErrParseJob = errors.New("cron format is something wrong")

func readCrontabFile(fileName string) ([]CronJob, error) {
	_, err := os.Stat(fileName)
	if err != nil {
		return nil, ErrCrontabFile
	}
	fp, err := os.Open(fileName)
	if err != nil {
		return nil, ErrCrontabFile
	}
	defer fp.Close()

	jobs := make([]CronJob, 0)
	scanner := bufio.NewScanner(fp)
	for scanner.Scan() {
		line := scanner.Text()
		if line == "" || strings.HasPrefix(line, "#") {
			continue
		}
		job, err := Parse(line)
		if err != nil {
			return nil, ErrParseJob
		}
		jobs = append(jobs, job)
	}

	return jobs, nil
}

// 実行されるcronの検索範囲を保持する構造体
type searchRange struct {
	from time.Time
	to   time.Time
}

func (s searchRange) String() string {
	const format = "2006/01/02 15:04"
	return fmt.Sprintf("from: %s - to: %s", s.from.Format(format), s.to.Format(format))
}


text:
require File.expand_path('../../../spec_helper', __FILE__)

ruby_version_is "2.1" do
  describe "Module#singleton_class?" do
    it "returns true for singleton classes" do
      xs = self.singleton_class
      xs.singleton_class?.should == true
    end

    it "returns false for other classes" do
      c = Class.new
      c.singleton_class?.should == false
    end

    describe "with singleton values" do
      it "returns false for nil's singleton class" do
        NilClass.singleton_class?.should == false
      end

      it "returns false for true's singleton class" do
        TrueClass.singleton_class?.should == false
      end

      it "returns false for false's singleton class" do
        FalseClass.singleton_class?.should == false
      end
    end
  end
end


text:
class Inc < Cask
  version 'latest'
  sha256 :no_check

  url 'http://inc-static.kippt.com.s3.amazonaws.com/apps/inc-osx.zip'
  homepage 'https://sendtoinc.com/apps/'

  link 'Inc.app'
end


text:
package org.roguewave.grpc.util.gfx;

import com.google.firestore.admin.v1beta1.Index;
import com.google.firestore.admin.v1beta1.IndexField;

import java.util.List;

public class DrawIndex {

    public void drawIndex(Index index) {

        System.out.println("Index Name: " + index.getName() + "\nIndex State: " + index.getState());

        List<IndexField> indexFieldList = index.getFieldsList();
        for (IndexField field : indexFieldList) {

            System.out.println("   Field: " + field.getFieldPath() + "   Mode: " + field.getMode().toString());

        }

    }

}


text:
package org.apache.lucene.collation;

import java.text.Collator;
import java.util.Locale;

import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.DocValuesRangeFilter;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryUtils;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.SortField;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;

/**
 * trivial test of CollationDocValuesField
 */
public class TestCollationDocValuesField extends LuceneTestCase {

  public void testBasic() throws Exception {
    Directory dir = newDirectory();
    RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
    Document doc = new Document();
    Field field = newField("field", "", StringField.TYPE_STORED);
    CollationDocValuesField collationField = new CollationDocValuesField("collated", Collator.getInstance(Locale.ENGLISH));
    doc.add(field);
    doc.add(collationField);

    field.setStringValue("ABC");
    collationField.setStringValue("ABC");
    iw.addDocument(doc);

    field.setStringValue("abc");
    collationField.setStringValue("abc");
    iw.addDocument(doc);

    IndexReader ir = iw.getReader();
    iw.close();

    IndexSearcher is = newSearcher(ir);

    SortField sortField = new SortField("collated", SortField.Type.STRING);

    TopDocs td = is.search(new MatchAllDocsQuery(), 5, new Sort(sortField));
    assertEquals("abc", ir.document(td.scoreDocs[0].doc).get("field"));
    assertEquals("ABC", ir.document(td.scoreDocs[1].doc).get("field"));
    ir.close();
    dir.close();
  }

  public void testRanges() throws Exception {
    Directory dir = newDirectory();
    RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
    Document doc = new Document();
    Field field = newField("field", "", StringField.TYPE_STORED);
    Collator collator = Collator.getInstance(Locale.getDefault()); // uses -Dtests.locale
    if (random().nextBoolean()) {
      collator.setStrength(Collator.PRIMARY);
    }
    CollationDocValuesField collationField = new CollationDocValuesField("collated", collator);
    doc.add(field);
    doc.add(collationField);

    int numDocs = atLeast(500);
    for (int i = 0; i < numDocs; i++) {
      String value = TestUtil.randomSimpleString(random());
      field.setStringValue(value);
      collationField.setStringValue(value);
      iw.addDocument(doc);
    }

    IndexReader ir = iw.getReader();
    iw.close();
    IndexSearcher is = newSearcher(ir);

    int numChecks = atLeast(100);
    for (int i = 0; i < numChecks; i++) {
      String start = TestUtil.randomSimpleString(random());
      String end = TestUtil.randomSimpleString(random());
      BytesRef lowerVal = new BytesRef(collator.getCollationKey(start).toByteArray());
      BytesRef upperVal = new BytesRef(collator.getCollationKey(end).toByteArray());
      Query query = new ConstantScoreQuery(DocValuesRangeFilter.newBytesRefRange("collated", lowerVal, upperVal, true, true));
      doTestRanges(is, start, end, query, collator);
    }

    ir.close();
    dir.close();
  }

  private void doTestRanges(IndexSearcher is, String startPoint, String endPoint, Query query, Collator collator) throws Exception {
    QueryUtils.check(query);

    // positive test
    TopDocs docs = is.search(query, is.getIndexReader().maxDoc());
    for (ScoreDoc doc : docs.scoreDocs) {
      String value = is.doc(doc.doc).get("field");
      assertTrue(collator.compare(value, startPoint) >= 0);
      assertTrue(collator.compare(value, endPoint) <= 0);
    }

    // negative test
    BooleanQuery bq = new BooleanQuery();
    bq.add(new MatchAllDocsQuery(), Occur.SHOULD);
    bq.add(query, Occur.MUST_NOT);
    docs = is.search(bq, is.getIndexReader().maxDoc());
    for (ScoreDoc doc : docs.scoreDocs) {
      String value = is.doc(doc.doc).get("field");
      assertTrue(collator.compare(value, startPoint) < 0 || collator.compare(value, endPoint) > 0);
    }
  }
}


text:
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.

using System;
using System.Threading.Tasks;
using FakeN.Web;
using Shouldly;
using Xunit;

namespace Microsoft.Owin.Host.SystemWeb.Tests
{
    public class OwinHttpHandlerTests : TestsBase
    {
        [Fact]
        public Task ItShouldCallAppDelegateWhenBeginProcessRequestCalled()
        {
            var httpHandler = new OwinHttpHandler(string.Empty, OwinBuilder.Build(WasCalledApp));
            FakeHttpContext httpContext = NewHttpContext(new Uri("http://localhost"));

            Task task = Task.Factory.FromAsync(httpHandler.BeginProcessRequest, httpHandler.EndProcessRequest, httpContext, null);
            return task.ContinueWith(_ =>
            {
                task.Exception.ShouldBe(null);
                WasCalled.ShouldBe(true);
            });
        }
    }
}


text:
/*
206. Reverse Linked List

Reverse a singly linked list.
*/

/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) { val = x; }
 * }
 */
class Solution {
    public ListNode reverseList(ListNode head) {
        if(head == null || head.next == null) {
            return head;
        }
        ListNode prev = head;
        ListNode cur = head.next;
        prev.next = null;
        while(cur != null) {
            ListNode temp = cur;
            cur = cur.next;
            temp.next =prev;
            prev = temp;
        }
        return prev;
    }
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenNLP.Tools.Ling;

namespace OpenNLP.Tools.Util.Process
{
    /// <summary>
    /// Constructs a Word from a string. This is the default
    /// TokenFactory for PTBLexer. It discards the positional information.
    ///
    /// @author Jenny Finkel
    ///
    /// Code retrieved on the Stanford parser and ported to C# (see http://nlp.stanford.edu/software/lex-parser.shtml)
    /// </summary>
    public class WordTokenFactory : ILexedTokenFactory<Word>
    {

        public Word MakeToken(string str, int begin, int length)
        {
            return new Word(str, begin, begin + length);
        }
    }
}


text:
namespace fractal {
	namespace fgraphics {
		class MeshData;
		class Vao {
		public:
			Vao();
			const GLuint VAO;
			size_t indicesSize, vecticesSize;
			GLfloat  furthestPoint;
			std::vector<GLuint> vbos;

			void bind();
			void unbind();
			void loadMeshIntoOpenGL(MeshData* meshData);
			void loadFontIntoOpenGL(const std::vector<fmath::Vector2>& positions,
				const std::vector<fmath::Vector2>& textCoords);
			void loadMeshIntoOpenGL(const std::vector<fmath::Vector3>& positions,
				const std::vector<fmath::Vector3>& normals, const std::vector<fmath::Vector2>& UVs, const std::vector<int>& indices);
			void loadUIIntoOpenGL();
			void loadSkybox();
			void destroy();
		private:
			void loadVboIntoOpenGL(const GLuint type, const void* data, size_t size, size_t dimension);
			void loadIndexIntoOpenGL(const GLuint type, const int* position, size_t size);
			static const GLuint create();
		};
	}
}

#endif // !VAO_H


text:
#ifndef CCB_NOTIFICATION_NODE_HH
#define CCB_NOTIFICATION_NODE_HH

#include <ctime>
#include "com/centreon/broker/namespace.hh"

CCB_BEGIN()

namespace notification {
namespace objects {

struct record {
  record(const char* name, uint32_t index) : name(name), index(index) {}
  record() : name(NULL), index(0) {}

  const char* name;
  uint32_t index;
};
}  // namespace objects
}  // namespace notification

CCB_END()

#endif  // !CCB_NOTIFICATION_NODE_HH