Skip to content

Instantly share code, notes, and snippets.

View klebercode's full-sized avatar
🎯
Focusing

Kleber Soares klebercode

🎯
Focusing
View GitHub Profile
@rcotrina94
rcotrina94 / regex para staticfiles en Django
Last active May 9, 2023 08:17
Find and Replace Django static files from template
Find what:
`(href|src)="([a-zA-Z0-9/.-]+[^.html])"`
Replace with:
`$1=\"{% static "assets/$2" %}"`
@shymonk
shymonk / customize-save-in-django-admin-inline-form.org
Last active April 14, 2024 02:55
How to customize save in django admin inline form?

Customize Save In Django Admin Inline Form

Background

This is a common case in django ORM.

from django.db import models

class Author(models.Model):
@zxbodya
zxbodya / S3-CORS-config.xml
Last active April 6, 2024 03:40
Client side uploads to s3, with pre-signed upload form (PHP/JS)
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
@vst
vst / todoist.py
Last active March 17, 2018 22:01
A command line tool for Todoist
## Got this script initially from https://gist.github.com/kbl/5970131
###########
# IMPORTS #
###########
import ConfigParser
import argparse
import json
import os
@thulioph
thulioph / mapa.js
Created December 27, 2013 22:32
código final e completo do mapa personalizado / Artigo: API Google Maps V3 - blog.thulioph.com
function initialize() {
// Exibir mapa;
var myLatlng = new google.maps.LatLng(-8.0631495, -34.87131120000004);
var mapOptions = {
zoom: 17,
center: myLatlng,
panControl: false,
// mapTypeId: google.maps.MapTypeId.ROADMAP
mapTypeControlOptions: {
from django.contrib import admin
from .models import Gallery, Image
class ImageInline(admin.StackedInline):
model = Image
extra = 0
fields = ('image',)
# Import datetime
from datetime import date
today = datetime.today()
date = date.fromordinal(today.toordinal() - 30) # today - 30 days
object_list = Model.objects.filter(date_at__gte=date)
@pebreo
pebreo / django-jquery-demo.py
Last active April 29, 2020 05:15
jQuery AJAX + Django SIMPLE DEMO
# views.py - django app called ajx
from django.shortcuts import render, get_object_or_404, redirect, HttpResponse, render_to_response, HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.contrib.auth import authenticate, login
import json
def mygetview(request):
if request.method == 'GET':
@rochacbruno
rochacbruno / admin.py
Created November 27, 2013 23:29
Django inlines
class PaiFilhosInline(admin.StackedInline):
model = PaiFilhos
fk_name = 'pai'
raw_id_fields = ['filho']
class PaiAdmin(models.ModelAdmin):
inlines = [PaiFilhosInline]
@luzfcb
luzfcb / anp_crawler.py
Last active April 2, 2018 04:15
Implementação simples de um Crawler pra extrair dados do site a ANP
# coding=utf-8
"""
NAO FUNCIONA MAIS. O sistema de CAPTCHA foi trocado.
**Implementa um Webcrawler para extracao de dados da pesquisa de media de precos realizada periodicamente pela ANP**
Desenvolvido por Fabio C. Barrionuevo da Luz. - 2013
Simple crawler to ANP site
Copyright (C) 2013 Fabio C. Barrionuevo da Luz.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License