Skip to content

Instantly share code, notes, and snippets.

@kenegozi
kenegozi / XunitConsoleForwarder.cs
Created June 25, 2017 22:35
Capturing console output in Xunit 2 tests
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 / EnvThenConfigSettings.cs
Created June 1, 2015 18:05
Env based appSettings overrides, plus DictionaryAdapter fun
using System;
using System.Configuration;
using System.Collections;
using Castle.Components.DictionaryAdapter;
namespace Demo {
class MainClass {
public static void Main (string[] args) {
var ageString = (string)ConfigurationManager.AppSettings ["Age"];
private func validateInputs() -> Bool {
let nonEmpty = {
(data:String!) -> Bool in
return count(data) != 0
}
func inRange (min: Int!, max:Int!) -> (String!) -> Bool {
return { (data:String!) -> Bool in
let dataAsInt = data.toInt()
return (dataAsInt! >= min && dataAsInt! <= max)
@kenegozi
kenegozi / keybase.md
Created May 27, 2015 18:21
keybase.md

Keybase proof

I hereby claim:

  • I am kenegozi on github.
  • I am kenegozi (https://keybase.io/kenegozi) on keybase.
  • I have a public key whose fingerprint is 4233 DAB9 6173 B1E4 E3D0 6263 B290 B45A ABB9 35CD

To claim this, I am signing this object:

@kenegozi
kenegozi / SimpleChannelPatterns.cs
Created January 16, 2015 07:03
Mimicking some of the samples from the talk "Go Concurrency Patterns" in c# (slides at https://talks.golang.org/2012/concurrency.slide#1) , to help illustrate the GO Channel concept to C# developers.
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
namespace GoPatterns
{
class Program
{
static void Main()
@kenegozi
kenegozi / applicationhost
Created December 20, 2014 05:33
fcgi playground
<add name="fcgi-golang" path="*.go" verb="*" modules="FastCgiModule" scriptProcessor="c:\w\playground\go-iis\std.exe" resourceType="Either" requireAccess="Read" />
<fastCgi>
<application fullPath="c:\w\playground\go-iis\std.exe"
arguments=""
maxInstances="1"
idleTimeout="300"
activityTimeout="30"
requestTimeout="90"
// 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 September 7, 2012 07:06
Editing Azure Mobile Service data using Excel
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 September 4, 2012 07:03
Given a gist embed script tag, get the gist's content
public class GistsResolver {
public static string CreateContentForFeedFrom(string content) {
try {
return UnwrapGists(content, GetGist);
}
catch {
return content;
}
}
@kenegozi
kenegozi / MobileServices_WindowsPhone.cs
Created August 29, 2012 00:38
First glance on my unofficial Windows Phone SDK for Azure Mobile Services
// 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