Skip to content

Instantly share code, notes, and snippets.

View d2fn's full-sized avatar
🐢

Dietrich Featherston d2fn

🐢
View GitHub Profile
@d2fn
d2fn / man-eating-cats_haruki-murakumi_en.md
Last active November 2, 2023 23:47 — forked from thoward/man-eating-cats_haruki-murakumi_en.md
Man Eating Cats, Haruki Murakami

Man-Eating-Cats

by Haruki Murakami
Translated by Philip Gabriel

Source

I bought a newspaper at the harbor and came across an article about an old woman who had been eaten by cats. She was seventy years old and lived alone in a small suburb of Athens -- a quiet sort of life, just her and her three cats in a small one-room apartment. One day, she suddenly keeled over face down on the sofa -- a heart attack, most likely. Nobody knew how long it had taken for her to die after she collapsed. The old woman didn't have any relatives or friends who visited her regularly, and it was a week before her body was discovered. The windows and door were closed, and the cats were trapped. There wasn't any food in the apartment. Granted, there was probably something in the fridge, but cats haven't evolved to the point where they can open refrigerators. On the verge of starvation, they were forced to devour their owner's flesh.

I read this articl

@d2fn
d2fn / README.md
Last active March 11, 2021 12:41
Perlin Curves I

Curves drawn by randomly placing actors on the canvas, and walking them in a direction determined by the perlin noise function at their location. The continuity of the underlying noise function causes paths to converge together.

@d2fn
d2fn / hemingway-happiness.md
Last active December 14, 2015 11:28
Happiness in intelligent people is the rarest thing I know

Happiness in intelligent people is the rarest thing I know.- Ernest Hemingway, author and journalist, Nobel laureate (1899-1961)

Hemingway, who took his own life in 1961, knew his share of both intelligent people and of unhappiness. He lived through two world wars, the Great Depression, four wives and an unknown number of failed romantic relationships, none of which would help him to develop happiness if he knew how.

As Hemingway's quote was based on his life experience, I will base the following speculation on both my personal and my professional experience as a sociologist. Not enough study exists to quote on this subject.

Western society is not set up to nurture intelligent children and adults, the way it dotes over athletes and sports figures, especially the outstanding ones. While we have the odd notable personality such as Albert Einstein, we also have many extremely intelligent people working in occupations that are considered among the lowliest, as may be attested by a review of the membership list

@d2fn
d2fn / gist:834627
Created February 18, 2011 23:50
bitsets, use them for everything!
import euler.Functions._
import scala.math._
val q = "What is the smallest positive " +
"number that is evenly divisible by " +
"all of the numbers from 1 to 20?"
def hasDivisors(n:Long, divisors:Seq[Long]) = {
divisors.filter(n%_ > 0).isEmpty
}
@d2fn
d2fn / equalSizeBins.erl
Created February 14, 2011 07:03
partition set of numbers into subsets of equal size
% produce a list, the elements of which are each lists of
% length 'Depth' of less forming sorted, equally sized bins
% of the numeric input list L
% the last bin will be of size (Depth rem length(L))
equal_size_bins (L,Depth) ->
[tuple_to_list(X) || X <- equal_size_bins_sorted(lists:sort(L),Depth)].
equal_size_bins_sorted (L,Depth)
when Depth >= length(L)
-> [list_to_tuple(L)];
@d2fn
d2fn / equibin.scala
Created October 1, 2010 03:28
partition set of numbers into subsets of equal size
def equibin(a:Seq[Double], depth:Int) = {
val d = a.size/depth
(0 until a.size) // ordered set of indexes of all values
.groupBy(i=>i/d).values.toList.sortBy(s=>s(0)) // split set into 'd' separate lists
.map { group => group.map( i => a(i) ) } // map onto value set
.map { values => ( (min(a),max(a)), values ) }// each bin gets min-max metadata
}

Keybase proof

I hereby claim:

  • I am d2fn on github.
  • I am d2fn (https://keybase.io/d2fn) on keybase.
  • I have a public key whose fingerprint is 9B44 A7D0 3783 FD03 570C 89FC AFEC 18F7 30BD 71C8

To claim this, I am signing this object:

@d2fn
d2fn / topk.py
Last active August 29, 2015 14:17
Bucketed top-k in Python using heap-ordered arrays
#!/usr/bin/env python
"""
Usage: topk [key-column-name] [score-column-name]
Reads tsv rows, including a header row, from stdin.
Writes to stdout the top 10 rows per distinct value of the given key column.
Author Dietrich Featherston
"""
@d2fn
d2fn / fr.csv
Last active August 29, 2015 14:04
Global Fossil Record I
We can't make this file beautiful and searchable because it's too large.
family,kingdom,phylum,classname,habitat,hadean precambrian,isuan,swazian,randian,huronian,animakean,riphean,sturtian,vendian,caerfai cambrian palaeozoic,st david's,merioneth,tremadoc ordovician,arenig,llanvirn,llandeilo,caradoc,ashgill,llandovery silurian,wenlock,ludlow,pridoli,lochkovian devonian,pragian,emsian,eifelian,givetian,frasnian,famennian,tournaisian carboniferous,visean,serpukhovian,bashkirian,moscovian,kasimovian,gzelian,asselian permian,sakmarian,artinskian,kungurian,ufimian,kazanian,tatarian,scythian triassic mesozoic,anisian,ladinian,carnian,norian,rhaetian,hettangian jurassic,sinemurian,pliensbachian,toarcian,aalenian,bajocian,bathonian,callovian,oxfordian,kimmeridgian,portlandian,berriasian cretaceous,valanginian,hauterivian,barremian,aptian,albian,cenomanian,turonian,coniacian,santonian,campanian,maastrichtian,danian palaeogene cainozoic,thanetian,ypresian,lutetian,bartonian,priabonian,rupelian,chattian,lower miocene neogene,middle miocene,upper miocene,pliocene,pleistocene quaternary,holoce
@d2fn
d2fn / README.md
Last active August 29, 2015 14:04
Perlin Curves II

Each curve follows 2d perlin space at a different, but nearby, z axis. The result is the appearance of topology as curves expose gradients in noise function.