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
var bind = function(func, thisValue) { | |
return function() { | |
return func.apply(thisValue, arguments); | |
} | |
} | |
var boundHello = bind(person.hello, person); | |
boundHello("world") // "Brendan Eich says hello world" |
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
var lastUsedHeap = 0; // remember the heap size | |
function checkMemory() | |
{ | |
// check if the heap size is this cycle is LESS than what we had last | |
// cycle; if so, then the garbage collector has kicked in | |
if (window.performance.memory.usedJSHeapSize < lastUsedHeap) | |
console.log('Garbage collected!'); | |
lastUsedHeap = window.performance.memory.usedJSHeapSize; |
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
#ball { | |
width: 300px; | |
height: 300px; border-radius: 150px; | |
background-color: blue; | |
background-image: radial-gradient(circle 400px at 0 0, rgba(0,0,0,0), rgba(0,0,0,0), rgba(0,0,0,.8)), radial-gradient(circle 180px at 90px 80px, rgba(255,255,255,.7), rgba(0,0,0,0)); | |
background-repeat: no-repeat, no-repeat; | |
position:relative; | |
} | |
#ball:after { |
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
.wrap { | |
/* Unimportant styling. */ | |
background-color: #ffa500; | |
width: 400px; | |
height: 200px; | |
/* Solution (part I)*/ | |
/* This code allows element inside the .wrap to be positioned in the middle. */ | |
display: table-cell; | |
vertical-align: middle; |
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
/** | |
* Move in a circle without wrapper elements | |
* Idea by Aryeh Gregor, simplified by Lea Verou | |
*/ | |
@keyframes rot { | |
from { | |
transform: rotate(0deg) | |
translate(50px) | |
rotate(0deg); |
NewerOlder