Skip to content

Instantly share code, notes, and snippets.

Ken Egozi kenegozi

Block or report user

Report or block kenegozi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
kenegozi / fix_crlf.bat
Created Sep 16, 2010
fixing text files to DOS style line endings (CRLF)
View fix_crlf.bat
c:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe fix_crlf.cs
kenegozi / ParallelHttpRequests.cs
Created Mar 15, 2011
Demonstrating the use of WebClient.DownloadStringAsync to parallelize http requests
View ParallelHttpRequests.cs
class ParallelHttpRequests
static void Main()
var count = 300;
var root = "";
ServicePointManager.DefaultConnectionLimit = 1000;
kenegozi / RandomAd.cs
Created Jul 5, 2011
Super dumbed-down ad server - serving a random image every-time.
View RandomAd.cs
using Manos;
using System;
using System.IO;
public class RandomAd : ManosApp {
public RandomAd () {
var ads = Directory.GetFiles(".", "*.gif");
var random = new Random();
Route ("/", ctx=> {
kenegozi / IncludeInterfacesModelMetadataProvider.cs
Created Aug 22, 2011
Allowing MVC3 model validator to use interface attributes
View IncludeInterfacesModelMetadataProvider.cs
class IncludeInterfacesModelMetadataProvider : DataAnnotationsModelMetadataProvider {
protected override IEnumerable<Attribute> FilterAttributes(Type containerType, PropertyDescriptor propertyDescriptor, IEnumerable<Attribute> attributes) {
var validationAttributesOnInterfaces =
from i in containerType.GetInterfaces()
from p in i.GetProperties()
where p.Name == propertyDescriptor.Name
from a in p.GetCustomAttributes(true).Cast<Attribute>()
where typeof(ValidationAttribute).IsAssignableFrom(a.GetType())
select a;
kenegozi / use_inheritance.cs
Created Oct 8, 2011
Pass compositioned data to views
View use_inheritance.cs
// adding GeneralView class with IsCurrentUserAdmin bool field,
// Derive LayoutView from GeneralView
// Derive HomepageView and PostPageView from LayoutView
public ActionResult ViewPost(string permalink) {
var post = magic.GetPostBy(permalink);
var view= new PostView {Post=post};
view.Related = magic.GetContentRelatedTo(post);
Return View(view);
kenegozi / static-latency-logging.cs
Created Jul 22, 2012
Statically logging method call latencies
View static-latency-logging.cs
interface IDoWork {
void DoThis();
string WhatsThat(int that);
class DoWork : IDoWork {
public void DoThis() {
Log.Action("DoWork.DoThis", () => DoThisImpl() );
View javascript-proxying-example.js
var x = {
doThis : function() { console.log('doThis'); },
whatIsThat : function(i) { console.log('whatIsThis'); return 'that is ' + i; },
name : 'I am x'
for (methodName in x) {
var method = x[methodName];
if (typeof method !== 'function') continue;
x[methodName] = (function(method, methodName) {
kenegozi / untyped-mongodb.cs
Created Aug 28, 2012
Accessing mongodb using the official c# driver without types
View untyped-mongodb.cs
using System;
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Driver.Wrappers;
using Newtonsoft.Json;
namespace Mongothingies {
class Program {
static void Main() {
var server = MongoServer.Create();
kenegozi / MobileServices_WindowsPhone.cs
Created Aug 29, 2012
First glance on my unofficial Windows Phone SDK for Azure Mobile Services
View MobileServices_WindowsPhone.cs
// in App.xaml.cs
public partial class App : Application
public static readonly MobileServiceClient MobileServiceClient;
public static User CurrentUser;
static App()
// Get this data from the management portal's quickstart page
// in the 'connect to existing apps' section
kenegozi / GistsResolver.cs
Created Sep 4, 2012
Given a gist embed script tag, get the gist's content
View GistsResolver.cs
public class GistsResolver {
public static string CreateContentForFeedFrom(string content) {
try {
return UnwrapGists(content, GetGist);
catch {
return content;
You can’t perform that action at this time.