sudo apt-get install python3-pip
sudo pip3 install virtualenv
| import boto3 | |
| import pandas as pd | |
| from io import BytesIO | |
| bucket, filename = "bucket_name", "filename.csv" | |
| s3 = boto3.resource('s3') | |
| obj = s3.Object(bucket, filename) | |
| with BytesIO(obj.get()['Body'].read()) as bio: | |
| df = pd.read_csv(bio) |
| from myapp.utils import set_current_user | |
| class CurrentUserMiddleware: | |
| def process_request(self, request): | |
| set_current_user(getattr(request, 'user', None)) |
| from concurrent.futures import ThreadPoolExecutor | |
| import time | |
| def wait_function(x, y): | |
| print('Task(', x,'multiply', y, ') started') | |
| time.sleep(2) | |
| print('Task(', x,'multiply', y, ') completed') | |
| return x * y | |
| def callback_function(future): |
| $ git clone [email protected]:xxxxx/xxxx.git my-awesome-proj | |
| Cloning into 'my-awesome-proj'... | |
| ssh: connect to host github.com port 22: Connection timed out | |
| fatal: Could not read from remote repository. | |
| $ # This should also timeout | |
| $ ssh -T [email protected] | |
| ssh: connect to host github.com port 22: Connection timed out | |
| $ # but this might work |
| [settings] | |
| DEBUG=True | |
| SECRET_KEY=y#bz$z0prv)@bie(@3wa@=--ana7%%k!hvo)b-3d4#0mnhh0pi6 | |
| AWS_ACCESS_KEY_ID=M5YCPZP3QT36OWMMZS23 | |
| AWS_SECRET_ACCESS_KEY=5Npq/S/7tX2IqBl51p3QEAMJuuGvHuFH4680Cl59M3s | |
| AWS_STORAGE_BUCKET_NAME=open-api-space | |
| AWS_S3_ENDPOINT_URL=https://nyc3.digitaloceanspaces.com | |
| AWS_LOCATION=open-api-static |
| INSTALLED_APPS = [ | |
| # My apps | |
| 'personal', | |
| 'account', | |
| 'blog', | |
| # django apps | |
| 'django.contrib.admin', |
| <script id="person-tmpl-django" class="fix" type="text/x-jquery-tmpl"> | |
| <div id="person-${user.id}" class="person"> | |
| <strong>${user.name}</strong> | |
| [[each(i, c) user.children]] | |
| <div class="child">${c.child_name}</div> | |
| [[/each]] | |
| <span>${user.age}</span> | |
| </div> | |
| function updateElementIndex(el, prefix, ndx) { | |
| var id_regex = new RegExp('(' + prefix + '-\\d+)'); | |
| var replacement = prefix + '-' + ndx; | |
| if ($(el).attr("for")) $(el).attr("for", $(el).attr("for").replace(id_regex, replacement)); | |
| if (el.id) el.id = el.id.replace(id_regex, replacement); | |
| if (el.name) el.name = el.name.replace(id_regex, replacement); | |
| } | |
| function addForm(btn, prefix) { | |
| var formCount = parseInt($('#id_' + prefix + '-TOTAL_FORMS').val()); |
| from django.db import models | |
| class ModelA(models.Model): | |
| fieldA1 = models.CharField(max_length=100, unique=True) | |
| fieldA2 = models.TextField(validators=[URLValidator()], blank=True, null=True) | |
| fieldA3 = models.CharField(max_length=100, unique=True, null=True, blank=True) | |
| field4 = models.BooleanField(default=True) |