RSS

Monthly Archives: May 2011

Django send_mail “Connection refused” on MacOS X

Connection refused

If you are getting “Connection refused” error message when trying to send an email from Django with send_mail then one thing to check is whether Postfix is running on your Mac OS X.

For that try the following in the terminal:

sudo postfix status

If Postfix is not running then start it.

postfix/postfix-script: the Postfix mail system is not running

sudo postfix start
postfix/postfix-script: starting the Postfix mail system

This should solve the problem (assuming email settings are correct). For example for localhost:

EMAIL_HOST = 'localhost'
EMAIL_PORT = 1025

For debugging purposes you could use a local smtp server:

python -m smtpd -n -c DebuggingServer localhost:1025

Try to send an email with Django and you should see it in your terminal:

---------- MESSAGE FOLLOWS ----------
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Subject: Subject here
From: info@test.com
To: test@test.com
Date: Sat, 28 May 2011 18:31:04 -0000
Message-ID: <20110528183104.11696.10011@dasha-salos-macbook-pro.local>
X-Peer: 127.0.0.1

Here is the message.
------------ END MESSAGE ------------

You can find more info on testing Django email in the documentation.

Advertisements
 
Leave a comment

Posted by on May 29, 2011 in misc

 

Tags: , ,

Turn jQuery slider into a switch

jQuery slider
jQuery slider

Three simple steps to turn jQuery UI slider into a switch.

1. Create HTML structure of the slider:

<span id="slider">
    <label id="on">GapAd ON<img src="/media/images/vsep.png"></label>
    <label id="off">GapAd OFF<img src="/media/images/vsep.png"></label>
</span>

2. Initialise jQuery slider object with two positions – on (zero) and one (off). And assign a handler for “slide” event that will change slider image depending on switch state.

$( "#slider" ).slider({
    value: 0,
    min: 0,
    max: 1,
    step: 1,
    slide: function( event, ui ) {
        if (ui.value == 0) {
            $('.ui-slider-handle').css('backgroundImage','url(/media/images/on.png)');
        } else {
            $('.ui-slider-handle').css('backgroundImage','url(/media/images/off.png)');
        }
    }
});

3. Now make a slider look a bit more like a switch with use of some CSS:

#slider {
    width: 170px; 
    background: #d6d5d5; 
    height: 3px; 
    position: relative; 
    display: block; 
}
	   
#slider .ui-slider-handle {
    top: -16px; 
    background: url('/media/images/on.png') 0 0 no-repeat; 
    border: 0; 
    width: 35px; 
    height: 35px; 
    left: 20px;
}
	
/* styling for the labels */    
#slider #on { position: absolute; ... }
#slider #off {position: absolute; ... }

In the end you should get something like on the picture in the beginning of the post.

 
2 Comments

Posted by on May 28, 2011 in CSS

 

Tags: , ,

String representation of path in RaphaelJS

raphaeljs paths

Simple thing but took me a few hours to find a solution. If you are using RaphaelJs and have performed some modifications on the path (like translation etc.) and then you would like to get a string representation of that modified path there is a very simple way to do it:

[path object].attr('path');

As always it’s all in the documentation if you know how to read it…

Quick working example:

var paper = Raphael(10, 50, 320, 200);
var p = paper.path("M10 10L90 90").attr({stroke: 'black'});

/* original path string */				
alert(p.attr('path')); //M10,10L90,90
				
p.translate(30,30);

/* modified path string */
alert(p.attr('path')); //M40,40L120,120
 
2 Comments

Posted by on May 26, 2011 in RaphaelJS

 

Tags: ,

EditorGridPanel drag and drop

sm.isSelected is not a function error message

If you are wondering why you are getting “sm.isSelected is not a function” error when trying to drag and drop records from EditorGridPanel then the answer is… CellSelectionModel.

Drag and drop in ExtJs works with RowSelectionModel but EditorGridPanel – with CellSelectionModel by default (which doesn’t implement isSelected method).

The quick and easy solution is to use RowSelectionModel instead (if it’s acceptable for you of course).

sm: new Ext.grid.RowSelectionModel()

Otherwise you most probably will have to override ExtJs implementation of drag and drop for EditorGridPanel.

 
1 Comment

Posted by on May 4, 2011 in Sencha

 

Tags: , ,

 
%d bloggers like this: