Skip to content

Instantly share code, notes, and snippets.

View luzfcb's full-sized avatar

Fábio C. Barrionuevo da Luz luzfcb

View GitHub Profile
@luzfcb
luzfcb / middleware.py
Created January 8, 2016 19:59 — forked from tclancy/middleware.py
Django middleware for Pympler
# encoding: utf-8
# Derived from Piotr Maliński's example with a few modifications to use logging and :
# http://www.rkblog.rk.edu.pl/w/p/profiling-django-object-size-and-memory-usage-pympler/
from pympler import muppy
from pympler.muppy import summary
from pympler.asizeof import asizeof
from django.conf import settings
import logging
@luzfcb
luzfcb / multipleforms.py
Created December 16, 2015 19:48 — forked from joaodubas/multipleforms.py
Django view to handle multiple forms. Basically it re-implements the form views structure to enable handling multiple forms.
# encoding: utf-8
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpResponseRedirect
from django.utils.text import force_text
from django.views.generic import View
from django.views.generic.base import ContextMixin, TemplateResponseMixin
class MultipleFormMixin(ContextMixin):
"""MultipleFormMixin -- Mixin that provides methods to show and handle
@luzfcb
luzfcb / forms.py
Created December 9, 2015 13:27 — forked from MarkusH/forms.py
Concurrent edit prevention through forms
from django import forms
from django.core.exceptions import ValidationError
from .models import Foo
class VersionNumberFormMixin(forms.Form):
version_number = forms.IntegerField(min_value=0, widget=forms.HiddenInput)
def __init__(self, *args, **kwargs):
@luzfcb
luzfcb / setup.py
Created December 1, 2015 19:35 — 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
@luzfcb
luzfcb / bobp-python.md
Created November 9, 2015 13:49 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@luzfcb
luzfcb / app.py
Last active August 29, 2015 14:26 — forked from drgarcia1986/app.py
Escape from GIL's block in intensive CPU tasks with ProcessPoolExecutor (web example)
import concurrent.futures
import muffin
app = muffin.Application(
'process_executor'
)
@luzfcb
luzfcb / generic_relations.py
Last active August 29, 2015 14:23 — forked from glasslion/generic_relations.py
Cache the generic relation field of all the objects in the queryset, using larger bulk queries ahead of time. Improved from original by Daniel Roseman: http://blog.roseman.org.uk/2010/02/22/django-patterns-part-4-forwards-generic-relations/ and justinfx's gist cache_generics.py : https://gist.github.com/justinfx/3095246#file-cache_generics-py Su…
'''
Cache the generic relation field of all the objects
in the queryset, using larger bulk queries ahead of time.
Improved from original by Daniel Roseman:
http://blog.roseman.org.uk/2010/02/22/django-patterns-part-4-forwards-generic-relations/
and
justinfx's gist cache_generics.py :
from django.views.generic import ListView
from django.views.generic.edit import FormMixin
from django.db.models import Q
class SearchView(FormMixin, ListView):
template_name_suffix = '_search'
filter_operator = 'contains'
allow_or_operator = False
def get_filter_operator(self):

Step 0:

Start downloading the install files from Oracle

Step 1:

Create a blank CentOs 6.5 instance

Convert to Oracle Linux: (source)

curl -O https://linux.oracle.com/switch/centos2ol.sh 
sh centos2ol.sh

Step 0:

Start downloading the install files from Oracle

Step 1:

Create a blank CentOs 6.5 instance

Convert to Oracle Linux: (source)

curl -O https://linux.oracle.com/switch/centos2ol.sh 
sh centos2ol.sh