python makedirs.py -f input.txt -o output.txt -indent 4
From a given txt file of directories and/or files structured by indentation generate a sh script that can create that directory tree. Be carefull with indentation.
Example:
"""Esse manager é responsável por gerar os arquivos padrões de um projeto Django (templates, urls, views, forms) | |
baseado nas informações contidas na classe da App do projeto Django. | |
""" | |
import fileinput | |
import os | |
from pathlib import Path | |
from bs4 import BeautifulSoup | |
from core.management.commands.utils import Utils |
# viewsets.py | |
from rest_framework.decorators import api_view, permission_classes | |
from django.http import FileResponse | |
from django.shortcuts import get_object_or_404 | |
@api_view(['GET']) | |
@permission_classes((IsAuthenticated,)) | |
def download(file): |
{ | |
"container_commands": { | |
"celery_configure": { | |
"command": "mv /tmp/100_celery_worker.sh /opt/elasticbeanstalk/hooks/appdeploy/post && chmod 774 /opt/elasticbeanstalk/hooks/appdeploy/post/100_celery_worker.sh", | |
"leader_only": true | |
} | |
} | |
} |
files: | |
"/tmp/100_celery_worker.sh": | |
mode: "000755" | |
owner: root | |
group: root | |
content: | | |
#!/bin/sh | |
# for_log_and_pid | |
mkdir -p /var/log/celery/ /var/run/celery/ |
""" | |
Django ORM Optimization Tips | |
Caveats: | |
* Only use optimizations that obfuscate the code if you need to. | |
* Not all of these tips are hard and fast rules. | |
* Use your judgement to determine what improvements are appropriate for your code. | |
""" | |
# --------------------------------------------------------------------------- |
def add_q_object(self, keyword, q_object, query_parm): | |
for key in keyword: | |
kwargs = {query_parm: key.strip()} | |
q_object.add(Q(**kwargs), q_object.OR) | |
def filter_applicants(self, _queryset=None): | |
my_applicants = _queryset |
BY: Edd Yerburgh
Slides: https://slides.com/eddyerburgh/testing-a-vuex-store
Twitter: https://twitter.com/EddYerburgh
By: Diana Rodriguez
from ast import literal_eval | |
def convert_to_type(input_data): | |
try: | |
return literal_eval(input_data) | |
except (ValueError, SyntaxError): | |
return input_data |
// Bootstrap datepicker | |
$('.input-daterange input').each(function() { | |
$(this).datepicker('clearDates'); | |
}); | |
// Set up your table | |
table = $('#my-table').DataTable({ | |
paging: false, | |
info: false | |
}); |