Skip to content

Instantly share code, notes, and snippets.

View AlexCuse's full-sized avatar

Alex Ullrich AlexCuse

View GitHub Profile
//using https://www.npmjs.com/package/grunt-cachebuster
module.exports = function(grunt) {
grunt.initConfig({
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) {
@AlexCuse
AlexCuse / runalltests.cs
Created July 12, 2016 13:17
Run multiple test projects
//All.Tests program.cs
public static int Main(string[] args)
{
var basepath = "./";
if (args.Length > 0)
{
basepath = args[0];
}
@AlexCuse
AlexCuse / index.html
Created February 27, 2013 22:26
service-backed jquery autocomplete where we need to capture name and id from the returned value
<!doctype html>
<html lang="us">
<head>
<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>
<script>
$(function() {
@AlexCuse
AlexCuse / NullableIntegerAttribute.cs
Created December 18, 2012 22:13
nullable integer validation
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.";
@AlexCuse
AlexCuse / kernel.placeholder.js
Created July 10, 2012 17:37 — forked from aaronmccall/placeholder.js
shim for browsers that don't support the html5 placeholder attribute
(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;
@AlexCuse
AlexCuse / GithubTicketImporter.cs
Created May 22, 2012 00:05
Retrieve open tickets from assembla and create issues for them on github :)
using System;
using System.Collections.Generic;
using RestSharp;
namespace GithubTicketImporter {
class Program {
static IAuthenticator authenticator = new HttpBasicAuthenticator("uname", "pwd");
static string assemblaBaseUrl = "https://www.assembla.com/spaces/BrewTelligence/";
static string githubBaseUrl = "https://api.github.com/";
@AlexCuse
AlexCuse / DatabaseReCollatorMcJawn.sql
Created April 26, 2012 14:02
Recollate All SQL Server Columns
--desired collation for (var)char columns:
DECLARE @collationName VARCHAR(30)
SET @collationName = 'Latin1_General_CS_AI'
--build tables containing drop/create index queries
--http://www.sqlservercentral.com/scripts/Indexing/31652/
SELECT
REPLICATE(' ',4000) AS COLNAMES ,
OBJECT_NAME(I.ID) AS TABLENAME,
I.ID AS TABLEID,
@AlexCuse
AlexCuse / BuildAuthorizationKey.cs
Created April 25, 2012 18:14
Build Authorization Key for AWS Requests in C#
/// <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)));
@AlexCuse
AlexCuse / NHibernatePartialCollection.cs
Created January 15, 2012 00:59
Limiting Collection Contents w/ NHibernate
[Test]
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" }
.WithTopping(cheese);
var pepperoniPizza = new Pizza() { Crust = "deep dish", Sauce = "red" }
.WithTopping(cheese)
@AlexCuse
AlexCuse / gist:1056072
Created June 30, 2011 11:46
subscriber usage
let Run<'T when 'T: not struct and 'T:null and 'T:equality> (errorCallback, ct:CancellationToken, finished:ManualResetEvent) =
let sub = new Subscriber<'T>()
sub.ReceivedMessages(ct)
|> Seq.iter (fun msg ->
try
write msg
with | ex ->
sub.Return msg
errorCallback ex)
finished.Set() |> ignore