Skip to content

Instantly share code, notes, and snippets.

@zischwartz
zischwartz / index.html
Created March 31, 2015 12:42
ScriptEd Unit 7 Project: Hi- Lo // source http://jsbin.com/lejewepeyo
<!DOCTYPE html>
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="css/highlow.css" rel="stylesheet" type="text/css" />
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="js/guts.js"></script>
<script src="js/highlow.js"></script>
<title>ScriptEd Unit 7 Project: Hi- Lo</title>
<style id="jsbin-css">
@zischwartz
zischwartz / gist:00fa4a0104e2a9919524
Last active September 14, 2015 20:30
Notebook websocket error
[I 20:29:05.985 NotebookApp] Writing notebook server cookie secret to /root/.ipython/profile_default/security/notebook_cookie_secret
[I 20:29:05.986 NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
[W 20:29:06.012 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[W 20:29:06.013 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using authentication. This is highly insecure and not recommended.
[I 20:29:06.019 NotebookApp] Serving notebooks from local directory: /notebooks
[I 20:29:06.019 NotebookApp] 0 active kernels
[I 20:29:06.019 NotebookApp] The IPython Notebook is running at: http://[all ip addresses on your system]:8888/user/G7Dqldp5KZwe/
[I 20:29:06.019 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 20:29:06.480 NotebookApp] 302 GET /user/G7Dqldp5KZwe (172.17.42.1) 2.75ms
[I 20:29:16.628 NotebookApp
h2
{
/*text-shadow: -1px -1px -1px @white;*/
text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.5);
font-size: 2.5em;
border-bottom: 1px @gray solid;
margin-bottom: .5em;
}
p
function make_graph(data){
var svg = d3.select("svg")
// hackily just remove everything from last time.
// a more sophisticated version would transition nicely
svg.selectAll("*").remove()
var margin = {top: 20, right: 20, bottom: 30, left: 40},
width = +svg.attr("width") - margin.left - margin.right,
height = +svg.attr("height") - margin.top - margin.bottom;
@zischwartz
zischwartz / .block
Created November 13, 2017 20:47
Circle Dragging I
license: gpl-3.0
@zischwartz
zischwartz / .block
Created November 15, 2017 14:17
Local Variables
license: mit
@zischwartz
zischwartz / .block
Created December 13, 2017 17:21
fresh block
license: mit
let cards = [0,1,2,3,4]
@zischwartz
zischwartz / README.md
Created January 4, 2018 19:16 — forked from mbostock/README.md
Local Variables

It’s often desirable when using D3 to define local behavior, that is, behavior that is specific to an individual element, rather than the same for all elements in a selection. The simplest example of this is passing a function to selection.attr to compute an attribute value for each element.

But what happens if your local behavior is more complicated? What if you want multiple operations (multiple attributes, or elements) to have local behavior, but still share local state between them? For instance, when rendering small multiples of time-series data, you might want the same x-scale for all charts but distinct y-scales to compare the relative (not absolute) performance of each metric.

There are several ways to do this in D3:

  1. Make the y-scale global, but set the domain on the y-scale before use. (Example.)

  2. Use selection.each to create a local con

@zischwartz
zischwartz / .block
Last active January 30, 2018 16:18
d3 raise()/order problem
license: mit