Skip to content

Instantly share code, notes, and snippets.

View Asinox's full-sized avatar
💭
React + Cinema = App!

Juan Miguel Calcaño Asinox

💭
React + Cinema = App!
View GitHub Profile
@riklomas
riklomas / adding-to-user-admin-form.py
Created August 6, 2010 15:01
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
# 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
@projectxcappe
projectxcappe / fromfolder.php
Created September 15, 2011 23:22
Display Images From A Folder with PHP
//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">'."&nbsp;&nbsp;";
}
?>
@dchaplinsky
dchaplinsky / avatars.py
Created September 28, 2011 18:12
Get avatars from social networks (facebook and google) with django-social-auth
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
@havvg
havvg / ajax-form.js
Created August 1, 2012 13:20
jQuery AJAX form submit with Twitter Bootstrap modal
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(),
@setola
setola / functions.php
Last active September 25, 2020 18:29 — forked from johnmegahan/functions.php
Extended Walker class for use with the Twitter Bootstrap toolkit Dropdown n-levels menus in Wordpress.
<?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 {
@rvause
rvause / models.py
Created December 17, 2012 09:42
User model for Django with an email/password login, no username
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,
@bergantine
bergantine / gist:5243223
Last active September 27, 2018 03:04
CSS grayscale filter (go from grayscale to full color on hover) #css #sethneilson
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 {
@elpargo
elpargo / provinciasapp.py
Created May 28, 2013 12:26
API de provincias v2 + tester + runner
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
@farandal
farandal / gist:6144701
Created August 3, 2013 01:34
Translated default messages for the jQuery validation plugin. Spanish
/*
* 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",
@vdboor
vdboor / patch_admin_permissions_list.py
Last active March 29, 2021 11:10
Patch Django admin to hide useless default permissions.Import this file somewhere in an `__init__.py` or `admin.py` file.
"""
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):