Skip to content

Instantly share code, notes, and snippets.

tophtucker / excelmacros
Created March 5, 2014 17:57
Excel macros
Function HLink(rng As Range) As String
'extract URL from hyperlink
'posted by Rick Rothstein
If rng(1).Hyperlinks.Count Then HLink = rng.Hyperlinks(1).Address
End Function

Keybase proof

I hereby claim:

  • I am tophtucker on github.
  • I am tophtucker ( on keybase.
  • I have a public key whose fingerprint is 38F8 35B0 0FC4 9A0D 6D74 733D B96E A5CF 4410 BBA5

To claim this, I am signing this object:

Page Highlighters Quotation
1 3312 When the rate of return on capital exceeds the rate of growth of output and income, as it did in the nineteenth century and seems quite likely to do again in the twenty-first, capitalism automatically generates arbitrary and unsustainable inequalities that radically undermine the meritocratic values on which democratic societies are based.
10 1807 Like his predecessors, Marx totally neglected the possibility of durable technological progress and steadily increasing productivity, which is a force that can to some extent serve as a counterweight to the process of accumulation and concentration of private capital.
15 1817 The sharp reduction in income inequality that we observe in almost all the rich countries between 1914 and 1945 was due above all to the world wars and the violent economic and political shocks they entailed (especially for people with large fortunes). It had little to do with the tranquil process of intersectoral mobility described by Kuznets.
19 1552 Inequal
tophtucker / stateface-mapping.js
Created October 15, 2014 14:54
Stateface mapping from full state name to letter
// cf.
var statefaceMap = {"Alaska":"A","Arizona":"D","Arkansas":"C","California":"E",
"Nebraska":"c","Nevada":"g","New Hampshire":"d","New Jersey":"e",
"New Mexico":"f","New York":"h","North Carolina":"a","North Dakota":"b",
"Ohio":"i","Oklahoma":"j","Oregon":"k","Pennsylvania":"l","Rhode Island":"m",
"South Carolina":"n","South Dakota":"o","Tennessee":"p","Texas":"q",
tophtucker / elasticScale.js
Created February 3, 2015 02:58
D3 elastic scale closure
// a wrapper around d3's linear scale;
// extreme inputs (outside domain) push the domain while maintaining a fixed extent
function elasticScale() {
var sensitivity = 27,
origin = 0,
domain = [origin - sensitivity/2, origin + sensitivity/2],
scale = d3.scale.linear()
.range([0, 0, 1, 1])
tophtucker /
Last active September 23, 2015 19:25
Earth orbit

Click to fast-forward. Based on the math here. No guarantees of accuracy, this is not legal advice. Made in honor of Pi Day — which I think is borderline numerology, a random and arbitrary mapping, but I respect the ability to create meaning in life ex nihilo.

tophtucker /
Last active August 29, 2015 14:19
Arrow connector helper

It is conceivable that one might want a setup whereby someone can arrange a Web Page such that certain things point to certain other things without writing any javascript or a ton of custom css or whatever. This is a solution.


In the data-arrow-target attribute of an HTML element, provide a CSS selector. If the selector matches more than one element, lines will be drawn from the element to all the matching elements.

E.g.: <div id="one" data-arrow-target="#two"></div>

2. JavaScript

function drawGCD(){
var stack = []
var a = 960 - Math.floor(Math.random()*100), b = 400 + Math.floor(Math.random()*100)
function gcd(u, v){
stack.push({u: u, v: v})
return v ? gcd(v, u % v) : u
tophtucker /
Last active May 12, 2016 04:03 — forked from mbostock/.block
Survivor with Seth performance

Survivor with Seth III auction performance

tophtucker /
Last active May 24, 2019 01:38
Inflation adjuster

On blur, bar heights represent nominal dollars, and bar areas represent real dollars. Mousemoves along the date axis normalizes width, forcing height to represent real dollars.

Bar chart based on mbostock/3885304. Box office data from CPI from