macks  [ Profile ]

Sort by: Date / Title /

  1. 4 weeks ago
    1. #instalar python - twitter http://code.google.com/p/python-twitter/downloads/list
    2.  
    3. import twitter
    4. import re
    5. api      = twitter.Api(username, password)
    6. #1. actualizar el estado
    7.  api.PostUpdate('Tweet desde python ;)') #
    8.  
    9. #2. recuperar tus posts con links a otros uasuarios o los hashtags
    10.     statuses = api.GetUserTimeline()
    11.     posts=[]
    12.  
    13.     for s in statuses:
    14.         tweet = s.text;
    15.         hash_regex = re.compile(r'#[0-9a-zA-Z+_]*',re.IGNORECASE)
    16.         user_regex = re.compile(r'@[0-9a-zA-Z+_]*',re.IGNORECASE)
    17.         savelog(hash_regex,'hashR')
    18.         savelog(smart_str(tweet),'tweet')
    19.         for tt in user_regex.finditer(tweet):
    20.             url_tweet = tt.group(0).replace('@','')
    21.             tweet = tweet.replace(tt.group(0),
    22.                     '<a href="http://twitter.com/'+
    23.                     url_tweet+'" title="'+
    24.                     tt.group(0)+'">'+
    25.                     tt.group(0)+'</a>')
    26.  
    27.         for th in hash_regex.finditer(tweet):
    28.                 url_hash = th.group(0).replace('#','%23')
    29.                 if len ( th.group(0) ) > 2:
    30.                     tweet = tweet.replace(th.group(0),
    31.                             '<a href="http://search.twitter.com/search?q='+
    32.                             url_hash+'" title="'+
    33.                             th.group(0)+'">'+
    34.                             th.group(0)+'</a>');
    35.  
    36.         posts.append({'summary': tweet})
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2095"></script>
  2. 1 month 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>
  3. 1 month ago
    1. from django.db import connection
    2. q = connection.queries # todos los querys y los tiempos de respuesta
    3.  
    4. savelog(obj.query,'query')  # query de una consulta
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2084"></script>
  4. sponsorised links
  5. 2 months 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. 2 months 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. 3 months ago
    binary
    1. SELECTFROM `table`  WHERE BINARY `COLUMN` = 'value'
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2078"></script>
  8. 3 months ago
    1. savelog(media.query.as_sql())
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2077"></script>
  9. 4 months ago
    1. SELECT id,title INTO OUTFILE "c:/result.text"
    2. FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    3. LINES TERMINATED BY "n"
    4. FROM property;
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2074"></script>
  10. 4 months 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>
  11. 4 months 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>

First / Previous / Next / Last / Page 1 of 6 (55 posteets)