Skip to content

Instantly share code, notes, and snippets.

View odytrice's full-sized avatar

Ody Mbegbu odytrice

View GitHub Profile
@odytrice
odytrice / Paging.cs
Last active December 11, 2017 13:10
ASP.NET MVC Paging Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace System.Web.Mvc
{
@odytrice
odytrice / Ninject.Mvc.cs
Last active December 12, 2022 11:48
A small Library to configure Ninject (A Dependency Injection Library) with an ASP.NET Application.
using Ninject;
using Ninject.Modules;
using Ninject.Web.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Mvc;
@odytrice
odytrice / Ninject.Http.cs
Last active February 14, 2023 12:15
A small Library to configure Ninject (A Dependency Injection Library) with a WebAPI Application.
using Ninject.Modules;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Http;
using System.Web.Http.Dependencies;
// A small Library to configure Ninject (A Dependency Injection Library) with a WebAPI Application.
@odytrice
odytrice / DataRepository.cs
Last active October 26, 2016 10:57
A Generic DataRepository Class that Abstracts the DbContext
public class DataRepository : IDataRepository
{
private DbContext _dbContext;
public DataRepository(DbContext context)
{
_dbContext = context;
}
public IQueryable<T> Query<T>() where T : class
@odytrice
odytrice / IDataRepository.cs
Last active December 19, 2015 08:29
Interface for the DataRepository
/// <summary>
/// An Abstraction for a Generic DataAccess Repoository
/// </summary>
public interface IDataRepository
{
/// <summary>
/// Get all Elements of Type T
/// </summary>
/// <typeparam name="T">Entity Type</typeparam>
/// <returns>DbSet of Entities</returns>
@odytrice
odytrice / map.cs
Created June 7, 2014 15:29
Simple Auto Mapper
public static class Extensions{
public void Assign(this object destination, object source)
{
if (source != null)
{
var destProperties = destination.GetType().GetProperties();
foreach (var sourceProperty in source.GetType().GetProperties())
{
foreach (var destProperty in destProperties)
{
@odytrice
odytrice / directives.html
Last active March 27, 2016 05:34
Javascript Paging Library using AngularJS and Lazy
<!-- STEP 1: Add This Script Markup to your Page.. This is the Template for the Pager -->
<!-- Pager Markup -->
<script id="od-pager.html" type="text/ng-template">
<ul class="pagination" ng-show="links().length > 1">
<li><a ng-click="prev()">&laquo;</a></li>
<li ng-class="{active:isCurrentPage(item)}" ng-repeat="item in links()"><a ng-click="goto(item)">{{item + 1}}</a></li>
<li><a ng-click="next()">&raquo;</a></li>
</ul>
</script>
@odytrice
odytrice / LinqBatch.cs
Created September 17, 2015 15:09
Batch Processing Operator for IQueryable and IEnumerables
using System.Collections.Generic;
namespace System.Linq
{
public static class Extensions
{
#region IQueryable Extensions
public static IEnumerable<IQueryable<T>> Batch<T>(this IQueryable<T> query, int batchSize)
{
int count = query.Count();
/// <reference path="notification.ts" />
/// <reference path="../app.ts" />
module App.Services {
export class FileService {
static $inject = ["_notify", "$rootScope", "$q"];
scope: ng.IRootScopeService;
notify: NotifyService;
@odytrice
odytrice / MD5.ts
Created February 8, 2016 14:51
MD5 algorithm implemented in TypeScript
/**
* Credit http://www.myersdaily.org/joseph/javascript/md5-text.html
*/
module MD5 {
function md5cycle(x, k) {
var a = x[0],
b = x[1],
c = x[2],
d = x[3];