Skip to content

Instantly share code, notes, and snippets.

Jimbo jimbojw

  • Boston
Block or report user

Report or block jimbojw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:583389
// 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;
View show blockers.js
$(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")
View cat pictures.js
$.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;
});
}
View pathological-json.js
{"/*":"*/","//":"",/*"//"*/"/*/"://
"//"}
View url-in-rhino.js
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),
View extend.js
/**
* 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,
View node-scope-test.js
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
You can’t perform that action at this time.