Skip to content

Instantly share code, notes, and snippets.

View darrenkopp's full-sized avatar

Darren Kopp darrenkopp

View GitHub Profile
private object ReadList(Type listType, object existingContainer)
{
if (IsDictionary(listType))
{
return ReadDictionary(listType, existingContainer);
}
NewDocument(_reader.ReadInt32());
var isReadonly = false;
var itemType = ListHelper.GetListItemType(listType);
using System;
using System.Collections.Generic;
using System.Linq;
using Autofac;
using Autofac.Builder;
using NServiceBus.ObjectBuilder.Autofac.Internal;
using Autofac.Core;
namespace NServiceBus.ObjectBuilder.Autofac
{
var fs = require('fs'),
sys = require('sys');
fs.readdir('./', function(err, files) {
if (err) {
throw err;
}
sys.puts('callback from files ' + files.length);
return;
var portNum = 8000;
public class HashProvider
{
readonly SHA1Managed Hasher;
public HashProvider()
{
this.Hasher = new SHA1Managed();
}
public string GenerateHash(string data)
{
@darrenkopp
darrenkopp / Resolver.cs
Created November 4, 2010 21:53
resolves assemblies that aren't found
/// <summary>
/// Resolves the timberline assembly.
/// </summary>
/// <param name="fileName">Name of the file.</param>
/// <returns></returns>
private static Assembly ResolveTimberlineAssembly(string fileName)
{
var sharedDirectoryKey = Registry.LocalMachine.GetKey("SOFTWARE").GetKey("Timberline").GetKey("General");
if (sharedDirectoryKey != null)
public class DataTranslator
{
public static Func<IDataRecord, T> CreateTranslator<T>(IDataRecord record)
{
Type targetType = typeof(T);
string cacheKey = string.Format("{0}-Translator", targetType);
var cachedTranslator = WebContextCache.GetItem<Func<IDataRecord, T>>(cacheKey);
if (cachedTranslator != null)
namespace IrbClient
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Remote IRB - type some shit");
using(new Context(2))
using(var socket = new Socket(SocketType.REQ))
@darrenkopp
darrenkopp / hack.sh
Created April 1, 2012 02:41 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@darrenkopp
darrenkopp / Create.cs
Created June 20, 2012 04:14
The creation.cs file has the code that is run on creation. code in update.cs is always run (create/update). The code in save is always run (create/update).
namespace DBI.Synchronization.Processing.ServiceManagement.Tasks
{
internal static class ActivityExtensions
{
internal static SMTask CreateChild(this long parentId, SMWorkOrderTaskTypeEnum type)
{
var parent = SMTaskFactory.Factory.Fetch(parentId);
var child = parent.AddChildTask();
child.TaskType = type;
child.Parent = parent;
@darrenkopp
darrenkopp / DataReaderExtensions.cs
Last active December 14, 2015 01:28
Some handy utilities for dealing with ado.net
public static class DataReaderExtensions
{
public static IEnumerable<T> Stream<T>(this IDbCommand command, Func<IDataRecord, T> converter)
{
using (var reader = command.ExecuteReader(CommandBehavior.SingleResult))
{
while (reader.Read())
yield return converter(reader);
}
}