Skip to content

Instantly share code, notes, and snippets.

View samueleresca's full-sized avatar

Samuele Resca samueleresca

View GitHub Profile
//Grunt configuration
module.exports = function(grunt) {
'use strict';
require('load-grunt-tasks')(grunt);
grunt.initConfig({
//blanket_mocha CONFIGURATION
blanket_mocha: {
options: {
run: true,
reporter: 'Min',
//KARMA CONFIGURATION
grunt.initConfig({
//PREVIOUS CODE..
karma : {
options: {
//Karma config file
configFile: 'karma.conf.js',
files: [
//KARMA CONFIGURATIONS
module.exports = function(config) {
config.set({
// base path
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha'],
// PORT NUMBER
port: 9877,
<packages>
<package id="mongocsharpdriver" version="2.0.1" />
<package id="MongoDB.Driver" version="2.0.1" />
<package id="MongoDB.Driver.Core" version="2.0.1" />
<package id="MongoDB.Bson" version="2.0.1" />
</packages>
using MongoDB.Bson;
using System.ComponentModel.DataAnnotations;
using MongoDB.Bson.Serialization.Attributes;
namespace Blog.QueryingMongoDb.Models
{
public class ContactModel
{
[BsonId]
public ObjectId Id { get; set; } //MongoDb uses this field as identity.
using MongoDB.Driver;
namespace Blog.QueryingMongoDb.Models.Repository
{
public class MongoDbRepo
{
//The client that manage the connection
public MongoClient Client;
//The interface that manage the database
using MongoDB.Bson;
using MongoDB.Driver;
using System.Collections.Generic;
namespace Blog.QueryingMongoDb.Models.Repository
{
public class ContactCollection
{
//Intializes the mongo db repository
internal MongoDbRepo _repo = new MongoDbRepo("mongodb://127.0.0.1:27017", "QueryMongoDb");
using System;
using System.Web.Mvc;
using Blog.QueryingMongoDb.Models;
using Blog.QueryingMongoDb.Models.Repository;
namespace Blog.QueryingMongoDb.Controllers
{
public class ContactController : Controller
{
//Private instance of contact collection
<html>
<head>
<title>JSON - JSONP tests</title>
<!--Include jquery-->
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(function(){
//DEF response
var data = {};
data.title = "title";
//DEPENDENCIES
var express = require('express');
//Initialize Express.js
var app = express();
//JSON Get Request
app.get('/endpointJSON', function(req, res){
//LOG