Skip to content

Instantly share code, notes, and snippets.

View odytrice's full-sized avatar

Ody Mbegbu odytrice

View GitHub Profile
@odytrice
odytrice / objects-closures.ts
Created August 13, 2016 17:25
This shows the relationship between Objects and Closures
//External state
let z = 5;
//this closure implicitly contains the value of z
let closure = function(x){
return x + z;
}
//The above loosely translates to..
class ObjectClosure{
@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) {
@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 / sicp.fs
Last active October 29, 2019 10:07
Structure and Interpretation of Computer Programs - F# Code Examples
(* SICP Chapter #01 Examples in F# *)
#light
(* 1.1.1 The Elements of Programming - Expressions *)
486
137 + 349
1000 - 334
5 * 99
10 / 5
2.7 + 10.0
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 / 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>
@odytrice
odytrice / fsharp-tutorial.fs
Last active March 3, 2024 04:32
F# Code Samples
// This sample will guide you through elements of the F# language.
//
// *******************************************************************************************************
// To execute the code in F# Interactive, highlight a section of code and press Alt-Enter in Windows or
// Ctrl-Enter Mac, or right-click and select "Send Selection to F# Interactive".
// You can open the F# Interactive Window from the "View" menu.
// *******************************************************************************************************
// For more about F#, see:
// 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 / 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];
/// <reference path="notification.ts" />
/// <reference path="../app.ts" />
module App.Services {
export class FileService {
static $inject = ["_notify", "$rootScope", "$q"];
scope: ng.IRootScopeService;
notify: NotifyService;