Skip to content

Instantly share code, notes, and snippets.

View jennyknuth's full-sized avatar

Jenny Knuth jennyknuth

View GitHub Profile
var http = require('http'),
fs = require('fs'),
mime = require('mime'),
colors = require('colors');
// This server is compliant with the demands of HTML5 pushstate URLs.
// See "The Reload Problem" http://www.angularonrails.com/get-html5-pushstate-working-angular-rails/
// The above article is for rails apps, but the same problem / solution apply here.
@jennyknuth
jennyknuth / D3.js-heat-map-tutorial.md
Last active September 29, 2024 07:41
How to make a heat map like GitHub's commit chart with D3.js

Make a heat map graphic with D3.js

This gist contains the code to create a simple "heat map" with D3.js. In this case, the "heat map" is a graph showing activity distributed over the days of the week on one axis and the weeks of the year on the other.

d3 heat map graphic

This gist is meant to be used as part of a workshop where the code is uncommented as the workshop progresses.

It could also be used as a puzzle outside of a workshop: follow the clues to reconstruct the correct code and make it work!

@jennyknuth
jennyknuth / LandlabFaultscarpTutorial.rst
Last active December 29, 2015 01:12
Quickly Building 2D models in Landlab

A Tutorial on Quickly Building 2D Models in Landlab

Computer models can be tremendously useful in both exploring and visualizing the consequences of scientific hypotheses and comparing these predictions with data. New ideas and discoveries require new models.

In an ideal world, the necessary programming, testing, and debugging would be trivial, leaving us free to focus on the core science. In practice, however, high-quality scientific programming takes time.

`Landlab

CellLab-CTS Model of Isostropic Turbulent Suspension

![] (https://gist.githubusercontent.com/jennyknuth/0be5370ced7dd9170a39/raw/4179b5111f41a008e71a03fcb2fe8e36497c639a/isotropic_suspension_example.png)

CellLab-CTS model of grains suspended in a stirred (turbulent) fluid. Grain motion is modeled as a transition that switches the position of grain and fluid at a user-specified rate. In this example, we assume that the grains are 1 mm diameter tea leaves and the characteristic turbulent velocity fluctuation is 0.01 m/s, so that cell size equals 0.001 m and the mean transition rate is 10 cells/second.

@jennyknuth
jennyknuth / README.md
Last active September 4, 2024 00:54
140 html color names as an array of json objects—enjoy!

HTML Colors

All 140 HTML colors as JSON objects with fields:

  • name
  • hex
  • rgb
  • families
@jennyknuth
jennyknuth / README.md
Last active September 23, 2024 19:12
Transform an SVG into a data URI—best practice

How to transform an SVG into a data URI

by Jenny Knuth, based on the work of Chris Coyier and Taylor Hunt

A data URI is a nice way to include a web resource without needing to make an HTTP request. Chris Coyier explains the technique nicely in Probably Don't Base64 SVG.

While a PNG might use Base64 encoding, for SVG, there is a better way.

Taylor Hunt's experiments led to this solution for optimizing SVGs in data URIs:

"So the best way of encoding SVG in a data URI is data:image/svg+xml,[actual data]. We don’t need the ;charset=utf-8 parameter (or the invalid ;utf8 parameter…), because URLs are always ASCII."

year month day dateString spots
1979 01 01 19790101 224
1979 01 02 19790102 224
1979 01 03 19790103 270
1979 01 04 19790104 222
1979 01 05 19790105 207
1979 01 06 19790106 245
1979 01 07 19790107 231
1979 01 08 19790108 244
1979 01 09 19790109 234
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.