May 30 2009

Django Quick Install With WSGI

Django is a high level python web framework that I’ve been hearing a lot about lately. I decided to try it out this weekend.
It took a little reading to get up and running so I documented the steps I took so others can get up and running a little more quickly.

sudo apt-get install django
django-admin –version

Create the appropriate directories and start the django project.

For no real reason I decided to put my new projects in /var/django.
sudo mkdir /var/django
sudo chmod 755 /var/django
cd /var/django
django-admin startproject mysite
cd mysite
mkdir apache

It seems that mod-wsgi is the best way to serve up python web apps due to mod_python being a little outdated. Note that django does come with a built in webserver that is really easy to get going. So if you’re just planning on evaluating the framework and not actually do any production aplications then that would be the way to go. mod_wsgi is an Apache module which can be used to host Python applications.

Install the module:
sudo apt-get install libapache2-mod-wsgi

Now for the configuration. It took me a few tries to get this right.
For now I just put my django site on port 8080 so I can play around without it being public to anyone else.

In the /var/django/mysite/apache directory I created a file called django.wsgi and put this in it:

import os, sys
apache_configuration= os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
sys.path.append(‘/var/django’)
os.environ[‘DJANGO_SETTINGS_MODULE’] = ‘mysite.settings’
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Make sure that the sys.path.append line contains the directory above the project directory. This one took me awhile to figure out.
I was getting this error until I got it right.

[Sat May 30 15:33:24 2009] [error] [client 127.0.0.1]     raise ImportError, “Could not import settings ‘%s’ (Is it on sys.path? Does it have syntax errors?): %s” % (self.SETTINGS_MODULE, e)
[Sat May 30 15:33:24 2009] [error] [client 127.0.0.1] ImportError: Could not import settings ‘mysite.settings’ (Is it on sys.path? Does it have syntax errors?): No module named mysite.settings

Next I added a new virtual host in my sites-enabled folder like this:

<VirtualHost *:808http://localhost:8080/0>
ServerAdmin root@mysite.com
ServerName mysite.com
ServerAlias mysite.com
<Directory /var/django/mysite/apache>
Allow from all
</Directory>

WSGIDaemonProcess www-data
WSGIProcessGroup www-data
WSGIScriptAlias / /var/django/mysite/apache/django.wsgi
</VirtualHost>

After restarting apache :
sudo /etc/init.d/apache2 restart

I got an “It Worked” page when I point my browser to http://localhost:8080/

Of course this doesn’t allow you to use a database in your applications yet but it’s a start.

Share

May 24 2009

Stream Video To The Iphone Using Tversity

Stream Video to Iphone with Tversity

After using Tversity for quite some time to stream my media to my Xbox 360 over my local network, I decided I wanted the same functionality on my iphone.
This is how I did it:

Logged on to my wifi with my iphone and pointed safari to: 192.168.2.10:41952 which is the ip address of my tversity windows server.
41952 is the port that the tversity mediaserver listens on.

I was then shown a nice and easy to navigate web interface to browse through all my folders.

After locating a basic xvid tv show I selected “Play in Media Player”.

The iphone loaded the media player and seemed like it was going to load the movie but then this error popped up.
“This movie format is not supported”.

I searched and searched for a solution to this but found none so I transcoded a video file using one of the many ipod touch video converter programs and added it to my media in tversity.

When I browsed to this file in Tversity and clicked play it worked.
It’s kinda a pain that Tversity can’t handle converting these files on the fly but it’s still useful to watch videos on my mobile

Share

May 17 2009

SSH Tunneling for Privacy and Trickery.

If you have access to a ssh server you can easily tunnel your web browsing and newsgroup/IRC activity to make sure that your IP is never associated with that ..stuff you do. You can basically tunnel any port through the any ssh server. These methods can be used to build up complex chains that are almost impossible to track.

To tunnel your basic browsing through a ssh “proxy” use this command:

ssh -D 8080 -p 22 codytaylor@someserver.com

I used port 8080 instead of the default 80 becuase I run a webserver on my local machine and I didn’t want to mess that up.

The -D in the command specifies a local dynamic application-level port forwarding which creates a socket to listen to the specified port on the local machine. Ancy connections made to this local port are forwarded over the secure channel.

This makes it easily possible to forward all web traffic on the local system through the secure channel by setting up a simple iptables rule:
–iptables -A PREROUTING -t nat -i eth0 -p tcp –dport 80 -j REDIRECT –to-port 8080

If you want to set up a secure ssh tunnel to connect to a specific newsgroup server you can use this command:

sudo ssh -N -p 22 codytaylo@sshserver.net -f -L 443:111.111.111.111:443

The -L specifies that the given port on the local client is to be forwarded to the given host and port on the remote side. This is basically a very specific instruction that tells all traffic that is directed to localhost at port 443 (119 if you don’t like double encryption) to go to the ip address 111.111.111.111:443. Note: I couldn’t get this to work with domains for some reason.

The -N tells ssh to not execute any remote commands. So you do not get the annoying ssh session stuff that makes you leave the terminal open.

The -f tells ssh to go into the background.

Share

May 14 2009

Make High-Impact Backgrounds for Your Designs with Photoshop

In this Photoshop web design tutorial, you’ll learn about creating dynamic and high-impact backgrounds that you can use on your own web layouts. We’ll go over color/gradient techniques, lighting effects, and using textures and patterns.


Share

May 14 2009

Court Orders Breathalyzer Code Opened, Reveals Mess

Death Metal writes with an excerpt from the website of defense attorney Evan Levow: “After two years of attempting to get the computer based source code for the Alcotest 7110 MKIII-C, defense counsel in State v. Chun were successful in obtaining the code, and had it analyzed by Base One Technologies, Inc. By making itself a party to the litigation after the oral arguments in April, Draeger subjected itself to the Supreme Court’s directive that Draeger ultimately provide the source code to the defendants’ software analysis house, Base One. … Draeger reviewed the code, as well, through its software house, SysTest Labs, which agreed with Base One, that the patchwork code that makes up the 7110 is not written well, nor is it written to any defined coding standard. SysTest said, ‘The Alcotest NJ3.11 source code appears to have evolved over numerous transitions and versioning, which is responsible for cyclomatic complexity.'” Bruce Schneier comments on the same report and neatly summarizes the take-away lesson: “‘You can’t look at our code because we don’t want you to’ simply isn’t good enough.”

Read more of this story at Slashdot.


Share

May 14 2009

The More Popular the Browser, the Slower It Is

demishade writes “Peacekeeper, the browser benchmark from the makers of 3DMark comes out of beta and shows an interesting (though perhaps not surprising) tidbit — the more popular a browser, the worse its performance. While it should not be surprising to anyone that IE slugs at the last place, the gap between Firefox and Chrome, is. Once IE’s market share goes the way of the Dodo will web developers start cursing Firefox? How long until Google comes out with a JavaScript intensive application that will practically require Chrome to function?”

Read more of this story at Slashdot.


Share

May 14 2009

13 Useful And Free Websites To Make Your Lives Easier

a list of cool websites that are free and hopefully will make your lives easier


Share

May 13 2009

Is the Free Web About to Expire?

The good old days of tons of something for pretty much nothing are coming to an end, and there’s little we can do to stop it.


Share

May 13 2009

Styling your Lists: 20 Brilliant How to’s and Best Practices

There are lots of different methods to format nice HTML lists that is used in most web designs not only for navigation menu (vertical or horizontal) but for formatting many design blocks in a stylish and elegant manner.


Share

May 13 2009

Why You Should Be Worried About Your Privacy on the Web

Combing through more than two dozen public and private resources on the Web, this author not only found a vast amount of their private information available (name, address, SS#, identifying photographs, family info) but also a fair amount of inaccuracies and outdated details.


Share