Skip to content

Instantly share code, notes, and snippets.

jammycakes / deps.js
Created Feb 28, 2012
Node.js script to install dependencies using npm
View deps.js
var child_process = require('child_process');
function install(modules, callback) {
if (modules.length == 0) {
if (callback) callback(null);
var module = modules.shift();
'npm install ' + module,
jammycakes /
Created May 27, 2012
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
( up to an asymptotic
jammycakes / LazyDisposable.cs
Last active Oct 9, 2021
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.
View LazyDisposable.cs
/// <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 / namespace.js
Last active Dec 19, 2015
Provides the ability to define namespaces in JavaScript.
View namespace.js
/* ====== namespace.js ====== */
// Provides the ability to define namespaces in JavaScript.
* Declares a namespace in JavaScript.
* This function can be called in one of two ways:
* namespace(ns, obj)
jammycakes / dropall.sql
Created Mar 26, 2014
A script to drop all objects from a SQL Server database
View dropall.sql
declare @name varchar(100)
declare @table varchar(100)
-- Drop all foreign key constraints: this goes through alter table
declare c cursor for
select as [constraint], as [table] from dbo.sysobjects a
inner join dbo.sysobjects b on a.parent_obj =
where a.xtype='F' and b.xtype='U'
open c
jammycakes / gist:f7138a3ae6b916dfbfed
Last active Jun 29, 2019
Find the MSBuild executable in a PowerShell script and run a build script in the same directory
View gist:f7138a3ae6b916dfbfed
$msbuild = (Get-ItemProperty hklm:\software\Microsoft\MSBuild\ToolsVersions\4.0).MSBuildToolsPath
$MyDir = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)
. "$msbuild\msbuild.exe" "$MyDir\build.proj"
jammycakes / .bashrc
Created Sep 15, 2016
Bash command to open a program in a new window, detached from the console. Run dos <your command>
View .bashrc
#! /bin/bash
function run_disowned() {
"$@" & disown
function dos() {
run_disowned "$@" 1>/dev/null 2>/dev/null

Keybase proof

I hereby claim:

  • I am jammycakes on github.
  • I am jammycakes ( on keybase.
  • I have a public key whose fingerprint is 6C63 B606 EAF0 B758 4630 DE32 9177 2E70 1B9D C839

To claim this, I am signing this object:

jammycakes /
Last active Feb 22, 2017
A snippet of code to detect the path to the current script. Works in bash and zsh.

This snippet detects various information about the shell script in which it is being executed. Copy and paste it into the top of your script.

Variables set are as follows:

  • $__SHELL: bash or zsh
  • $__SOURCED: true if the file was invoked using source filename or . filename, otherwise it will be blank.
  • $__SCRIPT_PATH: the full absolute path to the script.
  • $__SCRIPT_DIR: the full absolute path to the script's directory.
jammycakes /
Created Nov 3, 2017 — forked from Eyjafjallajokull/
AWS EBS - Find unused snapshots - this script generates csv raport about snapshot usage
import re
import boto3
import csv
from botocore.exceptions import ClientError
ec2 = boto3.client('ec2')
def get_snapshots():
return ec2.describe_snapshots(OwnerIds=['self'])['Snapshots']