Skip to content

Instantly share code, notes, and snippets.

View rg3915's full-sized avatar
🏠
Working from home

Regis Santos rg3915

🏠
Working from home
View GitHub Profile
@vallahor
vallahor / README.md
Last active January 13, 2024 15:20

usage

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:

@guilhermecarvalhocarneiro
guilhermecarvalhocarneiro / build.py
Created February 15, 2022 22:08
Código para automatizar a geração das urls, forms, templates, views e de um projeto DRF.
"""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
@toninhocajueiro
toninhocajueiro / gist:086ae0f9dca7db0cebe2256507d26844
Created December 19, 2021 00:56
Função simples pra testar download de arquivo no DRF
# 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):
@bahiamartins
bahiamartins / call_celery_post_deploy_aws.config
Created May 15, 2019 00:23
call celery in AWS Elastic Beanstalk via post deploy. Process of Daemonization using Supervisord
{
"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
}
}
}
@bahiamartins
bahiamartins / celery_daemon.config
Created May 15, 2019 00:21
Daemonization process of Celery and Celery Beat using Supervisord in AWS Elastic Beanstalk
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.
"""
# ---------------------------------------------------------------------------
@olivx
olivx / filter_applicants.py
Last active September 22, 2018 00:11
filter_applicants multiples elements separator per ', ' example with Q() object
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
@kevinbreaker
kevinbreaker / Slides.md
Last active September 3, 2018 05:22
Slides dos palestrantes do Vuejs Summit 2018
@dunossauro
dunossauro / convert_string_types.py
Last active December 14, 2018 18:21
Conversão de strings em tipos válidos do python usando literal_eval
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
});