Skip to content

Instantly share code, notes, and snippets.


R. Dunbar Poor rdpoor

View GitHub Profile
rdpoor / association.js
Created Mar 22, 2020
Efficiently maintain source => target associations.
View association.js
// Efficiently maintain source => target associations.
// R. Dunbar Poor - March 2020
var Association = function() {
this._links_by_source = new Map();
this._links_by_target = new Map();
* @brief Clear all associations
rdpoor /
Last active Aug 2, 2017
Minimal, Complete (within reason) and Verifiable example for

Demonstration of "p5.serialserver leaking memory"

This gist contains the files to demonstrate the problem described in p5.serialserver leaking memory.


Run the Arduino code

To run this, you'll need an "Arduino-like device" with a USB port capable of generating

rdpoor / .block
Last active Apr 10, 2019 — forked from mbostock/.block
Modifying a Force Layout (with comments)
View .block
license: gpl-3.0
View gist:dc7064c15d12f03e0207a897304ab553
// Walk a tree using Promises, where the act of fetching a node is asynchronous.
// This version visits the nodes in the expected order and returns a promise that
// is resolved when the last node is visited. (If you're here from the StackOverflow
// post, the original error was a missing return statement in the call to map())
"use strict";
var family_tree = {
"pops" : { name: "pops", children: ["chuck", "george", "pete"]},
rdpoor / gist:5249186
Last active Dec 15, 2015
compilation failure of ruby-2.0.0-p0 under Mac OS X 10.8.3
View gist:5249186
Summary: a "standard build" of ruby-2.0.0-p0 under Mac OS X 10.8.3,
fails with an abort trap while linking miniruby
Compilation environment:
MacBook Pro
OS X 10.8.3
Xcode version 4.6.1 with command line tools
gcc version 4.2.1 (Based on Apple Inc. build 5658)
rdpoor / address_sequence.rb
Created Mar 1, 2013
Generate a sequence of fictitious US street addresses for FactoryGirl
View address_sequence.rb
FactoryGirl.define do
# generate a sequence of fake US street addresses, such as:
# 1001 Birch Boulevard, Clinton AK 52574, USA
sequence :address do |n|
# NB: the length of street_name, street_type, city, state arrays
# are all chosen to be relatively prime to generate maximal
# length sequences
street_number = 1000 + n
street_name = %w(Aspen Birch Cedar Dogwood Elm Ginkgo Hickory Ironwood
rdpoor / name_sequence.rb
Last active Dec 14, 2015
Generate a sequence of fictitious names (first_name last_name) for FactoryGirl
View name_sequence.rb
FactoryGirl.define do
# Generate a fake name by composing a first and last name. Names
# taken from recent US Census lists.
sequence :name do |n|
first_names = %w( Aaron Abby Abdul Abe Abel Abigail Abraham Abram
Ada Adalberto Adam Adan Addie Adela Adele Adeline Adolfo Adolph
Adrian Adriana Adrienne Agnes Agustin Ahmad Ahmed Aida Aileen
Aimee Aisha Al Alan Alana Alba Albert Alberta Alberto Alden Aldo
rdpoor / greenbutton.xml
Created Jan 18, 2013
Benchmarking data for nokogiri's #xpath method. Test using: doc = {|f| Nokogiri::XML(f) } recs = doc.xpath('//meter:IntervalBlock//meter:IntervalReading', 'meter' => "") After it returns, recs.size should == 8759
View greenbutton.xml
This file has been truncated, but you can view the full file.
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='SDGE_Greenbutton_Style.xslt'?>
<feed xmlns="" xsi:schemaLocation=" espi.xsd" xmlns:xsi="">
<title>Green Button Export</title>
<title>123 MAIN STREET, ANYTOWN, USA</title>
rdpoor / datetime_bug results
Created Jun 21, 2012
Demonstration of bug in DateTime#to_formatted_s(:rfc822)
View datetime_bug results
load '../sketches/datetime_bug.rb'
-- create_table(:test_records, {:force=>true})
NOTICE: CREATE TABLE will create implicit sequence "test_records_id_seq" for serial column ""
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test_records_pkey" for table "test_records"
 (237.7ms) CREATE TABLE "test_records" ("id" serial primary key, "f_datetime" timestamp) 
-> 0.3416s
 (0.3ms) BEGIN
SQL (39.4ms) INSERT INTO "test_records" ("f_datetime") VALUES ($1) RETURNING "id" [["f_datetime", Wed, 14 Sep 0763 00:00:00 UTC +00:00]]
 (0.8ms) COMMIT
DateTimeBug::TestRecord Load (0.5ms) SELECT "test_records".* FROM "test_records" LIMIT 1