February 5th, 2010

Running Django with MySQL on Snow Leopard by Selwin Ong

Getting Django (or Python) to play nice with MySQL on Apple’s Mac OS X 10.6 Snow Leopard is really easy:

  1. Install MySQL. You can get the DMG from MySQL’s official download site (make sure you get the 64 bit version because Snow Leopard runs Python in 64bit)
  2. Type the following commands into terminal and you should be all set:
PATH=/usr/local/mysql/bin:$PATH
sudo easy_install mysql-python

Assuming that you already have Django setup properly and configured to run using MySQL, all you need to do is run manage.py runserver

If you run into errors similar to this, you are probably running MySQL in 32 bit, upgrading to 64bit of MySQL should fix this (this happened to me when I upgraded my OS from 10.5 Leopard to 10.6 Snow Leopard):

Unhandled exception in thread started by 
Traceback (most recent call last):
  File "/Library/Python/2.6/site-packages/django/core/management/commands/runserver.py", line 48, in inner_run
    self.validate(display_num_errors=True)
  File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 249, in validate
    num_errors = get_validation_errors(s, app)
  File "/Library/Python/2.6/site-packages/django/core/management/validation.py", line 22, in get_validation_errors
    from django.db import models, connection
  File "/Library/Python/2.6/site-packages/django/db/__init__.py", line 41, in 
    backend = load_backend(settings.DATABASE_ENGINE)
  File "/Library/Python/2.6/site-packages/django/db/__init__.py", line 17, in load_backend
    return import_module('.base', 'django.db.backends.%s' % backend_name)
  File "/Library/Python/2.6/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Library/Python/2.6/site-packages/django/db/backends/mysql/base.py", line 13, in 
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dynamic module does not define init function (init_mysql)

If, for some reason you prefer to stick with 32bit MySQL, you can also tell Python to run in 32bit mode by typing the following command into terminal (source):

defaults write com.apple.versioner.python Prefer-32-Bit -bool yes

To switch back to running Python in 64bit:

defaults write com.apple.versioner.python Prefer-32-Bit -bool no

Hope this bit of info helps some of you Django/MySQL developers out there :) .

December 24th, 2009

Merry Christmas and Happy New Year 2010 by Joe

November 6th, 2009

Simulating Slow Internet Connection for Website Performance Testing by Gilang Chandrasa

I joined this army at November, 2nd 2009, so this is my first week in this basecamp.
My name is Gilang Chandrasa, and I’m one of UI web developer.

What I want to show you right now is how to simulate slow internet connection.
Why?

  • Checking AJAX functions in slow connection
  • Measuring if my website is still acceptable in slow connection

For windows user, you can use Firefox add ons called Firefox Throttle.
Firefox Throttle only available for windows, if not this would be a great plugin to have on OS X and Linux.

For *nix user, you can rely on tool caled iprelay.
Ubuntu user can install this tool with this command :

$sudo apt-get install iprelay

To simulate 56Kbps internet connection, type this in your terminal :

$iprelay -b 56000 8001:localhost:80

When you type this address http://localhost:8001/ in your browser, you’ll have 56Kbps connection to your localhost.

October 30th, 2009

Speeding Up Your Website in 5 Minutes (CSS Sprites) by Selwin Ong

In the first article of our website optimization series we discussed about the importance of reducing page load times by compressing text based files served by our website.

I would like to once again stress the importance of building a highly optimized website, this time by highlighting some facts presented in the Velocity 2009 performance & scalability conference. In this conference Shopzilla, an online price comparison website shared their findings that increasing their page load times from 4-6 seconds to 1.5 seconds increased their conversion rate from 7 to 12%!

Reduced page load time leads to increased revenue and page views

Image courtesy of artzstudio

If in the first article we showed you how to reduce page load time by decreasing the number of bytes needed to be moved across the network, now we will tackle this issue from a different angle – reducing the number of items that need to be loaded. Each element in a web page (image, icons, external JavaScript and CSS files) represents a request that needs to be served by the server. The less items that need to be served, the faster the load time, plain and simple.

A popular technique to minimize the number of server requests is called Pingdom’s website testing tool that shows how quickly a page loads.

The first page (with CSS sprites) is rendered in 0.9 seconds, while the second page (regular icons) is rendered in 2.4 seconds – quite a big difference! Furthermore, if we look closely, the image sprite is only 4.96 KB big, while the total size of 8 different icons is 9.72 KB so not only CSS sprites reduce the number of HTTP requests, but it also reduces the aggregate file size.

Using this technique is really easy:
1. Visit css-sprit.es
2. Upload the images you want to combine
3. After you’re done uploading the images press on the “Create CSS Sprite” button
4. Download the resultant image sprite and CSS codes
5. Paste it into your HTML code

Aside from increasing website performance, you could also use techniques that combine JavaScript animation with CSS sprites to make attractive navigation menus. Smashing Magazine has this excellent write up about CSS sprites that you might want to read.

October 23rd, 2009

Software Piracy in Business Organization by Joe

The following advertisement appears in Kompas on Oct 14th 2009. It offers Rp. 50 millions (roughly US$ 5000 over) for those who report usage of pirated software in a business organization.

Advertisement on Kompas, Oct 14th 2009

Advertisement on Kompas, Oct 14th 2009

It is not a secret that there is correlation between a country’s GDP per capita and its piracy rate. There is higher piracy in developing country than in developed country. Indonesia with 84% piracy rate, is ranked 12th among the countries with highest piracy rate.

While correlation does not imply causation, it is easy to see why using pirated software is alluring. Windows 7 Home Premium OEM cost around US$99 (retail price is about US$199. Both IMF and World Bank estimated Indonesia GDP to be less than US$ 2300. Buying an original copy of Windows 7 cost over 4% of your average annual income. In contrast, it cost only 0.2% of your average annual income if you live in United States.

Knowing and empathizing with the above reason does not help.  Knowing that 84% of your peer is using pirated software does not help. The fact is, using pirated software is illegal by law. If your company systematically uses pirated software, the company is assuming a needless risk. US$ 5,000 is quite a large sum of money for most of your Indonesian employee.

It is a needless risk because you can easily mitigate the risk by using open source programs. Do everyone in your company need the latest MS Office? Perhaps, the alternative OpenOffice is sufficient for non sales staff? Instead of using Outlook to check email, maybe using Thunderbird or web interface is better?

All of our software are web based. This means, if you use our software for your business operation, you can save a lot on licensing cost. You do not need to buy Windows license on every computer you have since we can use Firefox on Linux. You also do not need to pay for pricey database program such as Oracle of MS SQL Server because we build our infrastructure using open source database.


Copyright © 2012 User Inspired Technology Services.