Skip to content

Instantly share code, notes, and snippets.

@tophtucker
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 (https://keybase.io/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
tophtucker / stateface-mapping.js
Created October 15, 2014 14:54
Stateface mapping from full state name to letter
// cf. http://propublica.github.io/stateface/
var statefaceMap = {"Alaska":"A","Arizona":"D","Arkansas":"C","California":"E",
"Colorado":"F","Connecticut":"G","Delaware":"H","Florida":"I","Georgia":"J",
"Hawaii":"K","Idaho":"M","Illinois":"N","Indiana":"O","Iowa":"L","Kansas":"P",
"Kentucky":"Q","Louisiana":"R","Maine":"U","Maryland":"T","Massachusetts":"S",
"Michigan":"V","Minnesota":"W","Mississippi":"Y","Missouri":"X","Montana":"Z",
"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
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()
.domain(padDomain(domain))
.range([0, 0, 1, 1])
.clamp(true);
@tophtucker
tophtucker / README.md
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
tophtucker / README.md
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.

1. HTML

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
tophtucker / README.md
Last active May 12, 2016 04:03 — forked from mbostock/.block
Survivor with Seth performance

Survivor with Seth III auction performance

@tophtucker
tophtucker / README.md
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 boxofficemojo.com. CPI from inflationdata.com.