Tech Thoughts and Projects http://blog.dedecko.com A space to showcase my projects and thoughts on technology posterous.com Mon, 23 Nov 2009 00:39:00 -0800 Firefox Navigation Bar on a Web Page http://blog.dedecko.com/firefox-navigation-bar-on-a-web-page http://blog.dedecko.com/firefox-navigation-bar-on-a-web-page

Screenshot

Firefox is one of the few applications that is always running on my computer.  It is monumentally important for doing almost anything, yet its user experience is imperfect.  My complaints stem from Firefox's many superfluous tool bars that consume a large amount of screen space. Many of the tool bars are unnecessary and could be eliminated to reduce screen space consumption. Google Chrome has done this effectively. With Firefox, I wanted to enhance the interface by minimizing tool bars using some clever add-ons and lots of hot keys.

What I learned from adjusting my Firefox configuration was that the navigation bar is nearly unnecessary. I use the navigation bar for 3 reasons:

  1. Going to a particular website after opening a new tab.
  2. Adjusting the URL slightly. Ex: from twitter.com to twitter.com/tdedecko
  3. Wanting to know the URL of the web page I am currently browsing.
Reasons 2 and 3 are case situations. Needing to adjusting the URL occurs rarely and I generally know my location on the web (Gmail, Hacker News, Google Reader, etc). These situation arise infrequently and could be accomplished with a navigation bar that can be minimized.

Reason 1 is the important part. I use the navigation bar as if it were a shell for launching applications (which it is). This is a regular occurrence with the way I use Firefox. This implies that I need a navigation bar primarily when I open a new tab. The solution is to put the navigation bar on a web page that loads when I open a new tab.

I decided to accomplish this. First I needed to install a few Firefox add-ons. I installed:

These add-ons made it so opening a new tab launched my homepage and makes my navigation bar toggle-able by hitting F2.

Then, I spent an hour or so creating a navigation bar on a web page using jQuery and Blueprint CSS.

Try out my implementation: http://www.dedecko.com/navbar/

I set this as my homepage in Firefox. Now when I open a new tab a navigation bar on a web page appears. Very useful in my opinion.

This might be particularly useful for netbooks. Let me know if this is helpful.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1474286/me.jpg http://posterous.com/users/36ENpnl3abHb Thom Dedecko Thom Thom Dedecko
Tue, 06 Oct 2009 21:16:00 -0700 Code Coverage for Django 1.1 http://blog.dedecko.com/code-coverage-for-django-11 http://blog.dedecko.com/code-coverage-for-django-11

Last week I wanted to implement code coverage for my Django application. So, I did what I normal do; a Google search. I found an old articles and alternate method. I worked with some old code that seemed to work for Django <1.0. I modified it so it now works with Django 1.1. I hope this will be useful to someone else.

With the current configuration the test runner will output the code coverage percentages and generate HTML reports displaying the code covered and code not covered.

Output to the console will look similar to this:

Ran 95 tests in 113.249s FAILED (errors=19) Name                   Stmts   Exec  Cover ------------------------------------------ myApp.datamethods     479    243    50% myApp.methods         150     97    64% myApp.models          432    335    77% myApp.signals          17     17   100% myApp.urls              4      4   100% myApp.views           938    311    33% ------------------------------------------ TOTAL                   2020   1007    49% Destroying test database...

You will need coverage.py and coverage_color.py for this to work. These should be placed somewhere on your Python path. I included the files below just in case. I also included the test runner code: tests_with_coverage.py, which should be placed in your django project directory.

In order for this test runner to function you will also need to modify your settings.py to include two constants:

  • TEST_RUNNER points to the location of the tests_with_coverage.py test runner.
  • COVERAGE_MODULES is a list of the modules used in the coverage analysis.

settings.py

TEST_RUNNER = 'myApp.tests_with_coverage.run_tests' COVERAGE_MODULES = ['myApp.models', 'myApp.views', 'myApp.datamethods', 'myApp.methods', 'myApp.signals', 'myApp.urls']

Run your tests as normal using:

./manage.py test myApp

The code below was based on the code found here: http://blogs.23.nu/c0re/2007/07/antville-15428/

tests_with_coverage.py

import unittest, os, coverage, coverage_color from django.conf import settings from django.db.models import get_app, get_apps from django.test.testcases import OutputChecker, DocTestRunner, TestCase from django.test.utils import setup_test_environment, teardown_test_environment from django.test.simple import build_test, reorder_suite, build_suite def run_tests(test_labels, verbosity=1, interactive=True, extra_tests=[]):     coveragemodules = []     if hasattr(settings, 'COVERAGE_MODULES'):         coveragemodules = settings.COVERAGE_MODULES     if coveragemodules:         coverage.start()         setup_test_environment()         settings.DEBUG = False     suite = unittest.TestSuite()          if test_labels:         for label in test_labels:             if '.' in label:                 suite.addTest(build_test(label))             else:                 app = get_app(label)                 suite.addTest(build_suite(app))     else:         for app in get_apps():             suite.addTest(build_suite(app))     for test in extra_tests:         suite.addTest(test)     suite = reorder_suite(suite, (TestCase,))         from django.db import connection     old_name = settings.DATABASE_NAME     connection.creation.create_test_db(verbosity)     result = unittest.TextTestRunner(verbosity=verbosity).run(suite)     if coveragemodules:         coverage.stop()         coveragedir = './build/coverage'         if hasattr(settings, 'COVERAGE_DIR'):             coveragedir = settings.COVERAGE_DIR         if not os.path.exists(coveragedir):             os.makedirs(coveragedir)         modules = []         for module_string in coveragemodules:             module = __import__(module_string, globals(), locals(), [""])             modules.append(module)             f,s,m,mf = coverage.analysis(module)             fp = file(os.path.join(coveragedir, module_string + ".html"), "wb")             coverage_color.colorize_file(f, outstream=fp, not_covered=mf)             fp.close()         coverage.report(modules, show_missing=0)         coverage.erase()     connection.creation.destroy_test_db(old_name, verbosity)         teardown_test_environment()         return len(result.failures) + len(result.errors)

coverage.py Download this file

coverage_color.py Download this file

tests_with_coverage.py Download this file

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1474286/me.jpg http://posterous.com/users/36ENpnl3abHb Thom Dedecko Thom Thom Dedecko