Skip to content

Instantly share code, notes, and snippets.

View jakesays-old's full-sized avatar

Big Jake jakesays-old

View GitHub Profile
public class StickyEnumerable<T> : IEnumerable<T>, IDisposable
{
private IEnumerator<T> innerEnumerator;
public StickyEnumerable( IEnumerable<T> items )
{
innerEnumerator = items.GetEnumerator();
}
public IEnumerator<T> GetEnumerator()
@jakesays-old
jakesays-old / GuardedReaderWriterLock.cs
Last active December 21, 2015 16:29
Reader/writer lock with auto guard support
using System;
using System.Threading;
/// <summary>
/// Simple ReaderWriterLockShim wrapper that exposes read and write
/// guards.
/// </summary>
public class GuardedReaderWriterLock
{
@jakesays-old
jakesays-old / ObjectExtensions.cs
Last active December 26, 2015 01:19
Extension method to estimate the size of an object
using System;
using System.Collections;
using System.Linq;
using System.Reflection;
namespace WayCoolThings
{
public static class ObjectExtensions
{
@jakesays-old
jakesays-old / SuperQueue.cs
Created October 29, 2013 05:09
SuperQueue
void Main()
{
}
// Define other methods and classes here
public class SuperQueue<TElement>
{
private Queue<TElement> _queue1 = new Queue<TElement>();
private Queue<TElement> _queue2 = new Queue<TElement>();
struct Bar
{
public ushort One;
public ushort Two;
}
class Foo
{
private Bar _thing;
using System.IO;
using System.Net;
using System.Reflection;
using JetBrains.Annotations;
namespace Foo.Utility.Process
{
public static class ProcessHelpers
{
<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
#core_card {
position: absolute;
width: 300px;
height: 300px;
using System;
using System.Threading;
namespace Models.Common.Internal
{
public class ReadOnlyState
{
public bool IsReadOnly { get; set; }
}
@jakesays-old
jakesays-old / gist:ad521c9af8650f3b39d0
Created August 27, 2014 14:50
DateTime abstraction
using System;
using System.Diagnostics;
using Apex.Utility.Internal;
namespace Utility
{
/// <summary>
/// The SystemTime class provides a simple abstraction over DateTime.Now.
/// It uses a time provider to generate the current time. The default
@jakesays-old
jakesays-old / gist:9107987b882a3a3933e2
Created September 6, 2014 18:43
Using IKVM.Reflection to obtain an assembly's version
private static string GetVersionFromAssembly(byte[] fileData, string fileName)
{
var reflector = new Universe();
AssemblyName name = null;
using (var fileStream = new MemoryStream(fileData))
{
var module = reflector.OpenRawModule(fileStream, fileName);
if (module == null)
{