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
@rg3915
rg3915 / index.html
Last active February 28, 2023 14:00
AlpineJS child component
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<link rel="shortcut icon" href="https://alpinejs.dev/favicon.png">
<title>AlpineJS</title>
<!-- Bulma -->
@rg3915
rg3915 / fix_app.sh
Last active June 23, 2024 05:59
fix app Django
# Fix new app
DIR=$(pwd)
APP_NAME=$1
# Add route on urls.py
sed -i "\@path('admin@ s@.*@ path('$APP_NAME/', include('backend.$APP_NAME.urls', namespace='$APP_NAME')),\n&@" $DIR/backend/urls.py
# Insert text in INSTALLED_APPS
sed -i "s/\]\s*$/ 'backend.$APP_NAME',\n]/" $DIR/backend/settings.py
@rg3915
rg3915 / extract.py
Created February 14, 2023 05:48
Extract all keys recursively - all keys json
import json
data = """
{
"data": {
"items": [
{
"name": "SciELO Preprints",
"type": "dataverse",
"url": "https://data.scielo.org/dataverse/preprints",
@rg3915
rg3915 / README.md
Created February 10, 2023 17:28
sync fork SciELO

Fluxo das branchs e sincronização dos forks

  • Fazer um fork do repositório

E clonar a partir do seu repositório.

git clone [email protected]:<SEU-USERNAME>/core.git
@rg3915
rg3915 / README.md
Created January 30, 2023 20:30
Aplicando filtros por Inquilino

O importante é aplicar o filtro corretamente.

@rg3915
rg3915 / README.md
Last active January 30, 2023 15:36
Django: Permissões no template - django permissions template
@rg3915
rg3915 / README.md
Created January 18, 2023 06:25
Como escrever um bom gist

Como escrever um bom gist

Escreva em Markdown.

Repare que eu tenho um README.md e outros arquivos.

  • Se for dúvidas, descreva o problema. Ex:

Problema

@rg3915
rg3915 / README.md
Created December 23, 2022 05:28
django form default value

Objetivo: definir um valor default para um campo, simples né?

Pega a visão:

  • __init__
class MyForm(forms.ModelForm):

 def __init__(self, *args, **kwargs):
@rg3915
rg3915 / README.md
Created December 20, 2022 23:28
AWS S3 storage config
pip install python-decouple  # variaveis de ambiente
pip install django-storages  # storage
cat << EOF > .env
AWS_ACCESS_KEY_ID=**********
AWS_SECRET_ACCESS_KEY=****************
AWS_STORAGE_BUCKET_NAME=brejinho