Skip to content

Instantly share code, notes, and snippets.

View lnickers2004's full-sized avatar

Larry Nickerson lnickers2004

View GitHub Profile
@lnickers2004
lnickers2004 / gist:8464784
Created January 16, 2014 22:30
PAGING: --GetAll method in RavenDb using LINQ for paging
public static List<EventData> GetAll()
{
using (var session = store.OpenSession())
{
RavenQueryStatistics stats;
// get the first page
@lnickers2004
lnickers2004 / gist:8464710
Created January 16, 2014 22:25
REPOSITORY SAMPLE: an example simple repository interface
using System;
using System.Linq;
using System.Linq.Expressions;
namespace MGMAuthCORS.Models
{
public interface IEventDataRepository : IDisposable
{
@lnickers2004
lnickers2004 / gist:8464658
Last active January 3, 2016 12:39
LINQ: sample queries collected over time...
//001: RAVEN DB LINQ QUERY
var results = session.Query<Car>()
.Statistics(out stats)
.Skip(0*10) // retrieve results for the first page
.Take(20) // page size is 20
.Where(x => x.Make == "Ford")
.Distinct().ToList();
//002: descending orderby
var query = this._unit.Homes.GetAll().OrderByDescending(s => s.Price);
@lnickers2004
lnickers2004 / gist:8464534
Last active January 3, 2016 12:39
WebAPI 2: Ninject RegisterServices: to register Services, Context Objects, Repositories, i.e any dependencies
[assembly: WebActivator.PreApplicationStartMethod(typeof(CountingKs.App_Start.NinjectWebCommon), "Start")]
[assembly: WebActivator.ApplicationShutdownMethodAttribute(typeof(CountingKs.App_Start.NinjectWebCommon), "Stop")]
namespace CountingKs.App_Start
{
using System;
using System.Web;
using System.Web.Http;
using CountingKs.Data;
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
@lnickers2004
lnickers2004 / gist:8463611
Last active January 3, 2016 12:29
WebAPI 2: Foods ApiController which returns an IEnumerable type and behind-the-scenes depends upon the JSON.NET Camel Case Contract Resolver Formatter to format the JSON nicely for client consumption. NOTE: we still need to change this to use dependency Injection of an Entity Repository-- to make for better decopling and testing.
using CountingKs.Data;
using CountingKs.Data.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
@lnickers2004
lnickers2004 / gist:8451799
Last active January 3, 2016 10:49
Web API 2: very basic return of a json array. NOTE: this is not recommended method of generating JSON we should use a formatter and return IHTTPResult etc. instead. But, this is a quick start at returning a list as a javascript array
using CountingKs.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
@lnickers2004
lnickers2004 / gist:8431262
Created January 15, 2014 05:23
Bootstrap3: ALERT closing and resetting when a dialog is closed, followed by closing the confirmation alert
<script>
(function()
{
$sentDialog.on("hidden.bs.modal", function () {
//do some work, save form, move onto another page etc
//show the Alert
@lnickers2004
lnickers2004 / gist:8430717
Last active January 3, 2016 07:39
Bootstrap3: Tooltip support. NOTE: this requires the use of javascript -- calling the tooltip(); method
<script>
(function(){
$("#contactForm input[type=submit]").tooltip();
//alternative is to set delay in code with more options:
$("#contactForm input[type=submit]").tooltip(
{
delay:{
show: 500,
hide: 0
@lnickers2004
lnickers2004 / gist:8430504
Last active January 3, 2016 07:39
Bootstrap3: Tab Control Example. two tabs, tab1: form tab2: addres section
<!--tab control for address and contact form-->
<ul class="nav nav-tabs">
<li class="active">
<a href="#formTab" data-toggle="tab">Contact Form</a></li>
<li>
<a href="#addressTab" data-toggle="tab">Address</a>
</li>
</ul>
<div class="tab-content">
@lnickers2004
lnickers2004 / gist:8430206
Created January 15, 2014 03:22
BOOTSTRAP3: HANDLING MODAL DIALOG EVENTS
(function()
{
//get a referenct to the dialog
var $sentDialog = $("#sentDialog");
debugger;