Skip to content

Instantly share code, notes, and snippets.

View bernardoduarte's full-sized avatar

Bernardo da Eira Duarte bernardoduarte

View GitHub Profile
@tclancy
tclancy / django_management_profile.py
Last active January 3, 2023 22:18
Profiling Django Management Command
from cProfile import Profile
from django.core.management.base import BaseCommand
class ProfileEnabledBaseCommand(BaseCommand):
"""Enable profiling a command with --profile.
Requires child class to define _handle instead of handle.
via https://gist.github.com/dfrankow
"""
@aaugustin
aaugustin / admin.py
Last active August 7, 2022 19:39
Read-only ModelAdmin for Django
from django.contrib import admin
class ReadOnlyModelAdmin(admin.ModelAdmin):
"""
ModelAdmin class that prevents modifications through the admin.
The changelist and the detail view work, but a 403 is returned
if one actually tries to edit an object.
@iansheridan
iansheridan / git-cheat-sheet.md
Created March 15, 2011 14:25
A cheat sheet for GIT

Setup

git clone <repo>

clone the repository specified by ; this is similar to "checkout" in some other version control systems such as Subversion and CVS

Add colors to your ~/.gitconfig file:

@elder
elder / getopt.c
Created June 21, 2010 16:27
Exemplo de uso da função getopt em C
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
int main (int argc, char *argv[])
{
int opcao; // Opção passada pelo usuário ao programa.
int indice; // Usado para pegar argumentos que não são opções
// Nem argumentos usados em opções.