Skip to content

Instantly share code, notes, and snippets.

View marceloleiva's full-sized avatar

Marcelo Leiva marceloleiva

View GitHub Profile
@marceloleiva
marceloleiva / determinar_encoding.py
Last active September 30, 2016 13:56
Determinar encoding
import chardet
def determinar_encoding(input_file='despachos.csv'):
file = open(input_file, 'rb').read()
encoding = chardet.detect(file)
if encoding:
return encoding['encoding']
return None
@marceloleiva
marceloleiva / django_reversion.md
Created July 12, 2016 17:39 — forked from goutham2027/django_reversion.md
using django reversion
pip install django-reversion

Add reversion to INSTALLED_APPS

INSTALLED_APPS = [
...
...
...
@marceloleiva
marceloleiva / forms.py
Created December 10, 2015 22:37 — forked from neara/forms.py
Django Class Based Views and Inline Formset Example
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
from models import Sponsor, Sponsorship
class SponsorForm(ModelForm):
class Meta:
model = Sponsor
@marceloleiva
marceloleiva / bootstrap-tables2.css
Created November 20, 2015 18:06 — forked from shayh/bootstrap-tables2.css
bootstrap3 django-tables2 based on this gist https://gist.github.com/dyve/5458209 I created a template that works wtih https://github.com/dyve/django-bootstrap3 make sure you have 'django.core.context_processors.request' in your TEMPLATE_CONTEXT_PROCESSORS
.table-container th.asc:after {
content: '\0000a0\0025b2';
}
.table-container th.desc:after {
content: '\0000a0\0025bc';
}
.pagination {
text-align: center;
}
@marceloleiva
marceloleiva / django_sleep.py
Last active August 29, 2015 14:27 — forked from josharian/django_sleep.py
Simple Django middleware that delays the processing of each request
"""
This module provides very simple Django middleware that sleeps on every request.
This is useful when you want to simulate slow response times (as might be
encountered, say, on a cell network).
To use, add this middleware, and add a value for SLEEP_TIME to your settings.
Possible future feature: Look for an X-Django-Sleep header on each request,
to let the client specify per-request sleep time.
## http://pastebin.ubuntu.com/11974308/
## problemas con encoding Ã
import codecs
import csv
def gen():
f = codecs.open("Ventas.csv", "rb", "utf16")
yield next(f).encode("utf-8")
for i in f:
import re
cadena = "open('../Attachment/ViewAttachment.aspx?enc=%2fnzOJlvQE1Q5cGviPAFZ%2fAwP4DzDJBri%2bWK1%2fBimEpHECqkBoS5%2fQKtpmZ8x8fmj8rudm2jNRnGPgHzbTdOH3wtcK8STvRkmfjkfy8XUF6xwUBoBbErAErrL7%2bg3Tt6XjP5AEjY6C3dNZP8NBOhAKlniJExwmfRWBRMuA%2bUju6Isl8ncH617vzflGWloZhbNcolIDIK7lzetNeOBVdzdNVV6Yrz7sbhBYzTkIIjuxmZVoHFTrr7h0sqPmH%2bU5y5iaWXxqB%2f1h7awOfzQPqpOt6sg3ZpXKUvaD6XO8fikAjmcWJ3FqzcS3KRFNfiD4S7V','MercadoPublico', 'width=850, height=700, status=yes, scrollbars=yes, left=0, top=0, resizable=yes');window.event.returnValue=false;"
patron = r".+\?enc=([a-zA-Z0-9%]+)"
patron2 = r".*enc=([^']*).*"
resultado = re.match(patron, cadena)
print(resultado.group(1))
print('')

Guide to install PyQt5 on Mac OS X with python 3.4 virtualenv

Description

A simple guide to install PyQt5 on Mac OS X and use python 3.4 on a virtualenv.

Requirements

  • python 3.4
  • Qt5
  • SIP
/*!
* Grunt
* $ npm install grunt-contrib-uglify grunt-autoprefixer grunt-contrib-cssmin grunt-contrib-imagemin grunt-contrib-sass grunt-contrib-watch grunt-contrib-concat grunt-contrib-clean grunt-contrib-jshint grunt-notify --save-dev
*/
module.exports = function(grunt) {
grunt.initConfig({
// Sass
@marceloleiva
marceloleiva / Vagrantfile
Created June 16, 2015 14:23
Conectar Django remotamente con MySQL en Vagrant
config.vm.box = "chef/ubuntu-14.04"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.network :forwarded_port, guest: 3306, host: 9306