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
$ make test | |
g++ -std=c++98 -Wall -Wextra -g -D_GLIBCXX_DEBUG -Isample -lpthread -I.. -I../gtest -I../gtest/include ../gtest/src/gtest-all.cc gtest_main.a ../basic_functions/guest.cpp ../basic_functions/party.cpp ../basic_functions/table.cpp ../basic_functions/wish.cpp test_guests.cc test_tables.cc test_wishes.cc test_party.cc -o test | |
In file included from ../basic_functions/guest.h:15, | |
from ../basic_functions/party.h:13, | |
from ../basic_functions/guest.cpp:15: | |
../basic_functions/wish.h:102: error: expected ‘)’ before ‘&’ token | |
../basic_functions/wish.h:137: error: ISO C++ forbids declaration of ‘Guest’ with no type | |
../basic_functions/wish.h:137: error: expected ‘;’ before ‘&’ token | |
../basic_functions/wish.h:146: error: ‘Tablegroup’ was not declared in this scope | |
../basic_functions/wish.h:146: error: template argument 1 is invalid |
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
var log = function () { | |
if (window.console && window.console.log && window.console.log.apply) { | |
var args = Array.prototype.slice.call(arguments); | |
args.unshift('My app:'); | |
console.log.apply(console, args); | |
} | |
}; |
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
var namespace = {}; | |
namespace.module = (function () { | |
var priv = 'private var'; | |
return { | |
init: function () { | |
// init module | |
}, |
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
var lazy = (function () { | |
var initialized = false; | |
var init = function () { | |
// init code here | |
}; | |
return function () { | |
if (!initialized) { |
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
var getCachedJSON = function (url, callback) { | |
var cachedData = window.localStorage[url]; | |
if (cachedData) { | |
log('Data already cached, returning from cache:', url); | |
callback(JSON.parse(cachedData)); | |
} else { | |
$.getJSON(url, function (data) { | |
log('Fetched data, saving to cache:', url); | |
window.localStorage[url] = JSON.stringify(data); | |
callback(data); |
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
asyncTest('Basic fetch with an empty localStorage.', function () { | |
expect(7); | |
start(); | |
var proxyMockCallCount = 0; | |
// Mock the json proxy to avoid networking. | |
JSONCache._getJSONProxy = function (url, options) { | |
proxyMockCallCount++; | |
if (url === 'data.json') { | |
options.success(testData); |
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
// http://www.html5rocks.com/en/mobile/workingoffthegrid.html | |
var fireEvent = function(name, data) { | |
var e = document.createEvent("Event"); | |
e.initEvent(name, true, true); | |
e.data = data; | |
window.dispatchEvent(e); | |
}; |
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
var day = {name: 'day 1', rooms: [1, 2, 3]}; | |
// create a separate var pointing to the same room list | |
var rooms = day.rooms; | |
day.rooms === rooms; // true | |
// delete the rooms list from the day object | |
delete day.rooms; |
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
// one liner | |
_.tap({}, function (o) { _.each(location.hash.split('&'), function (p) { var s = p.split('='); o[s[0]] = s[1]; }); }); | |
// indented | |
_.tap({}, function (o) { | |
_.each(location.hash.split('&'), function (p) { | |
var s = p.split('='); | |
o[s[0]] = s[1]; |
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
// In the events object of the view: | |
// 'touchstart nav a': 'onNavTouchStart', | |
// 'touchmove nav a': 'onNavTouchMove', | |
// 'touchend nav a': 'onNavTouchEnd', | |
onNavTouchStart: function (event) { | |
var href = $(event.target).attr('href'); | |
this.navTouchHref = (href && href !== '#') ? href : null; | |
}, |
OlderNewer