Skip to content

Instantly share code, notes, and snippets.

View jcreamer898's full-sized avatar
🏠
Working from home

Jonathan Creamer jcreamer898

🏠
Working from home
View GitHub Profile
@jcreamer898
jcreamer898 / giphy.sh
Created February 7, 2017 22:06
Giphy Search
#!/bin/bash
input=$1
query=${input// /%20}
url=http://api.giphy.com/v1/gifs/search\?q=$query\&api_key\=dc6zaTOxFJmzC
image=$(curl -s $url | jq '.data[0] | { url: .images.fixed_height.url } | .url')
echo "Added $image to the clipbboard."
echo ${image//\"/ } | pbcopy
@jcreamer898
jcreamer898 / whatHasUpdated.js
Created September 15, 2016 17:12
A way to figure out which state or props changed in any react component.
const whatHasUpdated = (instance, props, state) => {
const changed = (obj, comparedTo) => Object.keys(obj).reduce((memo, key) => {
if (comparedTo[key] !== obj[key]) {
memo.push({
key,
old: comparedTo[key],
new: obj[key],
});
}
import stringify from "json-stringify-safe";
import clone from "lodash/clone";
import each from "lodash/each";
import find from "lodash/find";
import camelCase from "lodash/camelCase";
const _ = {
clone, each, find, camelCase,
};
@model IEnumerable<TechPro.Web.UI.Areas.Admin.Controllers.HomeController.RouteViewModel>
<div ng-app="routesModule">
<h3>Routes</h3>
<input type="text" placeholder="Filter by Url" ng-model="query.Url" />
<div ng-controller="RouteListController" ng-cloak>
<p>Total Routes: {{(routes | filter:query).length}}</p>
public ActionResult NotFound()
{
ActionResult result;
object model = Request.Url.PathAndQuery;
if (!Request.IsAjaxRequest())
{
result = View("NotFound", model);
}
@jcreamer898
jcreamer898 / TheBestStyleGuideForJavaScriptThatExistsInTheWholeWorld.md
Created January 8, 2014 16:06
This is the best style guide for JavaScript in the whole world.

insert your style guide here, and follow it...

ALTER PROCEDURE [jobs].[spu_Job_List_Active_For_Recruiter] (
@recruiterId INT,
@pageNumber INT = 1,
@perPage INT = 5,
@paging BIT = 1
) AS
BEGIN
;WITH Jobs AS
(
SELECT
Z7777777Z
777777777777777Z
Z7777777777777777777
77777777777777777777777
7777777777777777777777777D
7777777777777Z$777777777777N
7777777777D 7777777777
777777777 $77777777
77777777 777777777
77777777 777777777
@{
// Setup the tabs for the profile page.
// The Href will also point to a view located at `MyProfileTabs/HREF.cshtml`.
var tabs = new[]
{
new
{
Href = "tab-profile",
Name = "Profile",
ClassName = "active",

The file I want to test is set up as an IIFE, which works great in the browser. I'm able to use the method renderInteractions like so:

var something = utils.renderInteractions(doc);

However, when I run the test suite I get the following error:

TypeError: Object #<Object> has no method 'renderInteraction'

I found this Stack Overflow post which seems to indicate that your JavaScript file HAS to export something that Mocha can tap into: http://stackoverflow.com/questions/10204021/how-do-i-test-normal-non-node-specific-javascript-functions-with-mocha