Skip to content

Instantly share code, notes, and snippets.

@laurentsenta
Last active December 15, 2015 12:38
Show Gist options
  • Save laurentsenta/5261194 to your computer and use it in GitHub Desktop.
Save laurentsenta/5261194 to your computer and use it in GitHub Desktop.
Minimal scripts to get started with some libraries/tools
<!DOCTYPE html>
<html>
<head>
<!-- source: http://christopheviau.com/d3_tutorial/ -->
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
</head>
<body>
<div id="viz"></div>
<script type="text/javascript">
var sampleSVG = d3.select("#viz")
.append("svg")
.attr("width", 100)
.attr("height", 100);
sampleSVG.append("circle")
.style("stroke", "gray")
.style("fill", "white")
.attr("r", 40)
.attr("cx", 50)
.attr("cy", 50)
.on("mouseover", function(){d3.select(this).style("fill", "aliceblue");})
.on("mouseout", function(){d3.select(this).style("fill", "white");});
</script>
</body>
</html>
// source: http://stackoverflow.com/a/2363990
// usage: dot -Tsvg -oresult.svg data.dot
// cat data.dot | dot -Tsvg -oresult.svg
// http://www.graphviz.org/doc/info/shapes.html
digraph {
"Node 1" [shape=diamond, penwidth=3, style=filled, fillcolor="#FCD975"];
"Node 2" [style=filled,fillcolor="#9ACEEB" ];
"Node 3" [shape=diamond, style=filled, fillcolor="#FCD975" ];
"Node 4" [style=filled, fillcolor="#9ACEEB" ]
"Node 1" -> "Node 2" [dir=none, weight=1, penwidth=3] ;
"Node 1" -> "Node 3" [dir=none, color="#9ACEEB"] ;
"Node 1" -> "Node 4" [arrowsize=.5, weight=2.]
"Node 1" -> Node42 [arrowsize=2, weight=5.]
}
<!DOCTYPE html>
<html>
<head>
<!-- source: http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery -->
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("a").click(function() {
alert("Hello world!");
});
});
</script>
</head>
<body>
<a href="">Link</a>
</body>
</html>
python -m SimpleHTTPServer 8000 # http server in the current directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment