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
class UserSerializer(serializers.ModelSerializer): | |
""" | |
Exposing permissions as an established policy. | |
""" | |
is_team_captain = serializers.SerializerMethodField('get_is_team_captain') | |
class Meta: | |
model = User | |
def get_is_team_captain(self, obj): |
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
App.TeamEditRoute = Ember.Route.extend({ | |
beforeModel: function(transition) { | |
if (!this.controllerFor('user').get('is_team_captain')) { | |
this.transitionTo('index'); | |
} | |
} | |
}); |
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 kivy.logger import Logger | |
class KivyLoggerWrapper: | |
""" | |
Custom logging wrapper to make use of Kivy's built in logger. | |
""" | |
def __init__(self, title): | |
self.title = title |
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 la kivy.adapters.listadapter | |
#:import listview kivy.uix.listview | |
<MyList>: | |
adapter: la.ListAdapter( | |
data=[], | |
args_converter=self.list_item_args_converter, | |
cls=listview.ListItemButton) | |
<MyScreen>: |
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
""" | |
Unit testing Kivy is easy, but requires a little boiler plate to keep the | |
window quiet while you test your code. This is one way to set up py.test, | |
but the same technique can probably be used with other test runners as well. | |
More information on how these py.test hooks work: | |
http://pytest.org/latest/plugins.html#generic-runtest-hooks | |
""" | |
import mock |
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
#!/usr/bin/env python | |
import sys | |
sys.platform = 'linux2' | |
import os.path | |
import mimetypes | |
import urlparse | |
import requests |
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
machine: | |
node: | |
version: 0.10.28 | |
dependencies: | |
pre: | |
- npm install -g bower | |
override: | |
- npm i | |
- bower i | |
deployment: |
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
#!/bin/sh | |
MASTER_BRANCH="master" | |
STAGING_BRANCH="staging" | |
function new_issue() { | |
# | |
# Create a new branch from master using the provided name | |
# | |
if [ -z $2 ]; then |
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
// app/helpers/safe-string.js | |
import Ember from 'ember'; | |
/** | |
* Do not escape special characters. | |
* | |
* Usage: | |
* | |
* ```hbs | |
* {{safe-string "<span>My raw HTML code</span>"}} |