Skip to content

Instantly share code, notes, and snippets.

@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"
@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 / 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:

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 / 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"];
@kenegozi
kenegozi / fix_crlf.bat
Created September 16, 2010 09:54
fixing text files to DOS style line endings (CRLF)
c:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe fix_crlf.cs
fix_crlf.exe
@kenegozi
kenegozi / RandomAd.cs
Created July 5, 2011 21:04
Super dumbed-down ad server - serving a random image every-time.
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
kenegozi / use_inheritance.cs
Created October 8, 2011 13:15
Pass compositioned data to views
// 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};
GetLayoutData(view);
view.Related = magic.GetContentRelatedTo(post);
Return View(view);
@kenegozi
kenegozi / javascript-proxying-example.js
Created July 22, 2012 08:47
javascript-proxying-example
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
kenegozi / static-latency-logging.cs
Created July 22, 2012 08:10
Statically logging method call latencies
interface IDoWork {
void DoThis();
string WhatsThat(int that);
}
class DoWork : IDoWork {
public void DoThis() {
Log.Action("DoWork.DoThis", () => DoThisImpl() );
}