Skip to content

Instantly share code, notes, and snippets.

View excelmacros
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:

View piketty.tsv
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 Oct 15, 2014
Stateface mapping from full state name to letter
View stateface-mapping.js
// 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 Feb 3, 2015
D3 elastic scale closure
View elasticScale.js
// 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 Aug 29, 2015
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

View gcd.js
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 / index.html
Last active Aug 29, 2015
Nested list columns
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
ul {
list-style-type: none; /* no bullets */
padding-left: 0; /* no spacing on left */
li {
clear: both; /* start a new line, kinda */

Factoring out the geometric background part of the opener for this Bloomberg Businessweek story on ketamine. Move your mouse left and right to change the speed. Move your mouse up and down to change the amplitude.

Text can be overlaid with the query string variable text, e.g.

It's a bunch of concentric circles with exclusion compositing. The radius of the ith circle oscillates with amplitude * Math.sin(t/speed + (t/10000)*i), where t is the number of milliseconds since you loaded the page.

E.g., for amplitude = 5 and speed = 500 (which is the default if you position your mouse in the middle of the page), the radius of circle i at time t oscillates with period (20000π)/(20+i) in t ([WolframAlpha](*sin%28t%2F500+%2B+%28t%2F10000%29*i%


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.