⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
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
import re | |
from django.utils.text import compress_string | |
from django.utils.cache import patch_vary_headers | |
from django import http | |
try: | |
import settings | |
XS_SHARING_ALLOWED_ORIGINS = settings.XS_SHARING_ALLOWED_ORIGINS |
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
#!/usr/bin/env python | |
# | |
# Converts any integer into a base [BASE] number. I have chosen 62 | |
# as it is meant to represent the integers using all the alphanumeric | |
# characters, [no special characters] = {0..9}, {A..Z}, {a..z} | |
# | |
# I plan on using this to shorten the representation of possibly long ids, | |
# a la url shortenters | |
# |
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
"""A basic database set-up for Travis CI. | |
The set-up uses the 'TRAVIS' (== True) environment variable on Travis | |
to detect the session, and changes the default database accordingly. | |
Be mindful of where you place this code, as you may accidentally | |
assign the default database to another configuration later in your code. | |
""" | |
import os |
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
class ValidateModelMixin(object): | |
"""Make :meth:`save` call :meth:`full_clean`. | |
.. warning: | |
This should be the left-most mixin/super-class of a model. | |
Do you think Django models ``save`` method will validate all fields | |
(i.e. call ``full_clean``) before saving or any time at all? Wrong! |
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 app = angular.module('validationExample', []); | |
app.controller('signupController', ['$scope', function($scope) { | |
$scope.submitted = false; | |
$scope.signupForm = function() { | |
if ($scope.signup_form.$valid) { | |
} else { | |
$scope.signup_form.submitted = true; | |
} |
I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.
- Publishing (Draft->Approved->Published->Expired->Deleted)
Overview:
- Redis supports PUB/SUB
- It supports pattern matching. Clients may subscribe to glob-style patterns in order to receive all the messages sent to channel names matching a given pattern.
Assuming Fedora 23.
OlderNewer