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
kenegozi / XunitConsoleForwarder.cs
Created Jun 25, 2017
Capturing console output in Xunit 2 tests
View XunitConsoleForwarder.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Xunit.Abstractions;
namespace MagicalUnicorns {
public class XunitConsoleForwarder : TextWriter {
private readonly ITestOutputHelper output;
@kenegozi
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 = "http://files.kenegozi.com/temp/";
ServicePointManager.DefaultConnectionLimit = 1000;
@kenegozi
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;
View humitemp1.ino
// Humidity and temperature monitor
// for Arduino UNO R3 (and probably most others)
// Main pieces:
// DHT11 humidity/temp sensor
// - mandatory 10k pull-up resistor
// -> using DHT.f by adafruit at https://github.com/adafruit/DHT-sensor-library
// 16x2 LCD
// - 10K potentiometer for contrast control
// - Push button and transistor for backlight control
// - 220ohm resistor to make the backlight a bit darker
@kenegozi
kenegozi / EditMyMobileServiceDataWithExcel.cs
Created Sep 7, 2012
Editing Azure Mobile Service data using Excel
View EditMyMobileServiceDataWithExcel.cs
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Windows.Forms;
using Microsoft.Office.Core;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Excel = Microsoft.Office.Interop.Excel;
@kenegozi
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;
}
}
@kenegozi
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
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
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) {
You can’t perform that action at this time.