This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Nice to study. Original here http://www.20thingsilearned.com/js/twentythings.min.js | |
*/ | |
var TT = TT || {}; | |
TT.PAGE_WIDTH = 800; | |
TT.PAGE_HEIGHT = 500; | |
TT.PAGE_MIN_WIDTH = 1000; | |
TT.PAGE_MIN_HEIGHT = 680; | |
TT.PAGE_MARGIN_LEFT = 32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pseudocode | |
Each node has x,y position and dx,dy velocity and mass m. There is usually a spring constant, s, and damping: 0 < damping < 1. The force toward and away from nodes is calculated according to Hooke's Law and Coulomb's law or similar as discussed above. | |
set up initial node velocities to (0,0) | |
set up initial node positions randomly // make sure no 2 nodes are in exactly the same position | |
loop | |
total_kinetic_energy := 0 // running sum of total kinetic energy over all particles | |
for each node | |
net-force := (0, 0) // running sum of total force on this particular node | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
addListener: null, | |
removeListener: null, | |
init: function () { | |
if (typeof window.addEventListener === 'function') { | |
this.addListener = function (el, type, fn) { | |
el.addEventListener(type, fn, false); | |
}; | |
this.removeListener = function (el, type, fn) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Make firebug going to facebook's canvas | |
// | |
// From Firebug console, just execute the following command | |
// Or make a bookmarklet: <a href="javascript:with(_FirebugCommandLine){cd($$(".canvas_iframe_util")[0].contentWindow);}">cd(canvas)</a> | |
// | |
// see: http://stackoverflow.com/questions/2495313/firebug-and-jquery-selectors-in-an-iframe#answer-2512156 | |
// | |
cd($$(".canvas_iframe_util")[0].contentWindow); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
background-image: -webkit-linear-gradient(-90deg, transparent 0%, transparent 50%, white 50%, white 100%), | |
-webkit-linear-gradient( 0deg, rgba(0,0,0,.1) 0%, rgba(0,0,0,.1) 50%, white 50%, white 100%); | |
background-size:.25em .25em; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> | |
<meta> | |
<author>Antoine BERNIER</author> | |
<documentationURL></documentationURL> | |
<sampleQuery>USE 'https://raw.github.com/gist/1097256' AS github.gist.content; select * from github.gist.content where gist_id='1097256'</sampleQuery> | |
</meta> | |
<bindings> | |
<select itemPath="content" produces="JSON"> | |
<urls> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
background-color: white; | |
background-size: 1em 1em; | |
background-position:0em 0em,.5em .5em, -.5em .5em,.5em -.5em, 1.5em 1em,1em .5em; | |
background-image: | |
-webkit-linear-gradient(-45deg, white 25%, transparent 25%, transparent 75%, transparent 75%, transparent), | |
-webkit-linear-gradient(-45deg, transparent 25%, transparent 25%, transparent 75%, white 75%, white), | |
-webkit-linear-gradient(-135deg, #333 0%, #333 14%, transparent 14%, transparent 26%, #333 26%, #333 35%, transparent 35%, transparent 100%), | |
-webkit-linear-gradient( 45deg, #333 0%, #333 14%, transparent 14%, transparent 26%, #333 26%, #333 35%, transparent 35%, transparent 100%), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var o = { | |
value: 3 | |
}; | |
* Method invocation | |
When invoking a function that is a property of an object | |
o.incr = function () { | |
this.value += 1; // 'this' will be bound to 'o' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Contextual reset | |
* | |
* Undo default browser's HTML styles | |
* | |
* Author: Antoine BERNIER (antoine.bernier@cafe.com) | |
*/ | |
.reset { | |
font-size:inherit; line-height:inherit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
background: | |
-webkit-linear-gradient(90deg, blue 0, blue 0.02925em, transparent 0.02925em, transparent 0.26325em, blue 0.26325em, blue 0.2925em, transparent 0) 0em 0.14625em, | |
-webkit-radial-gradient(white 0.07605em, transparent 0em), | |
-webkit-linear-gradient(128deg, black 0.6201em, transparent 0) -0.585em 1.17em, | |
-webkit-linear-gradient(-128deg, black 0.6201em, transparent 0) -0.585em 1.17em, | |
-webkit-linear-gradient(115deg, black 0.351em, transparent 0) -0.585em 1.17em, | |
-webkit-linear-gradient(-115deg, black 0.351em, transparent 0) -0.585em 1.17em, | |
-webkit-linear-gradient(103deg, black 0.1755em, transparent 0) -0.585em 1.17em, | |
-webkit-linear-gradient(-103deg, black 0.1755em, transparent 0) -0.585em 1.17em, | |
-webkit-radial-gradient(yellow 0.585em, transparent 0) black; |