This is from the challenge at the end of the the "javascript data structures and control" section of stream 1
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
from django.contrib.redirects.models import Redirect | |
from django.contrib.sites.models import Site | |
class BlogPost(models.Model): | |
... | |
slug = models.CharField(unique=true, max_length=128) | |
@models.permalink | |
def get_absolute_url(def): | |
return ('blogpost_detail', (), { 'slug' : self.slug }) |
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
import tweepy | |
import inspect | |
import re | |
from django.conf import settings | |
from django import template | |
from django.utils.safestring import mark_safe | |
register = template.Library() |
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
from django.contrib.contenttypes.models import ContentType | |
from django.core.urlresolvers import reverse | |
from django.db import models | |
class AdminURLMixin(object): | |
def get_admin_url(self): | |
content_type = ContentType \ | |
.objects \ | |
.get_for_model(self.__class__) | |
return reverse("admin:%s_%s_change" % ( |
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
user nginx; | |
worker_processes 2; | |
error_log /var/log/nginx/error.log warn; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
} |
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 single_pair_validator = function(hand){ | |
}; | |
var high_card_validation = function(white_numbered_hand, black_numbered_hand){ | |
for(var i=0; i < white_numbered_hand.length; i++){ | |
if(white_numbered_hand[i] > black_numbered_hand[i]){ | |
return "White wins"; | |
} | |
if(white_numbered_hand[i] < black_numbered_hand[i]){ |
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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: ['drag-box'], | |
attributeBindings: ['draggable'], | |
draggable: true, | |
x: 0, | |
y: 0, | |
positionChanged: Ember.observer('x', 'y', function(){ | |
this.$().css({ |
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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: "section", | |
page: 1, | |
paginateBy: 10, | |
paginatedItems: Ember.computed('amenities', 'page', function(){ | |
var i = (parseInt(this.get('page')) - 1) * parseInt(this.get('paginateBy')); | |
var j = i + parseInt(this.get('paginateBy')); | |
return this.get('items').slice(i, j); |
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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: 'li', | |
classNames: ['slide-list__list__item'], | |
didInsertElement() { | |
this._super(...arguments); | |
this.get('childRendered')(); | |
} | |
}); |