Skip to content

Instantly share code, notes, and snippets.

StateManager.fetchHtml('/services/money/jobs/categories/', { timeout: 10000 }).done(_.bind(function(html){
this.$('.jobs-form-dropdown').append(html);
}, this))
.always(function(){
this.subviews.jobSearchForm = new SelectDropdown({
el: this.$('.jobs-form-dropdown')
});
});
@cwmanning
cwmanning / bah.js
Created December 4, 2012 18:59
blah
animateNewContent: function(fromPath, toPath, htmlFrag, paused){
var currentWrap = this.$cards.eq(this.currentIndex);
var currentCard = currentWrap.children('.card');
if (currentWrap.children('.ad_container1').length === 0){
var ads = htmlFrag.find(".ad_container1");
currentWrap.prepend(ads);
}
if (htmlFrag.find('.hero.bump').length) {
currentCard.find('.punchout-cover').addClass('show');
}
@cwmanning
cwmanning / models.py
Created November 20, 2012 18:12
BoxScores
class BoxScores(object):
def __init__(self, data):
# boxscores key is required, let fail if not present
self.data = accum(data, 'boxscores')
def event(self):
return get_nested(self.data, 'event_metadata', 0, default=None)
def game_story(self):
story = get_nested(self.data, 'game_story', default={})
@cwmanning
cwmanning / taboola.js
Created November 15, 2012 16:31
Taboola Click
registerTaboolaClick: function(itemId, itemType, responseId, placement){
var url = 'http://api.taboola.com/1.0/json/usatodaydemo/recommendations.notify-click' +
'?app.type=desktop&app.apikey=' + this.apiKey + '&response.id=' + responseId +
'&item.type=' + itemType + '&item.id=' + itemId;
if (placement) {
url += 'placement=' + placement; // below-photo or end-slate
}
new Image().src = url;
$.ajax({
url: mapParams.url,
dataType: 'jsonp',
cache: true,
jsonpCallback: 'grid',
success: function(tilejson) {
var mapbox = new Connector(tilejson);
map.addLayer(mapbox);
mapbox.addEventListener('load', load);
}
@cwmanning
cwmanning / bash_prompt.sh
Created August 15, 2012 17:12
Bash prompt
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
@cwmanning
cwmanning / views-app.js
Created July 25, 2012 18:24
app change to allow #links
triggerRoute: function(e){
var $targetLink = $(e.target).closest('a'),
href;
if (!$targetLink.length) return;
href = $targetLink.attr('href');
if (href.indexOf('#') == 0 && href.length > 1) return;
App.setHeatTrack($targetLink);
if (Modernizr.history && this.isDefinedRoute(href) && href) {
@cwmanning
cwmanning / sviews.py
Created July 24, 2012 16:28
Messing around with timeline dates
from django.conf import settings
from django.http import HttpResponse
from django.shortcuts import render
from dummyjson import views as dj
from gannettapi.api import api
from datetime import datetime
from dateutil.parser import parse
from dateutil.relativedelta import relativedelta
from ordereddict import OrderedDict
from relux import utils
@cwmanning
cwmanning / wax.leaf.js
Created June 29, 2012 20:29
Wax and Reqwest
/*!
* Reqwest! A general purpose XHR connection manager
* copyright Dustin Diaz 2011
* https://github.com/ded/reqwest
* license MIT
*/
!function(context,win){function serial(a){var b=a.name;if(a.disabled||!b)return"";b=enc(b);switch(a.tagName.toLowerCase()){case"input":switch(a.type){case"reset":case"button":case"image":case"file":return"";case"checkbox":case"radio":return a.checked?b+"="+(a.value?enc(a.value):!0)+"&":"";default:return b+"="+(a.value?enc(a.value):"")+"&"}break;case"textarea":return b+"="+enc(a.value)+"&";case"select":return b+"="+enc(a.options[a.selectedIndex].value)+"&"}return""}function enc(a){return encodeURIComponent(a)}function reqwest(a,b){return new Reqwest(a,b)}function init(o,fn){function error(a){o.error&&o.error(a),complete(a)}function success(resp){o.timeout&&clearTimeout(self.timeout)&&(self.timeout=null);var r=resp.responseText;if(r)switch(type){case"json":resp=win.JSON?win.JSON.parse(r):eval("("+r+")");break;case"js":resp=eval(r);break;case"html":resp=r}fn(resp),o.suc
@cwmanning
cwmanning / map-test.html
Created June 28, 2012 16:55
MapBox Basic Demo
<html>
<head>
<title>MapBox Fun</title>
<link rel="stylesheet" href="leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="leaflet.ie.css" />
<![endif]-->
<script src="leaflet.js"></script>
<script src="wax.leaf.min.js"></script>