finding.my.name

eternal ramblings of an empty mind

Month: March, 2013

Word Up

Passwords. Use them wisely. For instance, when you change a password, do try to remember it. What I do know about my KeePass password is that it started with “pyrotechnical lagoon”, contained a total of 45 characters (two additional words), and I even know what dictionary file they came from. However, as best I can work out, brute-forcing the password, even with the dictionary, even if I had a library that worked with the version of KeePass I’m using, would take ages. So I “get” to reset all the passwords I forget.

So! A guide for installing and configuring a web server with a Debian-based Linux installation. Note: it’s definitely a work-in-progress, and honestly may not work. Check for updates if you’re truly interested.

Step 1: Installation
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
sudo add-apt-repository ppa:nginx/development
sudo apt-get update
sudo apt-get install python-software-properties add-apt-repository nginx php5-fpm php5-suhosin php5-gd php-apc php5-mcrypt php5-cli php5-curl memcached php5-memcache mariadb-server php5-mysql unzip git imagemagick python-pip
git clone git://github.com/django/django.git django-trunk
sudo pip install -e django-trunk/

Step 2: Test 1
In your browser, check the view at that IP address, and you should see a “Welcome to nginx” page.

Step 3: Configuration for PHP
Edit /etc/php5/fpm/php.ini. Find the lines that deal with session.save_handler and session.save_path and set them to the following:
session.save_handler = memcache
session.save_path = unix:/tmp/memcached.sock

Edit /etc/php5/fpm/pool.d/www.conf and set some more lines:
listen = /var/run/php5-fpm.sock
listen.owner = www-data
listen.group = www-data

(those last two you’ll probably just be able to uncomment)

Edit /etc/memcached.conf and:
comment out -p 11211
comment out -l 127.0.0.1
add the following lines at the end:
# Listen on a Unix socket
-s /tmp/memcached.sock
-a 666

Create /etc/nginx/conf.d/php-sock.conf with the following code:
upstream php5-fpm-sock {
    server unix:/var/run/php5-fpm.sock;
}

Add to your virtual server file in /etc/nginx/sites-available/:
location ~ \.php$ {
    try_files $uri =404;
    allow 192.168.1.0/24;
    allow 127.0.0.1;
    deny all;
    include fastcgi_params;
    fastcgi_pass php5-fpm-sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
}

Step 5: Test 2
Create a file in your web directory called phpinfo.php that contains the following:
<?php phpinfo() ?>

Step 6: More Configuration
Edit /etc/php5/fpm/php.ini and set the appropriate line:
mysql.default_socket = /var/run/mysqld/mysqld.sock

Step 7: Configuration for Django
Create a file /etc/nginx/django_fcgi_params:
fastcgi_param REQUEST_METHOD $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;

Create a file /etc/nginx/conf.d/django-sock.conf:
upstream django-sock {
    server unix:/usr/share/nginx/django/django.sock;
}

Of course, if you can find and set the right permission settings, you can put it in /var/run/.

Add to your virtual server file in /etc/nginx/sites-available/:
include django_fcgi_params;
fastcgi_pass django-sock;

Brain Damage

I have PHP and Django working, finally, with sockets, even. Now, that’s on my other local computer, not on my server in DFW. But it gives me hope that I’ll soon be able to resurrect that beast. I plan to rebuild it from scratch, get rid of all the junk, and start with Quantal Quetzal. The configuration I have started life as Natty Narwhal. I’m not going to worry right now about the fact that Raring Ringtail is coming around at the end of April. If, and I stress that “if”, my server can handle the load of WordPress and a Wiki running on PHP with fastcgi, as well as my quote database on Django (also with fastcgi), then my first real interactive site will appear. Well, again, not mine, but a client. And it means money! Actual dollars in the pocket! Not much, but six times more than I was originally going to charge, every year, plus development! And they’ll be saving $200 by going with me instead of an apparently aptly named company called “Narcissism, Ltd.” Okay, I changed the name to protect the, well, me, from the possibility of legal stupidity. Anyway, I figure a couple of days of serious development, now that I’ve got the hard stuff out of the way, should be enough to have a functioning demo, and a couple more days of work to make it look nice. Also, when I’m done, I should be able to put together an up-to-date tutorial on making everyone play nice together, and how to fix the problems I’ve run across in doing this.

He’s 15 weeks old, give or take a couple of days. My plan was, and currently still is, to keep Corvi around at least until July, if not for the rest of his life, but I’m worried that I might be allergic. There are very few things I’m allergic to: penicillin being the only thing that comes to mind (and probably certain kinds of pollen), but every time I pet him, I get a rash within a few minutes. It goes away with sufficient soap and water, but washing my hands so much dries them out, requiring moisturizer. It’s rather worrying. I also know he’s not getting his fair share of socialization, so I’m going to take him to doggie day care on Tuesday. I hope this wasn’t a very, very expensive mistake, but I’m really in far too deep to back out at a whim. It’s not fair to either of us.

With the weather improving (warming up, anyway), and light at the end of the day, I’ll have more useful time after work to exercise. Walking, and hopefully running, with Corvi, cycling at some point (not with Corvi), and Lindy Bombers (dancing—Lindy Hop/East Coast Swing) on Mondays, hopefully I’ll start shedding weight again. Back in early February when I had the flu, I dropped 4.5kg, and have managed to keep it off since. My goal is to lose another 11.5kg by summer’s end. That’d put me at 113kg, just 6.4kg above what the U.S. military expects soldiers of my height to weigh (well, 14.1lbs), and since I’m not a soldier, I think that’s a more reasonable goal for an engineer who sits at a desk all day.

Now, Kickstarter. I heard about the STRIPPED project from Howard Tayler (of Schlock Mercenary Fame), and I’d encourage others to support it. They’ve met their first goal of “The Final Push”—to get a few licenses for “in perpetuity” use. As it stands, they could still use another $14924, for scenes from the 1965 Jack Lemmon film “How to Murder Your Wife” (which incorporated comic strip art by Mel Keefer). What I’m most excited about, however, is the interview with Bill Watterson—the first ever with the reclusive creator of Calvin & Hobbes.

Another project I’ve backed which is still raising funds is Tayler’s Schlock Mercenary Challenge Coins. He’s also hurting for cash, at “only” 5517% of his goal. No, that’s not a typo. Interest was rather overwhelming. But if you know any military personnel who have stories about challenge coins, they’re looking for submissions for an unofficial storybook/history of challenge coin traditions. That stretch goal is a mere $693 away, but they plan to make the PDF freely available when it’s compiled.

A little bit of work cleaning my office here on Tuesday, and I’m going to make a serious effort to catch up on my comic book reading. After about two weeks more or less stuck inside (I missed dance tonight, but it’s now on my calendar so I should remember next time), British TV is wearing thin (I’ve finally caught up on Sherlock, watched half of Monty Python’s Flying Circus, and more than my share of Top Gear reruns), I am out of Brandon Sanderson books to read (read them all, except Wheel of Time, and there are 11 books of Jordan’s before he picked up the reins on that one), and I can only do actual work on this website for so long at a time. But I always feel a bit better when things get sorted out/organized. And I think I need to make one of these, too.

Jesus Just Left Chicago

I am developing a “Lunar Lander” game for the Lake Afton Public Observatory computers. The one they have is DOS-based, entirely textual, and needs at least a visual upgrade if nothing else. It’s the most popular game they have. So, starting with zero information, I decide to see what it would be like to simulate the actual lunar landing. I’m guessing those 12-15 minutes were harrowing experiences for the LM pilots, though they’d probably done plenty of ground simulations to make it easier.

The problems begin right off the bat: the average altitude at which the 6 LMs began their descent was about 15188 m (8.2 nmi), traveling 1694 m/s over the lunar surface. Ignoring the immense horizontal speed (considering the vertical component only), they had enough fuel on board for just 100 s of full throttle. Obviously, if they just fell, they’d hit the ground at about 222 m/s and leave quite a crater, and it’d take just over 2 minutes to get there. But the records show that it took Apollo 11 a full 12:36.39 to touch down. I’m trying to figure out a) how they managed that and b) how I can keep the game fun and educational. For instance, I haven’t found any data on the throttle position during landing, or how hard each LM hit the ground, or what, given the suspension of the craft, would be survivable (while keeping the ascent stage sufficiently intact for the return trip). Most of this data I would expect NASA to have record of, and perhaps I need to write them and find out if it’s freely available somewhere (or if they’ll just send it to me).

My program does do some nice things that others may not: it adjusts the mass of the craft based on the amount of fuel remaining, gravitational acceleration is adjusted based on the distance the LM is from the ground based on Newton’s law of gravitation (using mean lunar radius and estimated lunar mass), and uses all the (averaged) stats I could gather from the actual Apollo missions (Isp of the main thruster, acceptable thrust values, mass). I suspect I’ll edit starting values for “easy”, “medium”, and “hard” modes, and I’d like to add a “scenario” mode for each mission that actually landed. Keep in mind, Apollos 15, 16, and 17 had the lunar roving vehicles on board. Even though the rovers themselves were each just 210 kg, each of the LM were roughly 1179 kg more massive (probably for mounting equipment and shielding), yet held roughly the same amount of fuel.

One thing I do not have is terrain on which to land. I could (and probably will) make an artificial 2D terrain generator when I start building the GUI, but I’ll have to ensure that it’s realistic (that the parameters for a random midpoint displacement aren’t too extreme for the lunar surface).

Many sample programs I’ve examined use ambiguous altitude and speed measurements, things like “fuel units”, in addition to lives. I’m sorry, but if anyone crashed on the moon, they’d be dead. They wouldn’t get another chance five seconds later to try again. And instead of making decisions about how much throttle to use (or fuel to burn, as in the case of the current LAPO program), the user gets arrow keys to control pitch and the down arrow to control thrust–so it winds up being on or off. One boasts about using “true gravity physics”, but even if you land successfully, your craft explodes. Another talks about using realistic mass, thrust, and fuel consumption, but starts you off 50 m above the surface with a zero-magnitude velocity vector.

I went to Lindy Bombers tonight. Haven’t danced in probably 3 ½ years (since just after I moved to this house, I believe). It turned out that knocking some of the rust off my moves was easier than I expected it would be. I can do the swing out and the 6-count pass. Lots more of the basics to recall, but I’ll get there. Just gotta stick with it. Perhaps I can convince Karyn to join me some evening, at least over at Care to Dance.

So Corvi has grown…a lot in a short while. He’s probably passed 30 lbs already. Certainly not fat, either, just growing like a weed. I have to work on his biting, though, and a lot of it’s my fault for not spending enough time with him. Things will become much easier next week, as we finally get that extra hour of daylight in the evening (even if I do have to sacrifice an hour of sleep for it). So, running, dancing, dog, raise, side-job for more pocket money, things are going much better now than they were a month ago when I had the flu! I just have to find the time to do things like put away the laundry (it’s all clean, most of it’s folded, there’s just no room in the closet right now).