Skip to content

Instantly share code, notes, and snippets.

View jfunez's full-sized avatar

Juan Funez jfunez

  • iib-institut.de
  • Berlin, Germany
View GitHub Profile
@jfunez
jfunez / send_mail.py
Created January 11, 2013 14:18
django send mail for managers
# -*- coding: utf-8 -*-
from django.conf import settings
from django.template.loader import render_to_string
from mailer.models import Message
from mailer import PRIORITY_MAPPING
subject = settings.EMAIL_SUBJECT_PREFIX + u'Pending Registrations'
priority = PRIORITY_MAPPING['high']
context = {
@jfunez
jfunez / gist:6505611
Created September 10, 2013 06:16
Tsuru private beta
$ git push tsuru master
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 414 bytes, done.
Total 4 (delta 0), reused 0 (delta 0)
remote: /
remote: /
remote: Reading package lists...
remote: Building dependency tree...
import base64
import os
from tastypie.fields import FileField
from django.core.files.uploadedfile import SimpleUploadedFile
class Base64FileField(FileField):
"""
A django-tastypie field for handling file-uploads through raw post data.
It uses base64 for en-/decoding the contents of the file.
Usage:
from os.path import splitext
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.template.defaultfilters import filesizeformat
class FileValidator(object):
"""
Validator for files, checking the size, extension and mimetype.
@jfunez
jfunez / loggers_settings.py
Created June 10, 2014 13:47
django_loggers_settings
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
},
},
'handlers': {
'default': {
@jfunez
jfunez / setup.py
Created December 1, 2015 18:01 — forked from rochacbruno/Makefile
Perfect setup.py
import pip
try:
from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup, find_packages
links = [] # for repo urls (dependency_links)
requires = [] # for package names
@jfunez
jfunez / 0_reuse_code.js
Created February 11, 2016 12:48
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jfunez
jfunez / gen_secret_key.py
Created February 24, 2016 15:06
gerar secret key
import os
import binascii
binascii.hexlify(os.urandom(24))
@jfunez
jfunez / test_login_selenium.py
Created March 4, 2016 13:39
example of login with selenium
# pip install selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://127.0.0.1:5000/admin/login/")
driver.maximize_window()
input_login = driver.find_element_by_id('email')
@jfunez
jfunez / modal.fix.js
Created April 9, 2016 18:06
remove modal content to avoid caching
$(function () {
$('#modal-id').on('shown', function () {
/* add code here to be executed when modal is displayed */
});
$('#modal-id').on('hidden', function () {
/* the next line will remove from DOM the content of the modal body */
$(this).removeData('modal');
});
});