This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to add a field to the Django Admin Add User form | |
# using UserCreationForm. Add this to a admin.py and alter | |
# to whatever fields you'd like | |
from django.contrib.auth.forms import UserCreationForm | |
from django.contrib.auth.models import User | |
from django.contrib.auth.admin import UserAdmin | |
from django import forms | |
from django.utils.translation import ugettext_lazy as _ | |
from django.contrib import admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Display Images From A Folder with PHP | |
<?php | |
$files = glob("images/*.*"); | |
for ($i=1; $i<count($files); $i++) | |
{ | |
$num = $files[$i]; | |
echo '<img src="'.$num.'" alt="random image">'." "; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from social_auth.backends.facebook import FacebookBackend | |
from social_auth.backends import google | |
def social_extra_values(sender, user, response, details, **kwargs): | |
result = False | |
if "id" in response: | |
from apps.photo.models import Photo | |
from urllib2 import urlopen, HTTPError | |
from django.template.defaultfilters import slugify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function($) { | |
$('form[data-async]').live('submit', function(event) { | |
var $form = $(this); | |
var $target = $($form.attr('data-target')); | |
$.ajax({ | |
type: $form.attr('method'), | |
url: $form.attr('action'), | |
data: $form.serialize(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Extended Walker class for use with the | |
* Twitter Bootstrap toolkit Dropdown menus in Wordpress. | |
* Edited to support n-levels submenu. | |
* @author johnmegahan https://gist.github.com/1597994, Emanuele 'Tex' Tessore https://gist.github.com/3765640 | |
* @license CC BY 4.0 https://creativecommons.org/licenses/by/4.0/ | |
*/ | |
class BootstrapNavMenuWalker extends Walker_Nav_Menu { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.core.mail import send_mail | |
from django.contrib import auth | |
from django.contrib.auth.models import ( | |
AbstractBaseUser, | |
BaseUserManager, | |
Group, | |
Permission, | |
_user_get_all_permissions, | |
_user_has_perm, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
img:hover { | |
-webkit-filter: grayscale(0%); | |
-webkit-transition: .5s ease-in-out; | |
-moz-filter: grayscale(0%); | |
-moz-transition: .5s ease-in-out; | |
-o-filter: grayscale(0%); | |
-o-transition: .5s ease-in-out; | |
} | |
img { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import falcon #webframework | |
import json #json duh! | |
import requests #sane http get/post/etc. | |
from bs4 import BeautifulSoup #sane htmlparser | |
def get_soup(): | |
#Link u guys provided.... get me the .json !!!! | |
html_doc = requests.get("http://www.jmarcano.com/mipais/geografia/province/municipios/").text | |
if not html_doc: | |
#lame sanity check. TODO: make proper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Translated default messages for the jQuery validation plugin. | |
* Locale: ES | |
*/ | |
jQuery.extend(jQuery.validator.messages, { | |
required: "Este campo es obligatorio.", | |
remote: "Por favor, rellena este campo.", | |
email: "Por favor, escribe una dirección de correo válida", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Hide permission in the Django admin which are irrelevant, and not used at all. | |
""" | |
from django.contrib import admin | |
from django.contrib.auth.admin import GroupAdmin, UserAdmin | |
from django.contrib.auth.models import Group, User | |
class PermissionFilterMixin(object): | |
def formfield_for_manytomany(self, db_field, request=None, **kwargs): |
OlderNewer