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
countdown = (function(){ | |
var index; | |
function log(){ | |
console.log(index); | |
} | |
function iterate(){ | |
log(); | |
if(index>1) setTimeout(iterate, 1000); |
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
<script> | |
// Exercise 1 - OO || !OO | |
// Define a data structure for cars (make and color), and a function | |
// that logs a string like "I'm a red Mercedes" to the console. | |
// Make two versions: a functional version, and a object-oriented version. | |
// Example call for functional version: | |
logCar({ color: 'blue', make: 'BMW' }); | |
// Example call for OO version: |
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
document.getElementById('the_div').addEventListener( | |
'click', function(){ log('the_div!') }, true); | |
document.getElementById('the_list').addEventListener( | |
'click', function(){ log('the_list!') }, false); | |
document.getElementById('the_item').addEventListener( | |
'click', function(){ log('the_item!') }, true); |
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
document.getElementById('the_div').addEventListener( | |
'click', function(){ log('the_div!') }, false); | |
document.getElementById('the_list').addEventListener( | |
'click', function(){ log('the_list!') }, false); | |
document.getElementById('the_item').addEventListener( | |
'click', function(){ log('the_item!') }, false); |
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
document.getElementById('the_div').addEventListener( | |
'click', function(){ log('the_div!') }, false); | |
document.getElementById('the_list').addEventListener( | |
'click', function(){ log('the_list!') }, false); | |
document.getElementById('the_item').addEventListener( | |
'click', function(){ log('the_item!'); event.stopPropagation(); }, false); |
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
<body id="body"> | |
<div id="the_div"> | |
<ul id="the_list"> | |
<li id="the_item">Click me!</li> | |
</ul> | |
</div> | |
<p id="log"></p> | |
<script type="text/javascript" charset="utf-8"> |
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
function AwesomeBand(name) { | |
this.name = name; | |
} | |
AwesomeBand.prototype.name = 'Iron Maiden'; | |
var band = new AwesomeBand('Ke$ha'); | |
band.name; //prints 'Ke$ha' |
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
//Run this in the console at http://microjs.com to see how much it would weigh if you used 'em all! ;D | |
var theSizes = document.getElementsByTagName("div"); | |
var total = 0; | |
var incorrectClass = 0; | |
var i = theSizes.length; | |
var current; | |
while (i--) { | |
if ( theSizes[i].className == "size" ) { |
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
// Sometimes, when I'm in my office but not sitting at my computer, I want to glance over at new tweets | |
// in my feed at http://twitter.com. I find myself annoyed with having to click "Show X new tweets" | |
// button that pops up. Running this in the console solves my problem. | |
setInterval(function(){$("#new-tweets-bar").click()}, 5000); |
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
# slightly different version of the awesome stuff found at http://digitalformula.net/articles/pimp-my-prompt-like-paul-irish | |
# enable the git bash completion commands | |
source ~/git-completion.sh | |
# enable git unstaged indicators - set to a non-empty value | |
GIT_PS1_SHOWDIRTYSTATE="." | |
# enable showing of untracked files - set to a non-empty value | |
GIT_PS1_SHOWUNTRACKEDFILES="." |
OlderNewer