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
// For each of the following code fragments: | |
// a. what does the code do? | |
// b. what did the author intend for it to do? | |
// c. how would you fix it? | |
// 1. list of links | |
var p = document.createElement('p'); | |
for (var i=0; i<10; i++) { | |
var a = document.createElement('a'); | |
a.innerHTML = "link " + i; |
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() { | |
var $ol = $('#blocked_list').find('ol').eq(0); | |
$.ajax({ | |
url: 'http://api.twitter.com/1/blocks/blocking.json', | |
dataType: 'jsonp', | |
success: function(list) { | |
$ol.empty(); | |
$.each(list, function(i,item){ | |
$("<li><a><img /><span></span></a></li>") | |
.find("a") |
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
$.ajax({ | |
url: "http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json", | |
dataType: "jsonp", | |
jsonp: "jsoncallback", | |
success: function(data){ | |
$.each(data.items, function(i,item){ | |
$("<img/>").attr("src", item.media.m).appendTo('#images'); | |
return i < 3; | |
}); | |
} |
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 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 | |
// path to something you want to download | |
path = "http://something/you/want/to/download", | |
// file you want to save it as | |
file = new java.io.File( "path/to/somewhere/local" ), | |
// create URL object and establish connection | |
url = new java.net.URL(path), |
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
/** | |
* Extend one object with the properties of any other object(s). | |
* @param obj The object to extend. | |
* @param args Additional arguments - the objects from which to copy properties. | |
* @return The object which was extended. | |
*/ | |
var extend = (function(){ | |
var | |
slice = Array.prototype.slice, |
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 sys = require('sys'); | |
sys.puts("Top level"); | |
sys.puts(" this === GLOBAL: " + (this === GLOBAL)); // false | |
sys.puts(" this === exports: " + (this === exports)); // true | |
var x = "1"; // local variable | |
sys.puts(" x === GLOBAL.x: " + (x === GLOBAL.x)); // false |