Skip to content

Instantly share code, notes, and snippets.

View samccone's full-sized avatar
🐐

Sam Saccone samccone

🐐
  • Google
  • ∆∆∆<script>alert(prompt('why'))</script>
  • X @samccone
View GitHub Profile
@samccone
samccone / .block
Last active November 26, 2017 22:35 — forked from d3indepth/.block
Force layout (with collision detection)
license: gpl-3.0
height: 420
border: no
@samccone
samccone / README.md
Last active October 26, 2023 05:17 — forked from mbostock/.block
Reingold–Tilford Tree

The tree layout implements the Reingold-Tilford algorithm for efficient, tidy arrangement of layered nodes. The depth of nodes is computed by distance from the root, leading to a ragged appearance. Radial orientations are also supported. Implementation based on work by Jeff Heer and Jason Davies using Buchheim et al.'s linear-time variant of the Reingold-Tilford algorithm. Data shows the Flare class hierarchy, also courtesy Jeff Heer.

Compare to this radial layout.

{"title":"Finding the norm of a vector in Javascript","author":"jmeas","pages":[{"pageName":"","sections":[{"type":"text","source":"The norm, or magnitude, of a vector, is its length. In two dimensions, this can be represented in the following way:\n\n$$\\lVert v \\rVert = \\sqrt{x^2+y^2}$$\n\nIn Javascript, we could write a function to calculate this like so:\n\n```js\nfunction norm(x, y) {\n return Math.sqrt(x*x + y*y);\n}\n```\n\nLet's see an example of that:"},{"type":"javascript","source":"// Define the norm\nfunction norm(x, y) {\n return Math.sqrt(x*x + y*y);\n}\n\n// Calculate it\nvar val = norm(3, 4);\n\n// Set it to the output div\nvar output = document.getElementsByClassName('output')[0];\noutput.innerHTML = val;"},{"type":"html","source":"<!-- This is just a div to show our output -->\n\n<div class='output'></div>"},{"type":"css","source":"/* Let's give it some styling, too */\n\n.output {\n background: #eee;\n border: 1px solid #ddd;\n padding: 20px;\n}"}]}],"public":true}
@samccone
samccone / newtest.js
Last active August 29, 2015 14:05 — forked from joshtombs/newtest.js
module.exports = function(){
this.Given(/^I visit TODOMVC$/,function(){
return this.driver.get('http://todomvc.com/architecture-examples/backbone/')
});
this.When(/^I enter "([^"]*)"$/, function(value){
return new this.Widget({
root: "#new-todo"
}).sendKeys(value,Driver.Key.ENTER);
});