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
sudo sed -i "s/archive\.ubuntu/mirrors.digitalocean/g" /etc/apt/sources.list |
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
from sorl.thumbnail import default | |
from myapp.models import MyModel | |
# Get an model instance that has a File/ImageField associated with it. In this | |
# case the `thumb` attribute is an ImageField that we'd like to generate thumbnails for. | |
m = MyModel.objects.get(pk=10) | |
# Note the options passed to this method -- they are applied to the cache key so | |
# the ImageFile instance that is returned will be different for a different set | |
# of options kwargs provided here. In this case, the only option is `upscale=False`. |
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
# This should be in a global namespace shared across your entire project | |
from django.conf import settings | |
NO_SETTING = ('!', None) | |
class TestSettingsManager(object): | |
""" | |
A class which can modify some Django settings temporarily for a | |
test and then revert them to their original values later. | |
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
# create user | |
CREATE USER myuser WITH PASSWORD 'mypassword'; | |
# create database | |
CREATE DATABASE mydatabase; | |
# grant access to user | |
GRANT ALL PRIVILEGES ON DATABASE mydatabase TO myuser; | |
# grant just create |
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
#!/bin/bash | |
# | |
# This is a simple wrapper for generating commands for executables within a | |
# python virtualenv. | |
# | |
# Usage: virtenv env-name command [arg, arg, ...] | |
# | |
# env-name The name of the virtualenv for the command to be run in. | |
# command The command within the virtualenv's path to be run. The base path is usually $VIRTUALENV_HOME/$VIRTUALENV/bin. | |
# arg Any remaining arguments are passed to the command itself. |
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
// We generate this file with Grunt based on system/environment level configuration that is contained elsewhere... YAML file, build number, etc. | |
(function (exports) { | |
exports.config = { | |
"appVersion": "dev", | |
"cdnUrl": "http://cdn.example.com" | |
} | |
// this last bit allows the config to be used both in the browser and in Node (Grunt) | |
}(typeof exports === 'undefined' ? this['WD'] = {}: exports)); |
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
def get_meta_property(self, name): | |
if not self.has_property(name): | |
msg = "Invalid metadata field '{0}'".format(name) | |
raise InvalidMetadataField(msg) | |
try: | |
value_obj = self.meta_values.get(category__name=name) | |
except NodeMetadataValue.DoesNotExist: | |
return None |
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
from datetime import datetime, date, timedelta | |
from myproject.apps.events import Location, Event | |
start = date.today() | |
end = start + timedelta(days=3) | |
location = Location(place='Mountain View, CA', venue='Shoreline Amphitheatre', | |
address='1 Amphitheatre Pkwy, Mountain View, CA 94043', | |
latitude=37.423172, longitude=-122.078266) | |
location.save() |
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
location /favicon.ico { | |
alias /wd/services/api/production/current/wdapi/static/wdapi/img/favicon.ico; | |
} |
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
echo '{"foo": "lorem", "bar": "ipsum"}' | python -mjson.tool |