Skip to content

Instantly share code, notes, and snippets.

View howarddierking's full-sized avatar

Howard Dierking howarddierking

View GitHub Profile
@howarddierking
howarddierking / WCFNet45AsyncService.cs
Created November 30, 2011 19:46
WCF 4.5 Async Service Operation
public async Task<double> CalculateShippingSubtotalAsync(int productID, string postalCode)
{
var productServiceProxy = new ProductServiceClient();
var shippingServiceProxy = new ShippingServiceClient();
var t = productServiceProxy.GetProductByIDAsync(productID);
var t2 = shippingServiceProxy.GetShippingCostForPostalCodeAsync(postalCode);
await Task.WhenAll(t, t2);
public HttpResponseMessage<IEnumerable<Bug>> Post(JsonObject formData) {
dynamic data = formData.AsDynamic();
var bug = new Bug
{
Name = data.name,
Priority = data.priority,
Rank = data.rank,
};
_bugRepository.Add(bug);
@howarddierking
howarddierking / chainedBundleTransform.cs
Created March 8, 2012 03:20
example of a chained bundle transform using less
protected void Application_Start()
{
//...
Bundle cssBundle = new Bundle("~/Content/css", new LessTransform().Then(new CssMinify()));
cssBundle.AddFile("~/Content/site.css", throwIfNotExist: false);
cssBundle.AddDirectory("~/Content/", "jquery.mobile*", searchSubdirectories: false, throwIfNotExist: false);
BundleTable.Bundles.Add(cssBundle);
//...
@howarddierking
howarddierking / gist:2869437
Created June 4, 2012 16:35
Bundle registration in VS 2012 Beta
bundle = new Bundle("~/Content/themes/base/css", csstransformer);
bundle.AddFile("~/Content/themes/base/jquery.ui.core.css", true);
bundle.AddFile("~/Content/themes/base/jquery.ui.resizable.css", true);
bundle.AddFile("~/Content/themes/base/jquery.ui.selectable.css", true);
bundle.AddFile("~/Content/themes/base/jquery.ui.accordion.css", true);
bundle.AddFile("~/Content/themes/base/jquery.ui.autocomplete.css", true);
bundle.AddFile("~/Content/themes/base/jquery.ui.button.css", true);
bundle.AddFile("~/Content/themes/base/jquery.ui.dialog.css", true);
bundle.AddFile("~/Content/themes/base/jquery.ui.slider.css", true);
bundle.AddFile("~/Content/themes/base/jquery.ui.tabs.css", true);
@howarddierking
howarddierking / gist:2869445
Created June 4, 2012 16:36
Bundle registration in VS 2012 RC
bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
"~/Content/themes/base/jquery.ui.core.css",
"~/Content/themes/base/jquery.ui.resizable.css",
"~/Content/themes/base/jquery.ui.selectable.css",
"~/Content/themes/base/jquery.ui.accordion.css",
"~/Content/themes/base/jquery.ui.autocomplete.css",
"~/Content/themes/base/jquery.ui.button.css",
"~/Content/themes/base/jquery.ui.dialog.css",
"~/Content/themes/base/jquery.ui.slider.css",
"~/Content/themes/base/jquery.ui.tabs.css",
@howarddierking
howarddierking / gist:2869451
Created June 4, 2012 16:38
Custom LESS bundle transform
public class LessTransform : IBundleTransform
{
public void Process(BundleContext context, BundleResponse response)
{
response.Content = dotless.Core.Less.Parse(response.Content);
response.ContentType = "text/css";
}
}
@howarddierking
howarddierking / gist:2869457
Created June 4, 2012 16:39
Bundle registration for custom transform in VS 2012 RC
var lessBundle = new Bundle("~/My/Less").IncludeDirectory("~/My", "*.less");
lessBundle.Transforms.Add(new LessTransform());
lessBundle.Transforms.Add(new CssMinify());
bundles.Add(lessBundle);
@howarddierking
howarddierking / gist:2889557
Created June 7, 2012 15:45
RestBugs Node POST sample
app.post('/bugs/working', function(req, res){
db.bugs.find({_id:req.body.id}, function(err, doc){
doc.activate(req.body.comments);
db.bugs.update({_id:req.body.id}, doc, function(err, updatedDoc){
db.bugs.find({status:'Working'}, function(err, docs){
res.render('bugs-all.html', {
title: "Working",
model: { bugs : docs }});
@howarddierking
howarddierking / gist:2889580
Created June 7, 2012 15:47
RestBugs Bug JavaScript Object
function Bug(title, description) {
var self = this;
this.title = title;
this.description = description;
this.assignedTo = '';
this.status = '';
this.history = [];
function addToHistory(comments, stateChanges){
self.history.push({
[
{
"Make":"Ford",
"Model":"Taurus",
"Vin":"1234",
"Forms" : [
{
"Uri":"...",
"Rel":"reservation",
"Mode":"POST",