Skip to content

Instantly share code, notes, and snippets.

View brettjonesdev's full-sized avatar

Brett Jones brettjonesdev

View GitHub Profile
@brettjonesdev
brettjonesdev / query.sql
Last active July 18, 2019 02:15
CWA stuff
/* Pledgeup.contact table: convert Unix timestamp to created_at timestamp,
select only rows that have expressed interest */
WITH first_query AS
(SELECT FROM_UNIXTIME(property_pledgeup_interest/1000), '%Y-%m-%d %T UTC')
AND
SELECT *
FROM pledgeup.contact
WHERE property_pledgeup_interest IS NOT NULL),
it('should be able to select a TodoModel', () => {
const collection = new TodoCollection();
const selectedTodos = new TodoCollection();
const listView = new ListView({collection, selectedTodos});
const model = new TodoModel();
listView.select(model); // Works great!
expect(listView.isSelected(model)).toBe(true);
});
const App = new Application();
App.selectedTodos = new Backbone.Collection();
// List Route
const collection = new TodoCollection();
collection.fetch().then(() => {
const listView = new ListView({
collection,
selectedTodos: App.selectedTodos
}).render();
it('should be able to select a TodoModel', () => {
const collection = new TodoCollection();
const listView = new ListView({collection});
const model = new TodoModel();
listView.select(model); // Throws exception - App is not defined!
});
const App = new Application();
App.selectedTodos = new Backbone.Collection();
// List Route
const collection = new TodoCollection();
collection.fetch().then(() => {
const listView = new ListView({collection}).render();
});
// ListView
@brettjonesdev
brettjonesdev / SequentialSaveModel.js
Last active August 29, 2015 14:25
SequentialSaveModel
// Pass a Model class to modify. Will prevent concurrent ajax calls on model instances, instead queueing each call to `save`/`destroy`/`fetch` and running them sequentially.
// save/fetch/destroy still return jquery deferred promises so usage shoud not change.
function sequentialSyncModel(Model) {
function getWrappedMethod(method) {
return function() {
if (!this._steps) {
this._steps = [];
}
var currentArgs = arguments.length ? Array.prototype.slice.call(arguments, 0) : [];
<script type="text/javascript">
(function() {
function customScript() {
/* Your custom code */
}
if (window.addEventListener) {
window.addEventListener("load",customScript,false);
} else if (window.attachEvent) {
window.attachEvent("onload",customScript);
}
<script type="text/javascript">
(function() {
function customScript() {
/* Your custom code */
}
if (window.addEventListener) {
window.addEventListener("load",customScript,false);
} else if (window.attachEvent) {
window.attachEvent("onload",customScript);
}
<script type="text/javascript">
(function(){
function customScript() {
/* Your custom code */
}
if (window.addEventListener) {
window.addEventListener("load",customScript,false);
} else if (window.attachEvent) {
window.attachEvent("onload",customScript);
}