mini-posts
- Today’s exploration: Beauty
“In its most profound sense, beauty may engender a salient experience of positive reflection about the meaning of one’s own existence.” [article, video]
- Quote: On Teams
“I enjoy a working environment where the word ‘team’ is uttered in derision, and view the process of team or community as a result of mutual respect and enlightened self interest as opposed to a management method where fuzzy feelings are elicited to get the benefits and delegate the blame.” (comment by dkite on LWN article)
- Skype wows
Calling to Greek landline phones (both in-town and country-wide) is cheaper with Skype than Forthnet. Yay for N900 handling all my local calls then.
- Greetings.
“To the past, or to the future. To an age when thought is free. From the Age of Big Brother, from the Age of the Thought Police, from a dead man… greetings.” (1984)
- Rock Paper Scissors Spock Lizard
“Scissors cuts Paper covers Rock crushes Lizard poisons Spock smashes Scissors decapitates Lizard eats Paper disproves Spock vaporizes Rock crushes Scissors.” (via @mperedim)
-
SSD awesomeness
Psyched with the Intel SSD disk's performance: 238 MB/s on reads, 138 MB/s on writes. #wow

-
Test-wrapped development: Develop from within your tests
Here's something neat. Today I decided not to develop using the Django development server, but instead do that from inside my tests. This way I will work directly on my test database which runs with my test fixtures and when I'm ready, I'll just write the necessary assertions.
Previously I talked about rendering the test client's responses in the browser to view the results of your tests live, before choosing the correct assertions. This time I'm wrapping the code in a while loop to iterate over my development workflow.
This is something different than test-driven development. This way you don't run your tests for every development iteration, but rather you just "stuck" your test case until you like what you see in your code. Here's an example from a unit test:
from transifex.txcommon.tests.utils import response_in_browser def test_homepage(self): while True: resp = self.client['anonymous'].get('/') response_in_browser(resp, halt=False) # Loop control: ch = raw_input("Halted. [r]eload, drop to [s]hell or any other key to continue: ") if ch == 'r': continue; elif ch == 's': from IPython.Shell import IPShellEmbed; IPShellEmbed()() else: breakNow when I run the test, my browser opens up showing how my homepage looks like. I start tweaking the template, hit
rand view the page in the browser again. When I'm satisfied with what I see, I copy-paste from the browser some of the test I want to assert against and hit 's' to drop in a shell.I write my assertions there, in-place, with the test data initialized and ready to be asserted against. When I'm happy with those assertions, I just copy-paste them in the test case and remove the while statement and loop control code.
This type of testing & development works well for template testing. I'm not sure how this should be called. It's test-wrapped development or something.
Also note that the following config variables will be needed:
TEMPLATE_DEBUG = True CACHE_BACKEND = 'dummy://'
-
Video
-
An explorer adventures into an unknown world, yet it seems that he has been there before. A short animated film directed by Malcolm Sutherland in 2010.
(Notice the guy tripping at 1:43. Ingenious.)
-
Quote
There is nothing wrong with your television. Do not attempt to adjust the picture.
We are now controlling the transmission. We control the horizontal and the vertical. We can deluge you with a thousand channels or expand one single image to crystal clarity and beyond. We can shape your vision to anything our imagination can conceive. For the next hour we will control all that you see and hear.
You are about to experience the awe and mystery which reaches from the deepest inner mind to the outer limits. Http://www.youtube.com/watch?v=2I7vPbthvWo
-
twitter.com
For passionate and patient people it's never too little, and it's never too late.
— Quim Gil
-
Rendering Django tests in your web browser
There are a number of levels you can test your Django project. You can test any Python method, your models, your views and even your templates. In the latter case, you're actually testing the rendered response of a view with a specific context. Most of the times, this result is HTML.
When I write my assertion, I often need to query for a particular string in the response's content. I end up opening ipython, print the result and try to find something in that mess.
This takes a lot of time, because the command-line window isn't the best HTML renderer in the world. Here's a simple method to take the response content and render it in a browser:
def response_in_browser(resp, halt=True): """Open a browser and render the response's content.""" import tempfile, webbrowser, time with tempfile.NamedTemporaryFile() as f: f.write(resp.content) f.flush() webbrowser.open(f.name) if halt: raw_input("Press a key to continue with your tests...") else: # Give the browser a chance to open the file time.sleep(1)And just call it from inside any test of yours:
response = self.client.get( reverse('myUrlName', args=['foo']) from txcommon.tests.utils import response_in_browser response_in_browser(response)Your browser will open for you:

One of the first issues you might face is seeing a style-less page. This happens becuase the test server isn't really a web server, and you're probably serving static files from something relative such as
'/site_media'. The solution is simple: Run a separate Django server and tweak your development-only static URL to something like:STATIC_URL = 'http://localhost:8000/site_media/This will trick the temporary window to show the test's HTML with the static files served from the server. Voilà:

You can then use your browser's browser's super tools such as 'View Source' and 'Inspect Element'.














