This file contains hidden or 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
| // Assuming that the request to fetch the already written bytes has just | |
| // taken place and xhr.result contains the response from the server. | |
| var start = xhr.result.numWrittenBytes; | |
| var length = file.size - start; | |
| var chunk = file.slice(start, length); | |
| var req = new XMLHttpRequest(); | |
| req.open('post', 'fnc.php?fnc=resume', true); | |
| req.setRequestHeader("Cache-Control", "no-cache"); |
This file contains hidden or 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
| // snap cursor | |
| if(distM < 30 && count > 50) { | |
| count = 0; | |
| $("#mouth").css({ "height":"", "-webkit-transform":"", "-moz-transform":"" }); | |
| $("body").css({ "cursor":"none" }); | |
| $('#wrapper').removeClass("hungry").addClass("eat"); | |
| playAudio("audio-snap"); | |
| status = "eat"; | |
| } else { | |
| count++; |
This file contains hidden or 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
| // Suboptimal, causes layout twice. | |
| var newWidth = aDiv.offsetWidth + 10; // Read | |
| aDiv.style.width = newWidth + 'px'; // Write | |
| var newHeight = aDiv.offsetHeight + 10; // Read | |
| aDiv.style.height = newHeight + 'px'; // Write | |
| // Better, only one layout. | |
| var newWidth = aDiv.offsetWidth + 10; // Read | |
| var newHeight = aDiv.offsetHeight + 10; // Read | |
| aDiv.style.width = newWidth + 'px'; // Write |
This file contains hidden or 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
| Step( | |
| // Loads two files in parallel | |
| function loadStuff() { | |
| fs.readFile(__filename, this.parallel()); | |
| fs.readFile("/etc/passwd", this.parallel()); | |
| }, | |
| // Show the result when done | |
| function showStuff(err, code, users) { | |
| if (err) throw err; | |
| sys.puts(code); |
This file contains hidden or 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
| // -- input | |
| // simple call | |
| fish = $.get! '/fish' | |
| $("stomach").append fish | |
| // another simple call with implied () | |
| ok = stomach.save! | |
| meal.complete = ok | |
| // -- output |
This file contains hidden or 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
| if (window.matchMedia("(min-width: 400px)").matches) { | |
| // The screen width is 400px or wider. | |
| } else { | |
| // The screen width is less than 400px. | |
| } |
This file contains hidden or 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
| function setup_for_width(mql) { | |
| if (mql.matches) { | |
| // The screen width is 400px or wider. Set up or change things | |
| // appropriately. | |
| } else { | |
| // The screen width is less than 400px. Set up or change things | |
| // appropriately. | |
| } | |
| } |
This file contains hidden or 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
| .rtl ul { | |
| text-align: left\9; /* IE8/9 */ | |
| *text-align: left; /* IE5/6/7 */ | |
| } |
This file contains hidden or 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
| // create a test object | |
| var obj = {a:1, get b() {return "b value"}, c: undefined}; | |
| obj.c = {back: obj}; // make a circular reference to obj | |
| // create an introspection mirror on obj | |
| var m = Mirrors.introspect(obj); | |
| console.log(m); //output: "Object Introspection Mirror #0" | |
| console.log(m.ownPropertyNames) ; //output: "a,b,c" | |
| console.log(m.extensible); //output: true |
This file contains hidden or 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
| // this equation took FOREVER to pinpoint through less than mathematical means of trial and error. | |
| // Holy euclidian bullcrap, Batman! 1 - ratio, what is this nonsense?! | |
| // A thanks to IdleT user Forbin for simplifying the equation for me further. | |
| function parallax(containerClassRef, ratio){ | |
| $(containerClassRef).css({ | |
| left: Math.round( (1 - ratio) * ( cellWd / 2 + $(window).scrollLeft() ) )+'px' | |
| }); | |
| } |