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

Unix — Setup WordPress on Apache PHP5 through Nginx Reverse Proxy

Set up WordPress running on Apache through an Nginx reverse proxy.

Assuming you have apache2 installed, grab the relevant PHP5 libraries:
apt-get install libapache2-mod-php5, php5

Set up Apache

Set up an apache VirtualHost that listens on some port, say 8080.


Listen 8088

ServerName Blah
DocumentRoot /path/to/wordpress

Options FollowSymLinks
AllowOverride All

Set AllowOverride to allow wordpress to use .htaccess.

mod rewrite

You may need to install the apache rewrite module.
locate mod_rewrite.so revealed I have mod_rewrite in /usr/lib/apache2/mod_rewrite.so, so I added a file in /etc/apache2/mods-enabledthat contained:

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

Set up Nginx

Next up is to proxy some address to the apache server listening on 8080.

Set up a location in your nginx server configuration files to point proxy_pass the traffic to your apache server.
Inside your server directive, you’d have something like:
location /my-blog/ {
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
# more settings...
}

and bam!

visit /my-blog/ and your wordpress should start.

Modify wordpress to use new addresses

WordPress doesn’t know it’s living in a subdirectory because the request is proxied from Nginx.

You can fix the links from pointing at the root domain by modifying the home and home_url settings in the wp_options table to include yourdomain.com/my-blog

(also found in the general settings tab of WP admin)

Finally, one last fix with nginx for wp-admin bugginess

It seems the admin isn’t 100% good at dealing with WP living in a subdirectory. It tends to send me off to the root domain for searches and various other misc links.

I fixed this by making a rewrite rule in nginx that directs all traffic from /wp-admin to /my-blog/wp-admin/.

location /wp-admin/ {
rewrite ^/(.*)$ http://yourdomain.com/my-blog/$1 permanent;
}

Finally, we have our blog..

Internet Explorer — Fancybox Issues (1.3.x)

I was wondering what was causing my Fancybox to display incorrectly in IE, because i kinda assumed a release would be stable across modern browsers.

The problem is just that fancybox 1.3.x has been released w/o working for IE8.

Switch back to 1.2.6 and we’re good to go.