jump to navigation

Flex memory leaks and watching property chains September 7, 2011

Posted by maxmil in : Uncategorized , add a comment

As a general rule it’s a good idea to always unset any change watchers created via BindingUtils.bindProperty or Changewatcher.watch.

However in display objects this often requires a whole lot of boilerplate code listening for when your component is removed from the stage and even more if you consider that it might be re added at a later date.

Fortunately if you create a change watcher within your display object the scope of that change watcher is limited to the scope of the display object and so it doesn’t prevent the garbage collector from removing the object and watcher when the object is removed from the stage and you can avoid the boilerplate.

However whilst profiling my app today i have discovered that if your change watcher is listening to a property chain rather than a single property then this is not the case.

In this case multiple ChangeWatchers are created that reference each other and this, for some reason unknown to me, prevents the GC from collecting the ChangeWatchers and hence your display object.

Unfortunately in this case the boilerplate seems necessary :(

Love to hear if anyone could explain what is happening here…

/var/lib/dpkg/status and invalid character in revision June 27, 2011

Posted by maxmil in : Debian , add a comment

This error appears often in my system related to the names of virtualbox packages.

The current release of virtualbox packages no longer have this problem however the old packages are not removed from the status file.

The only solution seems to be to modify the status file by hand and remove the packages.

Another solution is to use this script written by Julien Valroff that clears purged packages from your status file.

Thankyou Julien.

Exclude hidden (dot) files from find June 8, 2011

Posted by maxmil in : Uncategorized , add a comment

find . -type f ! -iname ".*"

Using apt with an http proxy June 7, 2011

Posted by maxmil in : Debian , add a comment

First export http_proxy environmental variable.

sudo export http_proxy=http://uname:pass@proxy:port

apt / aptitude will now use that proxy.

Setting up apache forward proxy with basic authentication

Posted by maxmil in : Uncategorized , add a comment

To set up an apache forward proxy with username password authentication you need to add something like this to a catch all virtual host. If apache is only listening on port 80 this would be your default virtual host.


ProxyRequests on
<Proxy *>
Order deny,allow
Allow from all
AuthType Basic
AuthName "Password Required"
AuthUserFile /etc/apache2/proxy.passwd
Require valid-user
</Proxy>

You must obviously have mod_proxy activated in your apache.

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

To create the password file and add a user alice do

htpasswd -c /etc/apache2/proxy.passwd alice

Find out which process is listening on a given port May 9, 2011

Posted by maxmil in : Debian , add a comment

In GNU land, for port 123 this goes like
lsof -i :123

Or on Windows

netstat -aon | findstr 123 (get the process id)
tasklist | findstr processId

Move with wildcards December 30, 2010

Posted by maxmil in : bash , add a comment

Just found problems with a directory of images that had some extensions in uppercase (JPG) and others in lowercase (jpg).

I wanted to move all the uppercase JPG to lowercase.

This is the script that did it:

for f in *.JPG
do
new=${f:0:${#f}-4}
mv $f ${new}.jpg
done

at, Cron for Windows November 24, 2010

Posted by maxmil in : Uncategorized , add a comment

Just had to configure a scheduled task on a Windows server and have discovered a cron equivalent: at

At the command line typing “at” shows the programmed tasks.

To add a task use something like

at 02:00 /every:M,T,W,Th,F,S,Su c:\path\to\script.bat

Setting up SSL certificates for Chrome on Debian November 12, 2010

Posted by maxmil in : Uncategorized , add a comment

Just a reminder of how to set up NSS shared DB that chrome uses on Linux for authenticating certificates.

First make sure that libnss3-tools are installed:
sudo aptitude install libnss3-tools

Then download the certificates for CAcerts

wget -o "cacert-class3.crt" "http://www.cacert.org/certs/class3.crt"
 
wget -o "cacert-class3.crt" "http://www.cacert.org/certs/class3.crt"

Import them into the database

certutil -d sql:$HOME/.pki/nssdb -A -t "TC,," \
-n "CAcert.org" -i cacert-root.crt
 
certutil -d sql:$HOME/.pki/nssdb -A -t "TC,," \
-n "CAcert.org Class 3" -i cacert-class3.crt

What is this?

-d = where the database resides
-A = add action
-t = trust flags. In this case T identifies these certificates as certificate issuers any certificate issued by these authorites will be trusted. The C identifies the certificate as a root CA certificate. There are three different situations in which you can define trust flags: SSL, email and object signing. Here we just define the first one SSL.
-n = nickname
-i = certificate file

Lastly we can delete the downloaded files
$rm cacert-root.crt cacert-class3.crt

Setting up SSL on Apache October 28, 2010

Posted by maxmil in : Apache,Java,Security , add a comment

Just had to set up SSL on Apache which uses mod proxy to forward requests to Tomcat.

So that i don’t forget here are the steps and commands that i had to execute.

Create self signed certificate

1) Create private key

openssl genrsa -des3 -out server.key 1024

2) Create csr

openssl req -new -key server.key -out server.csr

NOTE: CN should correspond to domain (may use *)

3) Remove passphrase from private key

cp server.key server.key.org
openssl rsa -in server.key.org -out server.key

4) Generate self signed certificate

openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

5) Copy key and certificate

cp server.crt /etc/ssl/certs/
cp server.key /etc/ssl/private/

Configure Apache

1) Make sure mod_ssl is loaded

a2enmod ssl

2) Modify path to key in default virtual host /etc/apache2/sites-available/default-ssl

SSLCertificateFile /etc/ssl/certs/server.crt
SSLCertificateKeyFile /etc/ssl/private/server.key

Configure Java

1) Connect to apache en browser via https to get certificate. Confirm security exception.

Note that if you already have an exception confirmed you can delete (in firefox Edit > Preferences > Advanced > View Certificates > Servers)

2) Export certificate (in firefox Edit > Preferences > Advanced > View Certificates > Authorities).

3) Navegate to JVM: /usr/lib/jvm/java-sun-x/jre/lib/security

4) Import:

keytool -import -alias servername -keystore cacerts -file /exported/server.pem

NOTE: The default password for the jdk keystore is “changeit”