2012/05/15

Validating email without EmailField


Ref: http://www.djangofoo.com/39/validating-email-without-emailfiel

from django.core.validators import email_re

def is_valid_email(email):
    if email_re.match(email):
        return True
    return False

2012/04/29

Key Value Observing NSArray and NSDictionary

iOS SDK/Objective-C Key Value Observing (KVO) NSArray and NSDictionary

  1. http://streetsaheadllc.com/article/key-value-observing-nsarray-and-nsdictionary (Great Example)
  2. http://stackoverflow.com/questions/477204/key-value-observing-a-to-many-relationship-in-cocoa
  3. http://stackoverflow.com/questions/3478451/key-value-observing-with-an-nsarray




2012/04/26

Get file name after selecting a file via " input type='file' "



Javascript 
document.getElementById('fileInput').onchange = function () {alert('Selected file: ' + this.value);};

jQuery
$('input[type=file]').change(function(e){  $in=$(this);  $in.next().html($in.val());});



Ref:

2012/03/19

Django Imagekit - Dynamic Cache Path


def get_cache_dir(obj, filepath, cache_filename)
    today = datetime.now().date()
    custom_dir_name = "%s-%s-%s" % (today.year, today.month, today.day)     
    return os.path.join('cache', filepath, custom_dir_name, cache_filename) 



class Photo(ImageModel):
    class IKOptions:
        spec_module = "photos.imagespecs"
        cache_dir = get_cache_dir
        cache_filename_format = "%(specname)s/%(filename)s.%(extension)s"
        storage = DefaultStorage()


Ref:
http://stackoverflow.com/questions/8878119/django-imagekit-and-dynamic-paths
http://groups.google.com/group/django-photologue/browse_thread/thread/dada26db64844398
https://bitbucket.org/jdriscoll/django-imagekit/wiki/Options


2012/02/29

Learn CSS Positioning in Ten Steps

Awesome examples
http://www.barelyfitz.com/screencast/html-training/css/positioning/

CSS Vertical Alignment for Album Images
http://atedev.wordpress.com/2007/10/19/vertical-align-%E7%9A%84-css-%E8%A7%A3%E6%B1%BA%E6%96%B9%E6%B3%95/