Skip to content

Instantly share code, notes, and snippets.

public static void DisplayNameAndTitle(Person p)
{
Contract.Requires(p != null, "Person cannot be null");
Contract.Requires(p.GivenName != null, "Person's given name must be specified");
Console.WriteLine("{0} {1} {2}", p.Title, p.GivenName, p.FamilyName);
}
@jonhilt
jonhilt / rakefile.rb
Created May 19, 2010 12:53
A simple Rake build script example
require 'albacore'
require 'fileutils'
PROJECT_NAME = "Your Project Here"
DOT_NET_PATH = "C:/Windows/Microsoft.NET/Framework/v4.0.30319/"
NUNIT_PATH = "Tools/nunit/"
MSPEC_PATH = "Tools/mspec/"
PROJECT_CONFIG = (ENV['PROJECT_CONFIG'] == nil) ? "Debug" : ENV['PROJECT_CONFIG']
COMPANY_NAME = "Your Company Here"
BUILD_NUMBER = (ENV['BUILD_NUMBER'] == nil) ? "1.0.0.0" : ENV['BUILD_NUMBER']
$('#saveChanges').click(function () {
var rules = new Array();
$('#assignedRules table.ruleTable tbody tr').each(function (i) {
var subRuleCode = $('#subRuleCode', this).val();
var productGroupId = $('#productGroupId', this).val();
rules.push(new Rule(subRuleCode, productGroupId));
});
var postData = JSON.stringify(rules); ;
function Rule(subRuleCode, productGroupId) {
this.SubRule = subRuleCode;
this.ProductGroupId = productGroupId;
}
[AcceptVerbs(HttpVerbs.Post)]
public JsonResult SaveUserRules(List<Rule> usersRules)
{
// do something with the userRules list
}
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
if (!IsJSONRequest(controllerContext))
{
return base.BindModel(controllerContext, bindingContext);
}
// get the JSON data that's been posted
var request = controllerContext.HttpContext.Request;
var jsonStringData = new StreamReader(request.InputStream).ReadToEnd();
ModelBinders.Binders.DefaultBinder = new JsonModelBinder();
@jonhilt
jonhilt / qlikview.cs
Created March 2, 2012 11:21
Qlikview
#region
using System;
using System.Threading;
using System.Windows.Forms;
using QlikView;
using Application = QlikView.Application;
#endregion
protected override async Task RunAsync(CancellationToken cancelServicePartitionReplica)
{
// TODO: Replace the following sample code with your own logic.
// Gets (or creates) a replicated dictionary called "myDictionary" in this partition.
var myDictionary = await this.StateManager.GetOrAddAsync<IReliableDictionary<string, long>>("myDictionary");
// This partition's replica continues processing until the replica is terminated.
while (!cancelServicePartitionReplica.IsCancellationRequested)
{
var client = QueueClient.CreateFromConnectionString(connectionString, "send-email-queue");
var sendEmailCommand = new SendEmailCommand {
Subject = "Email from contact us page",
Body = "Hi, please can you send me more details about the super email sender",
CustomerEmail = "jon@azureinsights.net"
};
client.Send(new BrokeredMessage(sendEmailCommand));