Skip to content

Instantly share code, notes, and snippets.

View xpostudio4's full-sized avatar

Leonardo xpostudio4

View GitHub Profile
@xpostudio4
xpostudio4 / decorators_cheat_sheet.py
Last active September 20, 2016 16:49
Decorators Cheat Sheet
import functools # Part of Python standard library
def decorator(wrapped_function):
def _wrapper(*args, **kwargs):
# do something before the function call
result = wrapped_function(*args, **kwargs)
# do something after the function call
return result
return _wrapper
@xpostudio4
xpostudio4 / Template.html
Last active August 29, 2015 14:12
Question on stackoverflow
{% extends 'base.html' %}
{% load staticfiles %}
{% load selectize_tags %}
{% block extra_css %}
{% selectize_tags_media 'css' %}
{% endblock extra_css %}
{% block content %}
<form class="form-horizontal" action="." method="post">
@xpostudio4
xpostudio4 / gist:e548075275bdac2efcde
Created October 7, 2014 19:19
Jquery Ajax Post Request
var link = $(".btn");
link.click(
function(event){
//eliminate the default function
event.preventDefault();
$.ajax({
url: '/formulario/',
data: $('#new-form').serialize(),
type: "POST",
@xpostudio4
xpostudio4 / gist:7680855
Last active December 29, 2015 13:59
Custom User Model Django
#models.py
#Stdlib imports
import datetime
#Django core Imports
from django.db import models
from django.contrib.auth.models import (
BaseUserManager, AbstractBaseUser, PermissionsMixin
)