Posts in 'tech' – Page 2

From Django to GitHub Pages

I finally joined the cool club of hackers who host their blogs on GitHub Pages. I won't rave about the sheer awesomeness of using GitHub, Jekyll, and Markdown to write blogs because there are already about a hundred million other blogs out there doing just that. I will, though ...

"Testing in Django"

Writing tests and test-driven development has become all the rage lately; but before declaring assertions left and right, it's important to consider where, why, and how you will write your tests.

Different frameworks have different philosophies about how to go about this but, more often than not, developers tend ...

"2012 27\" iMac with 32GB Kingston HyperX"

After nearly 4 years of using a MacbookPro for all things internet, I've finally upgraded my home with a shiny new 27" iMac.

The new design is amazing, and yes, it's very, very fast. The point of this article, though, is to inform anyone curious that Kingston HyperX ...

".rvmrc and binstubs"

A while ago I wrote a script to help manage gemsets and PATH settings when switching between Ruby projects. It has worked very well, but I've recently learned about .rvmrc — yes, I'm still new at this.

Most RoR programmers probably know that one must prefix console commands with ...

"SEO Is Overrated"

Smashing Magazine has a good article today on the truth behind Search Engine Optimization "black magic." It's something I've been saying for years — SEO isn't rocket science, and "companies" who claim to provide (expensive) SEO expertise are merely taking advantage of the general public ignorance on the ...

"HTML5 Navigation in Django"

Creating a snappy user experience can be easily obtained by implementing HTML5 navigation. Not only does it take less time to render only the needed Django templates, the browser has less information to digest on the response.

Note that I do not use the popular method of using jQuery to ...

"Using Google to Send Mail in Django"

If you have a Gmail account (or a Google Apps account), you can use it to send mail on your behalf just like any other email client. Remember to use port 587 (not 465), and an "application-specific" password if you use 2-step verification.

EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'you@gmail ...

"Decorating Django Tests"

Just a quick note: when decorating Django tests you have to take care to name your return function using the same "test_" format otherwise an unmodified TestRunner will not discover it.

This will work:

def mydecorator():
  def wrapper(f):
    def test_func(*args, **kwargs):
      # Do some stuff
      result = f(*args, **kwargs ...

"Django: A New Way to Write Tests"

Taking a lot of inspiration from Ruby's RSpec, I've established a new way to write my tests when doing TDD in Django. Using django-nose, factoryboy, and a few of my own helpers I have greatly simplified and consolidated test writing.

My file structure:

project
  |
  +-- app1
  |
  +-- app2
  |
  +-- project
  |
  +-- tests ...

""subject" Decorator for Django Tests"

The Python elite will probably turn their noses up at me, but I just conjured an even better looking way to write my tests.

Using my utilities.py file I can write the following decorator:

def subject(item):
  def wrapper(f, _item=item):
    def test_func(*args, **kwargs):
      item = _item
      if ...