Instantly share code, notes, and snippets.

View cachebuster-gruntfile.js
module.exports = function(grunt) {
cachebuster: {
//appears you need a sub-task
'generate-hashes': {
options: {
//basedir: 'src/EHRSim.Web'
//basedir replacement does NOT work on windows, need to handle replacement on your own
formatter: function(hashes) {
View runalltests.cs
//All.Tests program.cs
public static int Main(string[] args)
var basepath = "./";
if (args.Length > 0)
basepath = args[0];
View gist:b99f3ba7898b99dac68f
public bool IsSignatureValid(HttpRequestBase request, string oauthSecret)
var context = _contextBuilder.FromHttpRequest(request);
//this is for when we are behind a load balancer that handles SSL duties
//client contacts https://oursite but load balancer directs request to http://oursite on the actual server
//this fundamentally changes the signature base of the request, forcing us to try validating both ways
var maybeSignedWithHttpsNotHttpUrlContext = _contextBuilder.FromHttpRequest(request);
maybeSignedWithHttpsNotHttpUrlContext.RawUri = new Uri(context.NormalizedRequestUrl.Replace("http:", "https:"));
View index.html
<!doctype html>
<html lang="us">
<meta charset="utf-8">
<title>jQuery UI Example Page</title>
<link href="css/custom-theme/jquery-ui-1.10.1.custom.css" rel="stylesheet">
<script type="text/javascript" src="js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.10.1.custom.js"></script>
$(function() {
View NullableIntegerAttribute.cs
using System.ComponentModel.DataAnnotations;
namespace Project.MvvmFramework.ValidationAttributes
public class NullableIntegerAttribute : ValidationAttribute
private readonly int _maxDigits;
private readonly string _propertyName;
const string MessageFormat = "{0} can only contain up to {1} numeric characters.";
View kernel.placeholder.js
(function () {
$.support.placeholder = false;
var test = document.createElement('input');
if ('placeholder' in test) {
$.support.placeholder = true;
return function () { }
} else {
return function () {
$(function () {
var active = document.activeElement;
View GithubTicketImporter.cs
using System;
using System.Collections.Generic;
using RestSharp;
namespace GithubTicketImporter {
class Program {
static IAuthenticator authenticator = new HttpBasicAuthenticator("uname", "pwd");
static string assemblaBaseUrl = "";
static string githubBaseUrl = "";
View DatabaseReCollatorMcJawn.sql
--desired collation for (var)char columns:
DECLARE @collationName VARCHAR(30)
SET @collationName = 'Latin1_General_CS_AI'
--build tables containing drop/create index queries
View BuildAuthorizationKey.cs
/// <summary>
/// generates key to include in the "Authorization" request header
/// </summary>
/// <param name="accessKey">AWS access key</param>
/// <param name="secretKey">AWS secret key</param>
/// <param name="dateString">string included in the "x-amz-date" request header</param>
/// <returns>string to be used for signing request</returns>
static string BuildSignature(string accessKey, string secretKey, string dateString) {
var hmacSha1 = new HMACSHA1(Encoding.UTF8.GetBytes(secretKey));
var hashedDate = Convert.ToBase64String(hmacSha1.ComputeHash(Encoding.UTF8.GetBytes(dateString)));
View NHibernatePartialCollection.cs
public void Limit_Collection_Contents_Criteria() {
var pepperoni = new Topping { Name = "pepperoni", Type = "meat" };
var cheese = new Topping { Name = "mozzarella", Type = "dairy" };
var cheesePizza = new Pizza() { Crust = "deep dish", Sauce = "red" }
var pepperoniPizza = new Pizza() { Crust = "deep dish", Sauce = "red" }