Skip to content

Instantly share code, notes, and snippets.

View WardCunningham's full-sized avatar

Ward Cunningham WardCunningham

  • Cunningham & Cunningham, Inc.
  • Portland, Oregon
View GitHub Profile
// Copyright (c) 2003 Cunningham & Cunningham, Inc.
// Read license.txt in this directory.
package Code;
public class Code {
static protected StringBuffer emited;
public void run (State s) {};
@WardCunningham
WardCunningham / ReadMe.md
Last active September 25, 2016 17:56 — forked from mbostock/.block
Web Traffic

We start with Bostock's Multi-Foci Force Layout example and add motion to represent traffic progressing through a system. Think of this as progress bars for every inflight transaction.

Each dot represents a transaction read from a four-minute long recording. Watch for a spike in activity at 20:20 after the hour. The animation repeats when finished.

Dots enter when transactions start and exit when completed. Their speed is proportional to client's response time while their size reflects the server's contribution to total time. Color comes from the specific request.

@WardCunningham
WardCunningham / ReadMe.md
Last active December 19, 2015 03:59
Push Pins

We simulate push-pins marking locations on a map. We use Force layout to position the pins as close to where they belong as possible. This may not be very close in geographic terms. However, the energy minimizing placement looks sensible on maps of large regions with densely clustered locations.

@WardCunningham
WardCunningham / ReadMe.md
Last active December 19, 2015 05:29
Crossword

Wiki appears as a word in the New York Times crossword on June 30, 2013. Thanks to David DiNucci for bringing this to my attention and to Bill Butler for posting the puzzle with explanation.

See also my correspondence on the etymology of wiki.

@WardCunningham
WardCunningham / gist:8265495
Created January 5, 2014 07:30
Squeeze a federated wiki page by replacing a huge image with a smaller copy
# replace an image with a much smaller one
# work in localhost, then post with scp
# scp pages/degrees-of-publicness fed.wiki.org:wiki/farm-8080/data/farm/mehaffy.fed.wiki.org/pages/
fs = require 'fs'
destFileName = '../pages/degrees-of-publicness'
# find source image
source = JSON.parse fs.readFileSync '../pages/scratch', 'utf-8'
images = (item for item in source.story when item.type is 'image')
@WardCunningham
WardCunningham / cross-ref.coffee
Created January 5, 2014 19:43
Visualize the possible flows of variables within Method plugins in a Federated Wiki site.
# scan all methods of all pages for variables
# create a graphviz dot file maping cross-references
# scp -r fed.wiki.org:farm/mehaffy.fed.wiki.org/pages pages
# coffee cross-ref.coffee
# graphviz cross-ref.dot
fs = require 'fs'
@WardCunningham
WardCunningham / mkplugin.sh
Last active January 22, 2017 23:02
Script to create a stub plugin with stub documentation
#!/bin/sh
# Script to create a stub plugin with build script, tests and documentation.
# See http://plugins.fed.wiki.org/make-plugin-script.html
# Usage: ./mkplugin.sh CoolThing
if [ $# -eq 0 ]
then
echo "Usage: ./mkplugin.sh <new-plugin-name>"
@WardCunningham
WardCunningham / FloatPrecisionTest.cc
Last active August 29, 2015 14:02
Reliable Representation of Integers in Floats
#include <iostream>
int main() {
int n = 0;
for (long w=1; w<=10000000000000L; w*=10) {
int k = 0;
for (int i=0; i<1000000; i++) {
long p = (long)(rand()%w);
long q = (float) p;
if (p != q) k++;
@WardCunningham
WardCunningham / utime.rb
Created October 21, 2014 14:18
Restore dates lost copying wiki pages
# This script reads all pages in a repository and sets each file's last modification date
# based on dates found in the Journal.
require 'json'
early = 1335324580000
Dir.glob('../pages/*') do |path|
File.open(path) do |file|
page = JSON.parse file.read
epoch = page['journal'].last['date'] || early
@WardCunningham
WardCunningham / cloneAll.sh
Last active August 29, 2015 14:11
Clone and Search all FedWiki Plugins
# make a fresh clone of all plugin repos
rm -rf all
mkdir all
for i in `sh listPlugins.sh`
do (cd all; git clone [email protected]:fedwiki/$i.git)&
done