Skip to content

Instantly share code, notes, and snippets.

@alexrudy
alexrudy / matplotlib-fonts-osx.md
Last active July 12, 2022 13:16
Adding custom fonts to Matplotlib on OS X

How to add custom (or system) fonts to matplotlib on OS X

Matplotlib expects to find .ttf fonts on your system. Newer versions of OS X use .dfont files. Converting them is easy, and putting them in a proper font path is also easy. The user font path on OS X is ~/Library/Fonts/, and matplotlib will find fonts here.

  1. First, install what you'll need:
  • matplotlib
  • fondu (port install fondu, or brew install fondu)
  1. Then find your desired font file. For system font files, the easiest way to do this is in the FontBook application. You can open FontBook in your utlities folder. Then select your font of choice, right click on it, and select "Show in Finder". You'll need to know where it is. Many system fonts are in places like /System/Library/Fonts/...
  2. Move to your user's font directory ~/Library/Fonts/.
  3. Use fondu to convert the OS-X specific font file (ends with .dfont) to .ttf.
@non
non / answer.md
Last active January 9, 2024 22:06
answer @nuttycom

What is the appeal of dynamically-typed languages?

Kris Nuttycombe asks:

I genuinely wish I understood the appeal of unityped languages better. Can someone who really knows both well-typed and unityped explain?

I think the terms well-typed and unityped are a bit of question-begging here (you might as well say good-typed versus bad-typed), so instead I will say statically-typed and dynamically-typed.

I'm going to approach this article using Scala to stand-in for static typing and Python for dynamic typing. I feel like I am credibly proficient both languages: I don't currently write a lot of Python, but I still have affection for the language, and have probably written hundreds of thousands of lines of Python code over the years.

@Wilto
Wilto / thanks.md
Last active August 29, 2015 14:02

Let’s leave aside, for now, the fact that you’ve changed web standards. You’ve been a participant in the first time—in the history of the web, far as I know—that the web development community has taken a feature from an initial proposal to the funding of an honest-to-God native implementation.

Instead, I want you to focus on this: say only ten developers use a native responsive images solution to reduce the weight of just one page apeice by only 500kb, and each of those pages has a barely-significant 5,000 hits per month: those users have been saved almost 24GB of data. A thousand pages saving 500kb apeice, and we’ve saved users an entire terabyte in a month. Now expand that to the entire industry: every web developer; every hit on every page that would otherwise carry with it a huge, wasteful image request, saving megabytes at a time. To those users, the only change is that the web is faster, less expensive, more accessible. For those users, the web is just better.

In helping make the picture element

@cmeiklejohn
cmeiklejohn / gist:8346377
Last active January 2, 2016 18:49
Think Distributed Systems Summer School; Providence, RI
Think Distributed Systems Summer School
Providence, RI
Curriculum
Friday (night session, open discussion)
* Background, introductions
* What are you working on in distributed systems?
* Lightning talks on research or open problems

On the relative value of startup stock

How do you compare the potential value of different stage companies? And as a company progresses what is the appropriate amount of stock to give new employees?

Using data from Crunchbase and Yahoo Finance we can calculate the average value created per company broken down by how much money they have raised. From this we can then compute relative returns at the different stages, e.g. $1M raised, $10M, $100M, etc.

tl;dr

For this exercise we'll calibrate relative to expected return from a company that's raised $1M.

aphyr@waterhouse:~/timelike master$ lein test timelike.node-test
lein test timelike.node-test
Even connections LB
Total reqs: 10000
Latency distribution:
Min: 0.017489419380090965
Median: 141.4027252436847
95th %: 612.7774737814785
99th %: 937.1806417316121
@lukego
lukego / gist:4706097
Last active December 12, 2015 03:19
Table data structure that "garbage collects" not-recently-used items in O(1) time

I use this data structure all the time. Can someone leave a comment and tell me what it's called?

  1. insert(k,v): add a new value
  2. lookup(k): lookup an existing value
  3. age(): delete old entries (that have not been used since previous call to age())
# Initialize 'old' and 'new' to empty tables
local old, new = {}, {}
public final static RuntimeException ᚇ = new RuntimeException("┻━┻");
public void ノಠ益ಠノ彡(RuntimeException t) { throw t; }
public void ノಠ益ಠノ彡(Throwable t) { throw new RuntimeException(t); }
public int hashCode() {
ノಠ益ಠノ彡(ᚇ);
return 0;
}
@mrflip
mrflip / maximum_battery_life.md
Created March 19, 2012 08:32
maximum battery life checklist -- use before a long plane flight

Max Battery Life Checklist

Here is a checklist to follow if you want maximum battery life -- for instance if you're about to get on a long plane flight.

10 hour battery life on a non-SSD Macbook Pro 17"

Low power use checklist

With power connected:

cscotta@ordasity:~/Desktop$ scala -cp mongo-2.7.0.jar Repro.scala
Inserting canary...
Inserting test data...
Paging through records...
Spotted the canary!
Updating canary object...
Spotted the canary!
Whoops, shipped the same order multiple times!
cscotta@ordasity:~/Desktop$