Skip to content

Instantly share code, notes, and snippets.

function checar_tiempo (startdate, tiempo_de_creacion) {
if(startdate.getSeconds() > tiempo_de_creacion.getSeconds() && startdate.getMinutes() === tiempo_de_creacion.getMinutes() && startdate.getDay() === tiempo_de_creacion.getDay() && startdate.getMonth() === tiempo_de_creacion.getMonth() && startdate.getFullYear() === tiempo_de_creacion.getFullYear() && startdate.getHours() === tiempo_de_creacion.getHours()){
tiempo = "A few ";
quees = "seconds";
}else if(startdate.getMinutes() > tiempo_de_creacion.getMinutes() && startdate.getDay() === tiempo_de_creacion.getDay() && startdate.getMonth() === tiempo_de_creacion.getMonth() && startdate.getFullYear() === tiempo_de_creacion.getFullYear() && startdate.getHours() === tiempo_de_creacion.getHours()){
tiempo = startdate.getMinutes() - tiempo_de_creacion.getMinutes() ;
quees = " minutes";
@Verurteilt
Verurteilt / client.py
Last active December 17, 2015 07:19
CouchDb client in process
import base64
import urllib2
import json
import httplib
class CouchDatabase(object):
def __init__(self,host="http://localhost", port=5984):
http://stackoverflow.com/questions/4475251/django-through-model-iteration
http://www.djangobook.com/en/2.0/chapter10.html
@Verurteilt
Verurteilt / gist:5580282
Created May 14, 2013 22:45
database.py
import base64
import urllib2
import json
import httplib
class CouchDatabase(object):
def __init__(self, host="localhost", port=5984):
https://gist.github.com/anonymous/5580444
@Verurteilt
Verurteilt / gist:5580281
Created May 14, 2013 22:45
document.py
from database import CouchDatabase
import base64
import urllib2
import json
import httplib
class CouchDocument(CouchDatabase):
def __init__(self, host="http://localhost", port=5984, database="pruebas"):
def pdf(request):
response = HttpResponse(content_type="application/pdf")
response['Content-Disposition'] = 'attachment; filename="UTEL_Tramites.pdf"'
file_ = GenerarPDF(response=response, user=User.objects.get(id=1))
to_admin = 'mini.guero@hotmail.com'
html_content = "Informacion recibida de <br><br><br>***Mensaje****<br><br>"
msg = EmailMessage('Correo de Contacto', html_content, 'from@server.com', [to_admin])
msg.attach('UTEL_Tramites.pdf', response.content, 'application/pdf')
msg.send()
return response
@Verurteilt
Verurteilt / admin.py
Created June 5, 2013 23:27
class DocumentoAdmin(admin.ModelAdmin): list_display = ('remitente','area','tipodoc','asunto','estado','ver_seguimiento','ver_historial','archivo') #list_display_links = ['remitente','estado'] search_fields = ('asunto__nom_asunto','remitente__mom_pernat') fieldsets = ( ('Datos del Documento', { 'fields': ('area','remitente','tipodoc','asunto','a…
class DocumentoAdmin(admin.ModelAdmin):
search_fields = ('asunto__nom_asunto','remitente__mom_pernat')
raw_id_fields = ('remitente',)
valid_lookups = ('asunto')
def get_list_display(self, request):
if request.user.is_admin:
list_display = ('remitente','area','tipodoc','asunto','estado','ver_seguimiento','ver_historial','archivo')
return list_display
else:
list_display = ('asunto',)
(18:11:26) erre: http://www.youtube.com/watch?v=MG2fSeis30E
(18:13:37) erre: http://www.youtube.com/watch?NR=1&feature=endscreen&v=TODDnIqlxi0
@Verurteilt
Verurteilt / gist:5844140
Created June 23, 2013 07:19
DOCX email class
def docx(request):
response = HttpResponse(content_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document")
response['Content-Disposition'] = 'attachment; filename="archivo.docx"'
html_content = "Informacion recibida de <br><br><br>***Mensaje****<br><br>"
msg = EmailMessage('Correo de Contacto', html_content, 'from@server.com', [to_admin])
file_ = open('archivo.docx', 'r+')
msg.attach('archivo.docx', file_.read(), 'application/vnd.openxmlformats-officedocument.wordprocessingml.document')
msg.send()
return response