Skip to content

Instantly share code, notes, and snippets.

View DrSammyD's full-sized avatar

Sam Armstrong DrSammyD

View GitHub Profile
@DrSammyD
DrSammyD / jq.domcallback.coffee
Created March 1, 2013 02:08
jquery plugin that provides a way to notify parents of different types of callbacks defined by the plugin user
(($, window) ->
hasArgs = () -> arguments.length > 0
noArgs = () -> arguments.length == 0
class DomCallbacks
###*
* Defines the jQuery functions to create callbacks for, and which type of callback they contain
* @type {defaults}
* @properties {array of jQuery function names, and test to determine if the callback
* should be run based on input to the jQuery function, passed the same arguments that the jQuery
* function is}
@DrSammyD
DrSammyD / koSelectizeBinding.js
Last active July 6, 2016 13:07
Selectize Binding Handler
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(['knockout','jquery','selectize'], factory);
} else {
var selConstructor = (typeof selectize != "undefined")?selectize:$('<select>').selectize().data('selectize').constructor;
factory(ko,$,selConstructor);
}
})(function (ko,$,selectize) {
@DrSammyD
DrSammyD / underscore.resolveRelink.js
Last active April 23, 2018 11:49
A lodash mixin which will create an object that links and unlinks circular references based on the way json.net handles reference loops. Based on this Stackoverflow answer http://stackoverflow.com/a/21687071/364282
@DrSammyD
DrSammyD / EntityExpressionCopy.cs
Last active February 12, 2019 21:02
An expression generator to deep copy entities from one type to another, preserving reference loops.
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace EntityExpressionCopy
{
@DrSammyD
DrSammyD / 0-Confirmation-Double-Spend-Protocol.md
Last active January 30, 2022 00:06
A double-spend protocol to make 0-confirmation transactions secured by consensus rules.

0-Confirmation Double-Spend Protocol

The problem

Bitcoin-accepting merchants want to receive payment and provide services instantly. However, block construction times can be as much as 10 minutes after the moment a bitcoin transaction is broadcast. In the time after a transaction but before a block’s creation, that transaction can be superseded by another transaction with a larger fee paid to miners.

With the change in the mempool protocol from first-seen-first-included and the rejection of conflicting double spends, to the inclusion of double spends and prioritizing transactions with larger fees attached, 0-conf transactions can no longer be reasonably secure for any sized transaction.

The idea of replace-by-fee was that miners will follow their immediate self-interest, and if miners sporadically act that way, could potentially decrease trust in the system. Now that this approach has been assumed and is the default behavior of miner software, we might consider amending t