Skip to content

Instantly share code, notes, and snippets.

View tarsil's full-sized avatar
🖖

Tiago Silva tarsil

🖖
View GitHub Profile
@tarsil
tarsil / procedure-to-archive-git-branches.md
Created October 9, 2023 15:00 — forked from zkiraly/procedure-to-archive-git-branches.md
Procedure to archive git branches.
version: "3.8"
services:
db:
restart: always
image: postgres:14
environment:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
POSTGRES_DB: "testsuite"
@tarsil
tarsil / settings.json
Last active October 21, 2023 15:35
Example settings.vscode
{
"python.analysis.disabled": ["unnecessary-semicolon"],
"python.analysis.autoSearchPaths": true,
"python.analysis.extraPaths": [],
"terminal.integrated.env.osx": {
"PYTHONPATH": "${env:PYTHONPATH}:${workspaceFolder}/{{ cookiecutter.project_name }}",
},
"terminal.integrated.env.linux": {
"PYTHONPATH": "${env:PYTHONPATH}:${workspaceFolder}/{{ cookiecutter.project_name }}",
},
@tarsil
tarsil / brokers.py
Created January 26, 2022 14:12 — forked from dnmellen/brokers.py
Improved EagerBroker for dramatiq
from dramatiq.brokers.stub import StubBroker
class EagerBroker(StubBroker):
"""Used by tests to simulate CELERY_ALWAYS_EAGER behavior.
https://github.com/Bogdanp/dramatiq/issues/195
Modified by @dnmellen to support pipelines and groups
"""
def process_message(self, message):
@tarsil
tarsil / create-superuser.py
Created January 11, 2022 15:17 — forked from c00kiemon5ter/create-superuser.py
Extend Django's management createsuperuser command to allow non-interactive creation of a superuser with a password.
"""
Extend createsuperuser command to allow non-interactive creation of a
superuser with a password.
Instructions:
mkdir -p path-to-your-app/management/commands/
touch path-to-your-app/management/__init__.py
touch path-to-your-app/management/commands/__init__.py
@tarsil
tarsil / covalent_prepare_nft_metadata_batch.py
Created December 9, 2021 16:20 — forked from adamwhitakerwilson/covalent_prepare_nft_metadata_batch.py
By using the Covalent APIs, given an NFT contract and chain id, fetch all token ids and prepare an array of urls that call Get External NFT Metadata to be passed into the body for the batch query endpoint.
import requests
import time
import urllib3
def check_internet(url):
try:
req = urllib3.PoolManager().request("GET", url)
if str(req.status) != "500":
if str(req.status) != "404":
@tarsil
tarsil / nginx.conf
Created November 30, 2021 15:49 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
# Copyright (c) 2021 Tiago Silva <https://github.com/tarsil>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@tarsil
tarsil / flask_view_generics.py
Last active January 14, 2021 12:30
Generics for Flask class based views that aims to replicate the Django Views
# Copyright (c) 2020 Tiago Silva <https://github.com/tarsil>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@tarsil
tarsil / pagination.py
Last active January 14, 2021 12:25
Django Rest Framework Pagination
# Copyright (c) 2017 Tiago Silva <https://github.com/tarsil>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in