Skip to content

Instantly share code, notes, and snippets.

View jarrettmeyer's full-sized avatar

Jarrett Meyer jarrettmeyer

View GitHub Profile
@jarrettmeyer
jarrettmeyer / CookieUtil.js
Last active August 29, 2015 14:04
Login View Example
CookieUtil = (function () {
var expirationDays = 14;
function deleteCookie(key) {
var expiration = new Date(0).toGMTString();
document.cookie = key + "=;expires=" + expiration;
}
function getCookie(key) {
@jarrettmeyer
jarrettmeyer / Controller.cs
Created July 10, 2014 12:58
Unit testing a controller
// Version 0: Nope.
public class SomeController
{
public object Get(string story, string view)
{
// Unit test blows up on the following line because there
// is no Request (NullReferenceException) from within a
// unit test.
var queryString = Request.RequestUri.ParseQueryString();
// snip
describe User do
# The test suite adds a #stub() method to every object. Since instances of objects
# and class definitions are considered objects in Ruby, the #stub() method gets
# applied just about everywhere. It can be used to stub both instance methods and
# class methods.
it "can have tests that hit a database" do
user = User.find(1) # This test will go to the database
expect(user.username).to eq("admin")
public class StrategyQuery
{
public string Name { get; set; }
}
public interface IStrategy
{
bool CanHandle(StrategyQuery query);
void DoSomething();
}
@jarrettmeyer
jarrettmeyer / ConversionStrategy.js
Created March 25, 2014 14:38
An idea for unit conversions in javascript
var ConversionStrategy = (function () {
function ConversionStrategy() {
}
ConversionStrategy.prototype.valueOf = function (value) {
return -1;
};
return ConversionStrategy;
@jarrettmeyer
jarrettmeyer / NinjectDependencyResolver.cs
Created March 20, 2014 10:57
Ninject Web API Setup
using System;
using System.Diagnostics.Contracts;
using System.Web.Http.Dependencies;
using Ninject;
using Ninject.Activation.Blocks;
namespace MyProject
{
public class NinjectDependencyResolver : NinjectDependencyScope, IDependencyResolver
{
@jarrettmeyer
jarrettmeyer / environment.txt
Last active January 3, 2016 09:19
Windows environment variables
PATH
%WINDOWS_PATH%;%SQL_SERVER_PATH%;%VISUAL_STUDIO_PATH%;%GIT_PATH%;%NODEJS_PATH%;%DEVTOOLS_PATH%
WINDOWS_PATH
C:\Windows;C:\Windows\system32;C:\Windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\
SQL_SERVER_PATH
C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\
(function () {
var defaults = {
message: "Waiting...",
selector: ".text-selector"
}
window.thing = {
initialize: function (opts) {
// Using Modernizr to detect and then apply a datepicker to date objects.
// Instead of creating a new instance of a JavaScript class, this is
// using an object literal.
//
// Usage: DatePickers.initialize(); This would either be called from the
// bottom of your page (after any date pickers) or from inside a jQuery
// document ready clause.
//
// Options:
// extension: The name of the extension to create/initialize the date
// We are creating a new class definition. The class definition itself
// will be added to the global window object.
window.MultiSelect = (function() {
function MultiSelect(options) {
var defaults = {
checkboxSelector: ".multi-select-checkbox",
onSelector: ".multi-select-on",
selectAllSelector: "#multi-select-all"
};