Skip to content

Instantly share code, notes, and snippets.

@yangchenyun
yangchenyun / fetch_kindle.js
Last active February 19, 2023 10:10
Get back my books from Kindle
/*
* @fileoverview Program to free the content in kindle books as plain HTML.
*
* This is largely based on reverse engineering kindle cloud app
* (https://read.amazon.com) to read book data from webSQL.
*
* Access to kindle library is required to download this book.
*/
// The Kindle Compression Module copied from http://read.amazon.com application

Explaining Miles's Magic

Miles Sabin recently opened a pull request fixing the infamous SI-2712. First off, this is remarkable and, if merged, will make everyone's life enormously easier. This is a bug that a lot of people hit often without even realizing it, and they just assume that either they did something wrong or the compiler is broken in some weird way. It is especially common for users of scalaz or cats.

But that's not what I wanted to write about. What I want to write about is the exact semantics of Miles's fix, because it does impose some very specific assumptions about the way that type constructors work, and understanding those assumptions is the key to getting the most of it his fix.

For starters, here is the sort of thing that SI-2712 affects:

def foo[F[_], A](fa: F[A]): String = fa.toString

LambdaConf Travel Notes

The missing manual!

Anyway… The first thing you should know is that you're not the only one who couldn't fly into Boulder directly. Denver International Airport is the closest and only major airport associated with Boulder. It's only about 50 miles away from Boulder, so that's not too much of a hardship, especially since transit connections are so good (more on this in a bit).

The next thing you should know is that Denver International Airport (DIA) is not actually in Denver. DIA is slightly closer to Denver than it is to Boulder, but honestly not by that much. So if you were planning on taking advantage of your flight into "Denver" to site-see in the city… uh, that's probably not going to happen. In any event, while Denver is quite nice, Boulder is better in almost every detail except its lack of skyscrapers.

Denver (for… reasons)

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x