Query Mongo as easy as RavenDB.

Posted On: February 22nd, 2013

I am a big advocate of document databases. I am a believer that they help developers write and separate responsibility in their enterprise systems cleanly.

If your in the .NET world, you will probably lean towards RavenDB in document database space.

However, I want to pitch mongo with a twist to you. The basic C# driver is provided to you, the mongo-csharp-driver and it works pretty darn well out of the box.

However, I wanted to make the c# driver as easy to use as RavenDB, out of the box. That is where: mongo-csharp-adapt WIP comes in:

 

Lets Adapt:
For this demo I will use this Mvc Application stub:

using System.Linq;
using MongoAdapt;

namespace MyMvcApplicaiton
{
    IDocumentDatabase _documentDb;

    ...
}

The first thing, that MongoAdapt gives you if you adopt is Dependency Injection Support, just register IDocumentDatabase to MongoDatabaseAdapter in your favorite IoC and your booming!

CONTINUE READING COMMENTS (0)

JavaScript, Part 2: Working with Function Prototypes.

Posted On: February 18th, 2013
Javascript Part 2 Doodle

About a year or two ago, I wrote about JavaScript Objects, Functions, Scoping & Closure.

I wanted to continue this series and take some time to discuss Object.prototype.

I created a person Object in that post, the truth is that I would never create a person Object like this:

var person = {
  firstName: 'john',
  lastName: 'doe',
  changeName: function (firstName, lastName) {
    this.firstName = firstName;
    this.lastName = lastName;
  },
  fullName: function () {
    return this.firstName + ' ' + this.lastName;
  }
};

Recreating this type of Object is expensive. By doing so you would create changeName and fullName, over and over again. Lets talk functional prototypes.

CONTINUE READING COMMENTS (0)

Sinatra Views & Layouts

Posted On: January 18th, 2013
Sinatra says yield!

Your on your way to creating your first sinatra website.

myapp.rb:

require 'sinatra'

class MyApp < Sinatra::Application

end

You make your first route:

myapp.rb:

require 'sinatra'
require 'haml' #require in the haml template engine

class MyApp < Sinatra::Application

  get '/' do
    haml :index #parse index.haml, and return html
  end

end
CONTINUE READING COMMENTS (0)

JavaScript, Part 1: Objects, Functions, Scoping & Closure.

Posted On: July 26th, 2011
Making the js puzzle fit.

Object Literals:
JavaScript is mostly composed of objects. You should use objects to collect and store common data and information:

var person = { 
    firstName: "john",
    lastName: "doe",
    address: {
         street: "321 Street",
         zipCode: "94125",
         county: "San Francisco",
         state: "CA"
    }
};

An empty JavaScript object, is defined, like so:

var person = { };
CONTINUE READING COMMENTS (1)

OpenID for ASP.NET MVC, A Quick Setup

Posted On: September 23rd, 2010

I went around the internet looking for a quick tutorial setting up DotNetOpenAuth for a project. No big surprise everything I ran into was either too confusing to follow or filled with useless information.

If you need to get your ASP.NET MVC website setup with some basic OpenID Authentication, I can help get you started. All you need is a DLL, a view, and two controller actions.

First download the latest DotNetOpenAuth and extract the zip file. Let’s start.

CONTINUE READING COMMENTS (10)

Zen Coding PHP (Pre 0.7), Zen Coding custom snippet example.

Posted On: August 30th, 2010

By now you are probably a big fan of Zen Coding, and want more. I am going to run through a tutorial on how to create custom snippets using the “Zen Coding.js” file.

At the end of this tutorial I have a link to a PHP version I wrote for personal use, feel free to download, edit, destroy, and share it.

Lets dive in.

CONTINUE READING COMMENTS (11)

Moq Testing Tutorial

Posted On: December 1st, 2009

If your reading this then I assume you are either looking for or have an interest in a mocking framework for testing your .NET Applications.

In this tutorial I will step you through a framework called Moq for (.NET) released under the New BSD License. I will not be discussing what Mocking is here as that’s outside the scope of this tutorial. What is mocking/mock object?

Before we jump into the code, we need to install Moq and it’s dependencies (using the nuget package manager):

   PM> Install-Package Moq
   PM> Install-Package Moq.Contrib.Indy

Lets dive in, assuming you have references to the Moq DLL, Moq.Contrib.Indy DLL and their dependencies in your project. Let’s start out by creating a new class in your project. During this session I am going to call this class: TestContext.

CONTINUE READING COMMENTS (17)

Css Syntax Highlighting for Scss

Posted On: September 17th, 2009

This post is very dated, I recommend using this tool: Mindscape Web Workbench

I wrote a quick little extension for Visual Studio 2010, which allows you to View SCSS with CSS 2.1 Syntax Highlighting and Intellisense, not the greatest thing in the world, but it helps a bit.

It can easily be uninstalled through the Extension Manager, if you don’t want it anymore. I basically took the values in my Registry for Css and duplicated them for SCSS.

Extension Source:

[$RootKey$\Languages\File Extensions\.scss]
@="{A764E898-518D-11d2-9A89-00C04F79EFC3}"

[$RootKey$\Editors\{A764E89A-518D-11d2-9A89-00C04F79EFC3}\Extensions]
"scss"=dword:00000040

READ BEFORE INSTALL!:

  • You must “Exclude [files] from Project” [SCSS] after install, then “View hidden files” and “Include files in Project” to make this work on existing files.
  • Run the installer as an Administrator.
  • Remove any entries for “scss” from: Tools, Text Editor, File Extension.

Download Extension: ScssInCss

CONTINUE READING COMMENTS (15)

Consume a WordPress RSS Feed in C# and cache it.

Posted On: April 1st, 2009

I couldn’t find a simple example of reading a WordPress Blog Feed in C# and caching it. So I decided to write out my own.

Here is an example to get you started. I wrote it in two parts:

A Class that Consumes a Feed (FeedReader)
An Object representing a Feed Item (FeedViewModel).

And so we begin:

CONTINUE READING COMMENTS (6)
Want to read more? Check out my Archive.

Thank you for visting my blog, Andrew Kharlamov. 2009-2013.