# Blog Archive

Viewing page 1 from archive of March 2012

# Pseudo suExec with PHP Behind Nginx

## For those who don't want to run more than one php-cgi... for some reason.

I recently started transitioning all of the websites under my management from Apache to nginx (mainly to ease running my Python webapps via gunicorn, but that is another story).

Since nginx will not directly execute PHP (via either CGI or nginx-managed FastCGI), the first step was to get PHP running at all. I opted to run php-cgi via daemontools; my initial run script was fairly straight forward:

 1 2 #!/usr/bin/env bash exec php-cgi -b 127.0.0.1:9000 

Couple this with a (relatively) straight forward nginx configuration and the sites will already start responding:

server {

listen          80;
server_name     example.com
root            /var/www/example.com/httpdocs;

index           index.php index.html;
fastcgi_index   index.php;

location ~ \.php {
keepalive_timeout 0;
include /etc/nginx/fastcgi_params;
fastcgi_param   SCRIPT_FILENAME  $document_root$uri;
fastcgi_pass    127.0.0.1:9000;
}

}


The tricky part came when I wanted to run PHP under the user who owned the various sites. I could have (and perhaps should have) opted to spin up a copy of php-cgi for each user, but I decided to try something a little sneakier; PHP will set its own UID on each request.

Posted . Categories: .

I'm writing #PHP for the first time in a few years (for some @Wordpress plugins); I feel a little conflicted about this.

@mikeboers on . Visit on Twitter.

Categories: .

# Friendlier (and Safe) Blog Post URLs

Until very recently, the URLs for individual blog posts on this site looked something like:

http://mikeboers.com/blog/601/friendlier-and-safe-blog-post-urls


The 601 is the ID of this post in the site's database. I have always had two issues with this:

1. The ID is meaningless to the user, but it is what drives the site.
2. The title is meaningless to the site (you could change it to whatever you want), but it is what appears important to the user.

What they would ideally look like is:

http://mikeboers.com/blog/friendlier-and-safe-blog-post-urls


But since I tend to quickly get a new post up and then edit it a dozen times before I am satisfied (including the title) the URL would not be stable, and implementations I have seen in other blog platforms would force the URL to retain the original title of the post, not the current title.

So I have come up with something more flexible that gives me URLs very similar to what I want, but allow for (relatively) safe changes in the title of the post (and therefore the URL).

Posted . Categories: .

# Ultimate physical limits to computation

## Lloyd, Seth. 2000. Ultimate physical limits to computation. Nature 406:1047–1054.

I just re-read part of this classic CS paper (PDF), and the figure captions at the back stood out to me as being particularly hilarious:

Figure 1: The Ultimate Laptop

The ‘ultimate laptop’ is a computer with a mass of one kilogram and a volume of one liter, operating at the fundamental limits of speed and memory capacity ﬁxed by physics. [...] Although its computational machinery is in fact in a highly speciﬁed physical state with zero entropy, while it performs a computation that uses all its resources of energy and memory space it appears to an outside observer to be in a thermal state at approx. $$10^9$$ degrees Kelvin. The ultimate laptop looks like a small piece of the Big Bang.

Figure 2: Computing at the Black-Hole Limit

The rate at which the components of a computer can communicate is limited by the speed of light. In the ultimate laptop, each bit can ﬂip approx. $$10^{19}$$ times per second, while the time to communicate from one side of the one liter computer to the other is on the order of 10^9 seconds: the ultimate laptop is highly parallel. The computation can be sped up and made more serial by compressing the computer. But no computer can be compressed to smaller than its Schwarzschild radius without becoming a black hole. A one-kilogram computer that has been compressed to the black hole limit of $$R_S = \frac{2Gm}{c^2} = 1.485 \times 10^{−27}$$ meters can perform $$5.4258 \times 10^{50}$$ operations per second on its $$I = 4\pi\frac{Gm2}{ln(2hc)} = 3.827 \times 10^{16}$$ bits. At the black-hole limit, computation is fully serial: the time it takes to ﬂip a bit and the time it takes a signal to communicate around the horizon of the hole are the same.

Posted . Categories: .

After a year to ask the right person, @w00tDude confirmed my theory about "wobbles" (a technical term) seen while lighting The Borgias. Thx!

@mikeboers on . Visit on Twitter.

Categories: .

I don't like needing to patch live websites from a terminal on my phone, but I really appreciate that I can.

@mikeboers on . Visit on Twitter.

Categories: .

Just stopped myself from over-generalizing a new library before it got out of hand, and feeling pretty good about it.

@mikeboers on . Visit on Twitter.

Categories: .

I'm starting to transition all my sites from Apache/FastCGI to nginx/gunicorn for the asynchronous deliciousness.

@mikeboers on . Visit on Twitter.

Categories: .

# The Gooch Lighting Model

## "A Non-Photorealistic Lighting Model For Automatic Technical Illustration"

I've recently been toying with the Gooch et al. (1998) non-photorealistic lighting model. Unfortunately, the nature of the project does not permit me to post any of the "real" results quite yet, but some of the tests have a nice look to them all on their own.

My implementation takes a normal map and colour map, e.g.:

This is the result from those inputs:

Posted . Categories: .
View posts before December 09, 2011