macks posteets tagged soluciones  [ Profile ]

Sort by: Date / Title /

  1. 3 years ago
    si se quiere saber a que url final nos redirecciona.
    1. import urllib2
    2. f = urllib2.urlopen('https://graph.facebook.com/macks.r2r/picture')
    3. print f.geturl()
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2106"></script>
  2. 3 years ago
    1. #---libs/date.py
    2. def format_date(value, format="%d/%m/%Y %H:%M:%S"):
    3.         return value.strftime(format)
    4.  
    5. #-----settings
    6. from libs.filters import format_date
    7. from jinja2 import Environment, FileSystemLoader
    8. TEMPLATE_ENV.filters["format_date"] = format_date
    9.  
    10. #---template
    11. <td>{{ h.date|format_date('%d/%m/%Y') }}</td>
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2104"></script>
  3. 4 years ago
    1. image = Image.open(imageField)
    2. if image.mode != "RGB":
    3.     image = image.convert("RGB")
    4.     #big
    5.     image.save('image.jpg')
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2090"></script>
  4. sponsorised links
  5. 4 years ago
    1. #1
    2. from django.db import models
    3. from django.contrib.auth.models import User, UserManager
    4.  
    5. class CustomUser(User):
    6.     birthday = models.DateField()
    7.     activation_key = models.CharField(max_length=255, blank=True, default='')
    8.     photo_url = models.CharField(max_length=50, blank=True) # cant incrementada de votaciones
    9.     User._meta.get_field('username')._unique = False
    10.     User._meta.get_field('email')._unique = True
    11.     User._meta.get_field_by_name('username')[0].max_length=75
    12.  
    13. #2 save child class
    14. from users.models import CustomUser
    15. def saveCustomUsers(request):
    16.     usr = CustomUser()
    17.     usr.username = 'macks'
    18.     usr.password = '123456'
    19.     usr.activation_key = 'sfsdf123456'
    20.     usr.birthday = datetime.now()
    21.     usr.photo_url = 'image.jpg'
    22.     usr.save()
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2083"></script>
  6. 4 years ago
    1. #agregar templatetags a APPS de settings
    2.  
    3. 1.-
    4. apps/templatetags/userInfoTag.py
    5.  
    6. # -*- coding: utf-8 -*-
    7. from django import template
    8. from django.shortcuts import get_object_or_404
    9. from django.contrib.auth.models import User
    10.  
    11. register = template.Library()
    12. @register.inclusion_tag('admin/users/inclusionTags/userRecordsTags.html', takes_context=True)
    13. def userRecords(context):
    14.     request = context['request']
    15.     user = get_object_or_404(User, id=request.user.id)
    16.     userName = user.first_name + ' ' + user.last_name
    17.    
    18.     return {'userName': userName}
    19.  
    20. 2.-
    21. apps/templatetags/__init__.py
    22. from django.template import add_to_builtins
    23. add_to_builtins('templatetags.userInfoTag')
    24.  
    25. 3.-
    26. templates/admin/users/inclusionTags/userRecordsTags.html
    27. {{ userName }} # return value of userInfotag.py
    28.  
    29. 4.-
    30.  
    31. #se puede usar la plantilla userRecords.html en culaquiera otra plantilla
    32.  
    33. templates/admin/users/indexSuccess.html
    34. <td>{% userRecords %}</td>  #def userRecords
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2079"></script>
  7. 4 years ago
    descragar y cambiar de nombre al archivo
    1. def downloadImage(self):
    2.     img_url = 'http://img1cdn.adoosimg.com/b195d543e38e349deac032b41be043c7-1-5.jpg'
    3.     imgName = 'b195d543e38e349deac032b41be043c7-1-5.jpg'
    4.     imgN = "peque_%s"%imgName.replace('5.','7.') if imgName[-5:]=='5.jpg' else imgName
    5.    
    6.     file_path = "%s/adoos/%s" % (settings.UPLOAD_PATH, imgN)
    7.     downloaded_image = file(file_path, "wb")
    8.  
    9.     image_on_web = urllib.urlopen(img_url)
    10.     while True:
    11.         buf = image_on_web.read(65536)
    12.         if len(buf) == 0:
    13.             break
    14.         downloaded_image.write(buf)
    15.     downloaded_image.close()
    16.     image_on_web.close()
    17.  
    18.     return  file_path
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2073"></script>
  8. 4 years ago
    1. def __validateVideoName(videoname):
    2.     import string
    3.     rs = False
    4.     if videoname:
    5.         whiteSpace = False if re.search(' ',videoname) else True
    6.         specialChar = True if re.compile('[a-zA-Z0-9._-]+$').match(videoname) else False
    7.         if whiteSpace and specialChar:
    8.             rs = True
    9.            
    10.     return rs
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2069"></script>
  9. 4 years ago
    1. dsc = ['uno','dos','tres']
    2. line = """#%d# rn
    3. %s rnrn""" % (i+1, dsc)
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2067"></script>
  10. 4 years ago
    1. def remove_html_tags(data):
    2.     p = re.compile(r'<[^<]*?/?>')
    3.     return p.sub('', data)
    4.  
    5.  
    6. Here is another function to remove more than one consecutive white spaces:
    7.  
    8. def remove_extra_spaces(data):
    9.     p = re.compile(r's+')
    10.     return p.sub(' ', data)
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2066"></script>
  11. 4 years ago
    usando la libreria ffmpeg
    1. import commands
    2. import os
    3.  
    4. def execute():
    5.         cmd = 'c:/ffmpeg/ffmpeg.exe -y -itsoffset -4 -i c:/input.mpg -vframes 1 -s 100x90 -f image2 c:/uploads/img_gen.jpg'
    6.         #c = commands.getoutput(cmd) # linux
    7.         c = os.system(self.cmd) #windows
    8.         return c
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2058"></script>

First / Previous / Next / Last / Page 1 of 2 (14 posteets)