SubClosure

{ Don't Repeat Yourself ! }

Browsing Posts published in November, 2010

I recently had to install a piece of new software on an older debian etch system.
Debian removed the distribution from its main update servers and aptitude or apt-get wouldn’t work anymore.

I could have upgraded the system to the latest debian stable version through an dist-upgrade.
But following the rule to never touch a running system I decided not to. It could have taken quite some time and possibly resulted in a crashed server.

Fortunately it is possible to still access old debian distribution files through the debian archive.

All that is required is to change the apt-sources file and replace lines like this one:

deb http://mirror.cc.columbia.edu/pub/linux/debian/debian/ etch main contrib

with

deb http://archive.debian.org/ etch main contrib

now the package manager will work again and you can safe yourself a dist upgrade for some quieter time.

When using Apache-SSL Certificates you typically have to create a password when initially setting up the certificates on your server.
Unfortunately after configuring apache to use the certificate it will promt you for the password each time it starts.
This means your webserver will not run if the system reboots automatically without you having to log in and start it with the password manually.

Luckily there is an easy way to remove the password from a ssl key.

Just find your key and use this command to create a new key without password:

sudo openssl rsa -in mysslkey.key -out mysslkeynopassword.key

Then change your apache configuration to use mysslkeynopassword.key instead of the one with password and apache will start automatically again.

Obviously there is a security risk involved. So make sure no evil gets access to your new mysslkeynopassword.key file.

Lets say you want to call a remote function with Flex’s RemoteObject and in the Response Handler you wish to access some of the variables you used in your calling function. You could use class variables so that they are available in your Response Handler. But thats not always the preferred way.

Another option that I like to use is to define the response handler in your calling Method as a closure. That way you will have access to all variables that are in the scope of the calling method in your handler function.

Here is an example on how to achieve this:

public function callRemoteMethod( myvar:String ):void {

myRemoteObject.myRemoteFunction( myvar ).addResponder(

new ItemResponder(

function(re:ResultEvent, a:AsyncToken ):void {

//the resonder has access to myar

trace(myvar ) ; trace(re.result) ;

},

function(f:FaultEvent, a:AsyncToken):void {

Alert.show(‘An Error occurred’) ;

}

)

) ;

}

Get Adobe Flash player