Posted 7 months ago

Disabling user-agent Stylesheets

I have been working on te views for a django web application and was having huge CSS issues with the user agent Stylesheet in Chrome, Firefox and Safari. It was applying styles that were breaking my template.

After searching around the web for a while I found a solution that seems to negate the styles that browsers are trying to enforce on sites.

I found it in the User Foruns of Drupal.org a great PHP CMS. 

/* These are here to override "user-agent" stylesheets */
html{
    color:#000;background:#FCF1D1;
}
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{
    margin:0;padding:0;
}
table{
    border-collapse:collapse;border-spacing:0;
}
fieldset,img{
    border:0;
}
address,caption,cite,code,dfn,em,strong,th,var{
    font-style:normal;font-weight:normal;
}
li{
    list-style:none;
}
caption,th{
    text-align:left;
}
h1,h2,h3,h4,h5,h6{
    font-size:100%;font-weight:normal;
}
q:before,q:after{
    content:'';
}
abbr,acronym{
    border:0;font-variant:normal;
}
sup{
    vertical-align:text-top;
}
sub{
    vertical-align:text-bottom;
}
input,textarea,select{
   font-family:inherit;font-size:inherit;font-weight:inherit;
}
input,textarea,select{
*font-size:100%;
}
legend{
color:#000;
}
del,ins{
    text-decoration:none;
}
/* User-aget override end */

A big thanks to the Drupal community for coming up with this great solution. The origional thread can be found here.

Posted 7 months ago

Installing comments on the blog.

Posted 7 months ago

Moved House

You may have noticed that we have moved to a new platform with a new look.

This was a necessity as we had some issues with our hosting provider and thought it was better to move to a new platform and provider. We are now using the Tumblr. platform to deliver content so any feedback would be awesome.

This move has its ups and its downs, we have lost all of our 2011 posts which really sucks, but I will endevour to get what content was there back if I can. Though on the up side have been able to breing in all of our content from blogger in. We will get all of this content tagged ready for your to consume.

As well as some posts missing the date stamps may all be for yesterday.

So enjoy the new look (more changes to come) and more content on Puredistortion. 

Posted 7 months ago

Python Image Library Install OSX

Moving on and starting to develop apps now that I have my Django Dev Environment installed I would get on and do some Django development.

What I did find is that to use the models.ImageFile() field type in an apps models.py you need to have the Python Image library (PIL) in stalled into your python install.

After some Googling round I found a compatible package at effbot.org. This is how to install it.

# wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz
# tar -xzf Imaging-1.1.7.tar.gz
# cd ImagingImaging-1.1.7
# python ./setup.py install

When running setup.py make sure that you call the python install that has Django installed.

Once you have this module installed you will now be able to have see the image fields in your models work properly.

Posted 7 months ago

Setting up a Django Dev environment on OSX

I have been looking over the past month or so at web development frame works in different languages and decided that Django is the one for me. Not only is it quick and scalable, but it is written in Python and it is a language I am familiar with and even better enjoy coding in.

For this environment we are going to install Django and integrate it with Eclipse.

For eclipse got to http://eclipse.org/downloads/ and down load the Eclipse Classic DMG file and install.

Next you are going to want to get the Django tarball from http://www.djangoproject.com/download/1.2.3/tarball/. Once this is down loaded open the Terminal app and do the following:

# cd Downloads
# tar -xzf Django-1.2.3.tar.gz
# cd Django-1.2.3
# sudo python ./setup.py install

In the last command i did not declare the full path to the python interpreter. This is so Django is installed into the python version that is in $PATH or found in $PATH first.

Next we want to move django-admin.py into a directory that is listed in $PATH so it is easily called from the Treminal prompt.

# ln -s /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/django-admin.py /opt/local/bin/django-admin.py

Now we have our software installed it is time to integrate the IDE with the Django framework. To do this we are going to plugins into Eclipse, PyDEV a python development environment and the Django Templates Editor.

To install PyDEV open Eclipse and go to Help > Install New Software. This will open another window. In the ‘Work with’ text area add the URL: http://pydev.org/updates then select the ‘Add’ button. This will open the Add repository window, the URL will be populated in the ‘Location’ field and all you need to add is a ‘Name’ for the repo. Once you have done this click OK and Eclipse will list what can be installed from this repository. Select PyDEV and hit next, accept the licence and let the Package Install. Eclipse will ask to restart, once that is done PyDEV is installed.

Next you need to specify a path to the python interpreter for PyDEV. To do this in Eclipse goto Eclipse > Preferences and select the PyDEV drop down. Select Interpreter – Python and then add a new path by selecting New. This will have a pop up window where you can add a path to your python interpreter that you installed Django in. I used the default python that came with OSX. Bellow are the values that I added.

Name: python
Location: /opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resourses/Contents/MacOS/Python

Next you need to install the Django Template Editor you do this the same way as you installed PyDEV except with this URL: http://eclipse.kacprzak.org/updates. Make sure that you select ‘Django Template Editor’ and not ‘Django Editor’.

Eclipse will ask you for a reboot the same way that it did with PyDEV. Once this is done your Django Dev Environment is done.

Posted 7 months ago

Apache Dummy Connections Crashing Plesk HTTP Server

Been chasing an issue at work the last couple of days where one of the servers has a periods of loading up the server’s CPU with a large percent of processes in a wait state.

Fishing arround I noticed a whole heap of dummy connections from the apache server after the Apache server was trying to scale back down the number of child processes. I was seeing these in the access_log and on the Extended Status page on the server. What was weird they were hanging round and taking up CPU. ::1 - - [09/May/2008:14:53:29 -0400] “GET / HTTP/1.0” 200 5043 “-” “Apache (internal dummy connection)” What I found was that the default HTTP web root page that Plesk configures is a dynamic page and for some reason is taking ages to load. So this causes these dummy processes to get stuck and load up the HTTP server.

To fix this I used a mod_rewrite solution I found on the linuxweblog.com and integrated it with the Plesk server default HTTP webroot.

First you need to go to the Plesk HTTP DocumentRoot (this can be found bu looking in /etc/httpd/conf.d/zz010_psa_httpd.conf).

# cd /var/www/vhosts/default/

Next we need a quick loading page. I created a blank HTML file fo this rather than editing the existing page.

# touch ./blank.html

Next we need to open a .htaccess file in this directory and add the following rewrite rule.

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
RewriteRule ^/$ /blank.html [L]

Once this was done I was able to monitor the amount of connections and make sure it was all scaling ok with this command.

netstat -an | grep '\:\:1' | grep ':80' | wc -l
Posted 7 months ago

We have been having issues with the Access Point for the wireless at home, so I reconfigured a WRT54GS v.4 that I was using for my Melbourne Wireless Node.

While dont this I wanted to make sure I was on a channel that did not overlap with any other AP’s in Range. I did this using KisMAC a WiFi scanner I have on my Macbook and the chat I found bellow showing the channels that may over lap and cause interference.

Posted 7 months ago

Checkout this awesome link to an episode of the Totally RAD Show where they demo the Microsoft Surface.

I was blown away by this and if you weren’t you already have one. Not only was there a multiplayer super sprint clone and Settlers of Catan, but you rolled clear dice on the surface and it tells you the results.

I was inspired to build a multitouch display when I saw the Porta Touch on hackaday.com. I even went as far as scrounging a couple of 15 inch displays for the project. Then like many of my home hacking projects it faded off into the mist of daily life.

Time to find the few other parts I need to get this going.

Keep an eye out here or in the projects for my multitouch adventure coming to the interwebs soon.

Posted 7 months ago

Adding system stats to the desktop

While procrastinating on my home automation code I wanted to get some basic system stats on the desktop to just get an idea of what is going on on my new Macbook.

Now there are a whole bunch of widgets, dashboard and menu apps for OSX but being the way I am these days I wanted to see what I could achieve and this is what I came up with.

The first part of my solution to this is a tool called GeekTool. GeekTool integrates with the System Preferences menu and allows you to create areas of desktop to display content. once configured and running this content essentially becomes a dynamic part of the wallpaper so you do not loose any Desktop Real Estate.

The second part of the solution is a script to get the content. I wanted to display Load, CPU and Memory stats. To do this I called top for one instance and then piped (|) the data through sed and pull the strings that I wanted to display.

top -l1 | sed -n -e '3,4p' -e '7p'

I used top as OSX had no /proc filesystem and I was to lazy to find OSX commands to display this stuff at the command line. I would love to hear better ways, so if you have one leave a comment.

to put it all together is simple go to SystemPreferences > Geek tool. Then drag a Shell object off the window and down onto your desktop. Once this is done in the propertied panel and add the script above to the Command panel. You should get output straight away to verify that the script is working.

Posted 7 months ago

Android Preparing SD Card issue

This morning after plugging my Xperia X10 into my macbook and syncing my daily dose of tech podcasts ready for the commute to work I found that the phone was not mounting the SDCard and the phone kept crashing.

After a reboot there was a notification saying that the system was preparing the SDcard and was checking for errors.

I used ‘Android Terminal Emulator’ by Jack Palevich to connect to the terminal of my phone to find out waht it was doing to the phone to fix these errors. I found that the phone was trying to run an fsck on the SDCard.

My Xperia kept crashing so it would start again, so I removed the card from the phone and mounted it to my Linux PC and used fsck.msdos on my linux machine to fix the disk errors.

I did this by running the command bellow:

fsck.msdos -a

once this was completed I was able to remove it and place it straight back into my phone to have it work perfectly.

This solution allowed me to quickly repair the issue and not loose any data.