Skip to content

Instantly share code, notes, and snippets.

View odytrice's full-sized avatar

Ody Mbegbu odytrice

View GitHub Profile
@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 / 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 / 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>
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
@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 / Curry.cs
Created May 12, 2016 08:58
Curry Function in C#
public static partial class Prelude
{
/// <summary>
/// Curry the function 'f' provided.
/// You can then partially apply by calling:
///
/// var curried = curry(f);
/// var r = curried(a)(b)
///
/// </summary>
namespace Ninject.Web
open Ninject.Modules
open Pocket.Core
open System
open System.Reflection
open System.Web.Mvc
open Ninject
open Microsoft.FSharp.Core.Operators
@odytrice
odytrice / directives.ts
Created August 2, 2016 10:22
Angular Typescript Directives and Utilities
module App.Directives {
var Directive = function (): ng.IDirective {
return {
restrict: "A",
scope: {
location: "@navigate"
},
link: function (scope: any, el, attrs) {
el.click(function () {
document.location.href = scope.location;
@odytrice
odytrice / angular-paging.ts
Last active August 3, 2016 12:50
Angular Typescript Directives and Utilities
module App {
export class PagedList<T>{
private page: number;
private list: IList<T>;
private items: T[];
private itemsPerPage: number;
private numOfPages: number;
private count: number;
constructor(list: IList<T>, itemsPerPage = 10) {