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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js'></script> | |
<script> | |
$(document).ready(function(){ | |
function debug(str){ $("#debug").append("<p>"+str+"</p>"); }; | |
if(typeof WebSocket === 'undefined') { | |
alert("Your browser does not support websockets.") | |
} |
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
/** | |
* Render templates. | |
* | |
* @param {String} The template to use `<p>Hello {{name}}</p>` | |
* @param {String} The data `{ name: 'Alex' }` | |
* @return {String} The rendered template | |
**/ | |
function template(t, d) { | |
return t.replace(/{{([^}]*)}}/g, function(m, f, p, a) { | |
return d[f] || ''; |
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
Foo = {}; | |
Foo.bar = function(){ | |
alert("test"); | |
} | |
setTimeout(Foo.bar, 1000); // 1 second later, alert's "test" |
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 results = new SearchResults(); | |
results.searchTerm = "some search term"; | |
results.fetch({ | |
success: someView.showTheResults | |
}); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script class="jsbin" src="http://code.jquery.com/jquery-1.7.1.min.js"></script> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
<!--[if IE]> | |
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
<style> |
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
#first we create a subclass of class string | |
class MyString < String | |
end | |
MyString.new | |
# => "" | |
#now we are going to override this method by some Ruby magic | |
MyString.class_eval do | |
def empty? |
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
describe('built-in matchers', function() { | |
describe('toBeTruthy', function() { | |
it('passes if subject is true', function() { | |
expect(true).toBeTruthy(); | |
expect(false).not.toBeTruthy(); | |
}); | |
}); | |
describe('toBeFalsy', function() { | |
it('passes if subject is false', function() { |
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 parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
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 Blips = new Meteor.Collection("blips"); | |
if (Meteor.is_client) { | |
var handle = Meteor.subscribe('blips', function () {}); | |
var handleClient = Meteor.subscribe('blips_' + clientID, function () {}); | |
Meteor.call('mapBlips', box, clientID, function (error, result){ | |
BlipsClient = new Meteor.Collection('blips_' + clientID); | |
blips_client = BlipsClient.find({}); | |
} |
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
require 'set' | |
# Union | |
Set[1,2,3] | Set[3,4,5] | |
#=> #{1,2,3,4,5} | |
# Intersection | |
Set[1,2,3] & Set[2,3,4,5] | |
#=> #{2,3} |
OlderNewer