Skip to content

Instantly share code, notes, and snippets.

@jammycakes
jammycakes / LazyDisposable.cs
Last active December 26, 2022 22:31
A subclass of System.Lazy<T> that implements IDisposable and forwards calls to the Dispose method on to the lazily created instance if it exists.
/// <summary>
/// A <see cref="Lazy"/> object that implements <see cref="IDisposable"/>.
/// </summary>
/// <typeparam name="T">
/// The object being lazily created.
/// </typeparam>
public class LazyDisposable<T> : Lazy<T>, IDisposable where T: IDisposable
{
/// <summary>
@jammycakes
jammycakes / gitpredict.py
Created May 27, 2012 21:35
A script to attempt to predict how Git's popularity will increase over the next few years.
import math
import scipy.optimize
'''
This script attempts to predict how Git's popularity will increase
over the next few years by extrapolating the results of the annual
Eclipse Community Survey.
The forecast assumes that Git adoption is following an S-curve
(http://en.wikipedia.org/wiki/Sigmoid_function) up to an asymptotic
@jammycakes
jammycakes / deps.js
Created February 28, 2012 00:59
Node.js script to install dependencies using npm
var child_process = require('child_process');
function install(modules, callback) {
if (modules.length == 0) {
if (callback) callback(null);
return;
}
var module = modules.shift();
child_process.exec(
'npm install ' + module,