Django / mod_python — IOError: Client read error (Timeout?)

I’ve been getting these emails from my  django setup with this exception: IOError: Client read error (Timeout?)

I just found out I can consistently trigger it if I cancel an upload before it’s finished.

 

I used to think it was a server setting cutting off connections early or something, not to worry now!

 

TextMate / Sublime Text 2 Sudden Light Font Fix

Suddenly, my fonts got REALLY thin and I couldn’t figure out why. I started to wonder if it was ever any different or if I was imagining things.

That said, the fonts looked really thin and so did all others.

I’m glad I found this post: http://hints.macworld.com/article.php?story=20090828224632809

that details how OSX can sometimes detect your external display as a CRT and disables font smoothing.

Type this in the terminal to force the mac to always use 2: LCD font smoothing.

defaults -currentHost write -globalDomain AppleFontSmoothing -int 2

The number 2 here corresponds to Medium - Best for Flat Panel. You may also use 1 for light smoothing, and 3 for strong smoothing, as per the original OS X font smoothing options.

WordPress.com Code Syntax Highlighting

I’ve had a lot of trouble finding syntax highlihgting for WordPress.com, as in hosted at wordpress.com.

There are plenty of nice plugins for wordpress.org, but not com.

I needed to write a post with a decent amount of code in it, so I looked harder this time and found Posting Source Code.

def myfunction(foo):
    print "this is Python!" 

#oh my god this is useful.

Git — Remove all .pyc

To remove all your .pyc files from your git repo…

First, git rm them
find . -name "*.pyc" -exec git rm -f {} \;

Then, add a .gitignore file in the root of your repo and enter a line:
*.pyc

to prevent them from being added automagically in the future without an -f

Mac — Practical Mac Shortcuts for Web Design

I’m newly converted to Mac mainly for the possibility of iPhone app development and a native unix-like system for hooking into my servers.

For web design, it turns out there are some cool productivity improvements, despite some productivity flaws (window management is a pain but you learn other ways to cope).

Quick Mockups

When you need to make a quick mockup of a website, or if you’re building drafts of a site, there are some serious Mac advantages.

My previous workflow was to take a screenshot, open a new file in photoshop (which recognizes the size of your current clipboard image on both OS), paste the whole thing, crop what I need and get working.

Theres’a a better way, and the first is the screenshot capability built into the OS.

Capture Region or Window (screenshot)

All the capture region commands have the option to use Spacebar to select a window, with fancy BG dropshadow effects.

Cmd Cntrl Shift + 4 will select a region and save it to the clipboard, which means you can paste a random snippet off anything into photoshop.

Cmd Shift + 4 will select a region and save it to the desktop, useful for sending to somebody or uploading to wordpress.

Remember, pressing space while in selection mode will allow you to select a full window to copy to pasteboard or desktop.

As a bonus, it will display the pixel dimensions of the selection meaning you can use it to quickly measure the size of anything in pixels.

 

Drag and Drop Functionality

The drag and drop functionality from browser to Photoshop is pretty great.

Drag and drop any Image from the web to photoshop and it works as if you’ve saved it and dragged it into your photoshop, except it involves zero hassle.

I can search for an image of a wine bottle, drag it into photoshop, do a color overlay and I have a mockup of an icon in 10-15 seconds.

Will update as I find more …

Django — Aggregate Sum of All Fields

Well, the docs as of today on aggregation don’t mention anything about the specific types of Aggregation possible. It mentions Avg, Min, Count, etc.

Update from Derek below: actually, it’s in the docs in the Queryset API docs under “Aggregation Functions”
http://docs.djangoproject.com/en/dev/ref/models/querysets/#sum
Missed that… but there should be a link back there from the main aggregation docs.

Anyhoo, I found another type Sum in django.db.models.

Just apply
MyQueryset.aggregate(Sum('my_field')) to get the sum of all my_fields in your queryset.

Photoshop — Disable Auto Transform Handles

I have been living with auto transform handles on my objects for the past week and wondering how to turn it off.

I searched, found nothing.

Then, I found a freaking button I’ve never seen before (clearly):

Show Transform Controls.

Turn it off. Fixed.

Git — Force Git to Pull a Branch in it’s entirety. Ignore Merging.

Read below to make sure you’re in the same boat.

I had a branch set up on Server A that I committed to the remote repository.

I had a branch set up on Server B that I committed to the remote repository.

Now, Remote Repository has branch from A and B.

Pulling branch B or branch A from either server would result in merge conflicts.

If you are…

How to do I get git to pull overwriting /everything/ ? I just need exactly what is on the remote server.

Now I’m starting to sound very stupid: I just needed to do

git fetch origin branch

Apparently, git pull always merges with the current branch. Not proud to admit I’m just starting to get Git.

http://stackoverflow.com/questions/292357/whats-the-difference-between-git-pull-and-git-fetch