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
Source: https://vimeo.com/133154447 | |
Source: https://realpython.com/blog/python/django-development-with-docker-compose-and-machine/ | |
# if you run into problems when creating try docker-machine regenerate-certs dev | |
docker-machine create --driver virtualbox dev | |
# run commands in your created VM | |
eval "$(docker-machine env dev)" | |
# List available machines and check their Ip's | |
docker-machine ls |
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 MissionSerializer(TranslatableModelSerializer): | |
mission = serializers.CharField(source='mission') | |
class Meta: | |
model = Mission | |
class MissionViewSet(viewsets.ModelViewSet): | |
queryset = Mission.objects.language().all() | |
serializer_class = MissionSerializer | |
authentication_classes = (NoAuthentication,) |
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
# hvad compatibility for rest_framework - JHA | |
class TranslatableModelSerializerOptions(serializers.ModelSerializerOptions): | |
def __init__(self, meta): | |
super(TranslatableModelSerializerOptions, self).__init__(meta) | |
# We need this ugly hack as ModelSerializer hardcodes a read_only_fields check | |
self.translated_read_only_fields = getattr(meta, 'translated_read_only_fields', ()) | |
self.translated_write_only_fields = getattr(meta, 'translated_write_only_fields', ()) | |
class HyperlinkedTranslatableModelSerializerOptions(serializers.HyperlinkedModelSerializerOptions): |
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
DEFAULT_FILE_STORAGE = 'app.s3utils.MediaRootS3BotoStorage' | |
STATICFILES_STORAGE = 'app.s3utils.StaticRootS3BotoStorage' | |
AWS_ACCESS_KEY_ID = 'XXXXXXXXXXX' | |
AWS_SECRET_ACCESS_KEY = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY' | |
AWS_STORAGE_BUCKET_NAME = 'app-bucket' | |
AWS_S3_SECURE_URLS = False # use http instead of https | |
AWS_QUERYSTRING_AUTH = False # we dont have any private files | |
S3_URL = 'http://s3-eu-west-1.amazonaws.com/%s' % AWS_STORAGE_BUCKET_NAME | |
MEDIA_ROOT = '/media/' |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> | |
<CORSRule> | |
<AllowedOrigin>*</AllowedOrigin> | |
<AllowedMethod>GET</AllowedMethod> | |
<AllowedMethod>PUT</AllowedMethod> | |
<AllowedMethod>POST</AllowedMethod> | |
<AllowedMethod>DELETE</AllowedMethod> | |
<MaxAgeSeconds>3000</MaxAgeSeconds> | |
<AllowedHeader>Authorization</AllowedHeader> |
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 subprocess | |
import time | |
import smtplib | |
import string | |
# Author Nuno Khan | |
# Utility to check dynamic ip addresses | |
def save_new_Ip(p): | |
ip="" |
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 re | |
class StripHtmlMixin(object): | |
#based on http://stackoverflow.com/a/3398894/977622 | |
def strip_html(self, data): | |
p = re.compile(r'<.*?>') | |
return p.sub('', data) |
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
SETTINGS.PY: | |
from datetime import timedelta | |
CELERYBEAT_SCHEDULE = { | |
'add-every-30-seconds': { | |
'task': 'yourapp.tasks.teste', | |
'schedule': timedelta(seconds=5), | |
'args': (16, 16) | |
}, |
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 urllib2, json | |
def post(): | |
def basic_authorization(user, password): | |
s = user + ":" + password | |
return "Basic " + s.encode("base64").rstrip() | |
data = json.dumps({'username':'david2', 'email':'[email protected]' , 'password':'mypassword'}) |
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 urllib2 ,argparse, shutil, urlparse , os , zipfile, os.path | |
from zipfile import ZipFile as zip | |
parser = argparse.ArgumentParser(description="Download and Unzip") | |
parser.add_argument('url', help='The action to take (e.g. install, remove, etc.)') | |
args = parser.parse_args() | |
url = args.url | |
def extractAll(zipName): | |
z = zip(zipName) |
NewerOlder