Skip to content

Instantly share code, notes, and snippets.

View gustavderdrache's full-sized avatar
🤔
...

gustavderdrache

🤔
...
View GitHub Profile
@gustavderdrache
gustavderdrache / bsa.rs
Created July 28, 2020 01:01
TextToSkyrim scratch
use bitflags::bitflags;
use nom::{
bytes::streaming as bytes, combinator, error::ErrorKind, multi, number::streaming as number,
Err as NomErr, IResult,
};
use std::{
fs::File as StdFile,
io::{self, Read as _, Seek as _, SeekFrom},
path::Path,
};
@gustavderdrache
gustavderdrache / Gruntfile.js
Created May 27, 2016 15:15
minimal htmlOutputTemplate configuration
module.exports = function (grunt) {
grunt.initConfig({
ts: {
'custom-template': {
html: ['file.html'],
src: ['.'],
options: {
compile: false,
htmlOutputTemplate: 'export default \'<%= content %>\'',
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>FNS map</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.12/d3.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.19/topojson.min.js"></script>
<style>
.fns-map__state {
@gustavderdrache
gustavderdrache / README.md
Last active August 29, 2015 14:13
Federal election results for 2012, 2008, and 2004

This is a relatively simple D3 demo using electoral college results culled from the Federal Election Commission. Red states are states in which the Republican candidate won more votes, and blue states are Democratic. (We use this rule because in 2008, Nebraska cast one vote for Obama and four for McCain.)

@gustavderdrache
gustavderdrache / keybase.md
Last active August 29, 2015 14:05
keybase.md

Keybase proof

I hereby claim:

  • I am gustavderdrache on github.
  • I am gustavderdrache (https://keybase.io/gustavderdrache) on keybase.
  • I have a public key whose fingerprint is 05C6 B1ED 7AEC A640 6A11 974A EFA8 2C7C 534D 20A8

To claim this, I am signing this object:

@gustavderdrache
gustavderdrache / 0_reuse_code.js
Created January 27, 2014 15:51
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

By-radius and by-area bubble scaling

Assumptions

  • 0 ≤ population ≤ 100 (unit: percentage)
  • 0 ≤ radius ≤ 40 (unit: pixels)
  • 0 ≤ area ≤ 5026.55 (unit: pixels²)

Area Chart Behind Lines

The first chart demonstrates putting an area chart "behind" the lines and symbols. The area chart has an opacity of 50% in order to help the line graph be visible.

A few notes:

  1. The symbols' fill attribute (white) covers the area.
  2. The line that is supposed to be highlighted has been lost, even at 50% opacity.

Highlighting Line Segments

This graph is structured as follows:

  • There is a single SVG <path> element at the root containing the basic line graph.
  • Above that, the highlighted lines are SVG <line> elements representing important segments.
  • Above that are the symbols (SVG <path> elements generated by d3.js' d3.svg.symbol generator) for the data points.

I have a number of objections to this approach:

<!DOCTYPE html>
<html>
<head>
<title>svg clipping is totally ballin'</title>
</head>
<body>
<svg version="1.1" width="500" height="400">
<defs>
<clipPath id="cup">
<!-- This is as close as I could get to drawing a cup object -->