Archive for August 2009
You may not know it to look at me, but I’ve wrestled with my health for years. Not because I’ve ever been particularly unhealthy, mind you; I’ve just always known that I’m merely in average shape when I could be in good, or even great, shape if I would just try. My exercise regiment seems to wax and wane like the tides; I’ll become motivated to get in shape, do the research, and intensely devote myself to exercise and eating healthy for a period of months, and get myself (at least partially) back to the shape I feel like I should be in. I look good, feel good, and am convinced I’ve finally broken my lethargy. But then my circumstances change, I move houses or start work or stop school, and as much as I try to stay on top of my exercise, eventually I have to say “I’ll just go to the gym tomorrow instead of today” or ” And once I’ve said that the first time, it just makes it easier to say it a second time, and then a third. And then it all comes crashing down.
When I was working after university, I had nothing to do in evenings other than go to the gym, so that’s what I did. Then I went to Japan, and stopped exercising, and started eating badly and drinking more (not to excess, but it’s such a big part of the social culture that it’s really hard to avoid). As you can expect, by the time I left I was a fat bastard. At a beach party a month beforehand, I got to take part in a capoeira trial lesson, and it was humbling to say the least. Looking at pictures of the lesson taken by some of my friends, it was shocking to look at how big I was compared to when I’d first arrived, and how red-faced and exhausted I’d become after what was, in retrospect, not a particularly intensive class. That was my wake-up call – I resolved to get back into good enough shape that a class like that would never defeat me again.
When I got to England, that’s exactly what I did. I scaled back the drinking, started running and going to the gym, experimented with a few diet strategies, and found a capoeira group that turned out to be just as exhausting as I’d hoped, and more. In a few short months, the change was shocking; I’d lost all the weight I wanted, built muscle everywhere I needed it, and felt better than I had in a long time. And then my gym membership ran out and I couldn’t afford to renew it under the non-student rates, and I started working which meant I couldn’t exercise whenever I had a spare moment anymore, because I had so many less. When my visa ran out and I ended up back in a Canadian winter with no gyms in sight, my slow decline into physical mediocrity became an official slide, which is where I find myself now.
I’ve been trying to get back on the wagon all summer, and I’m finding it a lot harder than usual. I’m playing capoeira a lot less, running a lot less, snacking a lot more, and drinking a lot more. I think the problem is that I haven’t found a good pattern to get into yet; working in a real job cuts so much time out of my day, it’s hard to come home from my desk and be motivated to do much more than cook dinner and watch movies. The few times I do anything physical, though, I have a great time. I think the main difference is that it used to feel like exercise was something I wanted to do; now it feels like something I have to do, or should do, and that makes it so much less appealing.
The one change I have made, on the other hand, is a big one; for the past few months, I’ve been eating vegetarian. I’m by no means a purist yet; I still eat a lot of eggs and cheese, and if I’m in a location where there is literally nothing to eat other than meat, I’d still rather do that than go hungry. But I no longer buy it and I don’t cook it for myself at home, and there are enough veggie options around the city that I’m usually not stuck for nothing else to eat. The last time I tried going vegetarian, I simply ate what I usually did without the meat included. I didn’t consider that this strategy would result in my taking in way fewer calories than I should have, and after a month I went back to meat-eating simply because I was tired of feeling hungry. This time, I was ready with a huge assortment of vegetarian recipes, and knowledge of how to replace all the protein and nutrients that I would be missing.
And you know what? It isn’t hard at all. I’ve spoken to a few other vegetarians who talk about missing meat when they first started, and I don’t know what I’m doing differently because I totally don’t. I think a lot of it has to do with using my vegetarianism as an excuse to properly cook again. When I ate meat I had the luxury of grilling chicken, boiling rice and calling it a meal. But unless you’re the kind of person that can eat a gigantic salad for dinner (and I’m not), being a vegetarian makes cooking mandatory if you want to get any kind of decent meal. Take a look at what I’ve added to my repertoire lately:
- Gratineed Gnocchi with Spinach and Ricotta
- Ratatouille and Penne
- Black Bean and Tomato Quinoa
- Mediterranean Lentil Salad
- Pad Thai
That’s just what I made for dinner last week. In two and a half years overseas I haven’t cooked as many new things as I have in the past two months. Expect to see the best recipes posted here in photo-journal form.
The most common question when my vegetarianism comes up in conversation is “Why?” Not in an accusatory sense, of course. People are simply curious because I suppose I don’t strike them as the type to be passionate about animal rights. And sheepishly (no pun), I’m not; I think animals should be treated well, just like most people, but I think there’s a big difference between ethical treatment and equal treatment, and treating animals well doesn’t require treating them as if they were humans in different bodies. My problem has more to do with the meat industry itself; after doing a lot of research about it, I feel that it is destructive, exploitative, and unsustainable, and by refusing to buy meat I am refusing to support that industry. I know they make billions of dollars a year and my $10 worth of chicken isn’t going to make a dent, but you know what they say about everyone doing their part.
The other reason is that, when you think about it, it really is kind of hypocritical to eat meat… or rather, hypocritical to only eat certain meats. When I was in China, I ate dog, because it was on the menu and I had to at least try it. I tell people this and they are shocked. Shocked! “How could you eat a cute little puppy?” they say. “They’re so friendly and intelligent and cute!” Well, yes they are, but so are pigs according to many people who grew up on farms, and no one seems to have a problem eating them. People in England would talk about their refusal to eat veal (baby cow) over a Sunday roast lamb (baby sheep), or shake their head at the Canadian seal hunt while cutting into fish & chips. Where did this line come from that separates the animals that are considered “food” from the ones that aren’t? It sounds like a tired joke to say that people only care about saving the cute animals, but it really does seem that way, doesn’t it? It’s like there’s some kind of equation where cuteness times intelligence divided by taste equals how bad you should feel about eating it. That would certainly explain why bacon always seems to be the meat that brings vegetarians back to the land of the omnivores. The only factor as to whether an animal becomes food or not is how much food you get out of it compared to how much effort you put in. Cows and pigs (and chickens if you have enough of them) produce a lot of meat, but dogs, cats and horses don’t, so we eat one and keep the other as pets.
If you’re a meat eater, ask yourself if there are certain animals you wouldn’t eat, and if there are, why not? Is there a line beyond which you feel it’s immoral to eat living things, but up until that line you’re OK with it? For me, there isn’t, at least not anymore. A few of you might be tempted to remind me of my pledge to try any food once, but last weekend I turned down the chance to try a kangaroo burger. And I’m fine with that.
I invite you to try a little social experiment; head out onto the Internet, and find a news article or blog post that relates to shady business practices. Anti-competitive behaviour, price fixing, frivolous lawsuits, copyright infringement, it doesn’t really matter. Thanks to the resulting recession and bailout plans being enacted around the world, there are no shortage of people raging about how screwed up businesses can get. But make sure that, whatever article you choose, it allows un-moderated comments.
I know this will be hard, and I’ll hold your hand if you want, but here goes; I want you to read some of those comments. Steel yourself and dive into some of the dumbest, unfounded, fringe-lunatic opinions the world has to offer. What you’ll find is two very common arguments about the solution to these practices:
- Businesses evidently cannot be trusted to run their own market, and it is the government’s responsibility to step in and regulate corporate behaviour.
- The government should stay out of private business, and if it did, the free market would allow the companies with the best products and services to flourish.
To be honest, in the wake of a worldwide recession directly caused by financial institutions trying to make as much money regardless of the sustainability of their plans, that second point isn’t a very popular one. But it still pervades, particularly in the form of Internet comments. The technology news aggregator Slashdot is a perfect example of this.
When Apple removed the Google Voice application from the App Store, the opinion wasn’t that AT&T may have asked them to remove it because it competes with services that AT&T offers (which, as it turns out, was true). Rather, it was a sign that the iPhone can’t be that good of a product, because if it was, they should have welcomed the competition and been confident that the free market would provide. Advertisers do not have the right to display ads in games, or software, or on websites, or basically anywhere they would be seen, because needing advertising is a sign of an inferior product. People who violate copyright law (especially video games) are revolutionaries because the information “wants” to be free, and if the games were really good people would be willing to pay for them.
For now, let’s ignore the flaws in their logic, and the likely hypocrisy surrounding their own piracy, and their already questionable taste in media; finding fault in Slashdot users is like swatting a fly with a brick. Instead, focus on their pervasive, almost naive, view of capitalism in practice being similar to capitalism in theory. In theory, privatizing the means of production in a society will lead to the best products having the best profits, and those profits being re-invested back into new technologies, further increasing the product quality and profits, ad infinitum. But as it turns out, John Maynard Keynes was right, and a lot of people would rather keep their profits and re-invest them, at which point the entire system breaks down. Not only that, but there’s a pretty big loophole in capitalism; namely, it’s a lot more expensive to innovate and promote competition than it is to prevent the innovation and competition of others. If I make a widget that explodes and kills 1% of the people who use it, it could cost me millions of dollars to fix it, but only a fraction of that to pay the families of that 1% not to sue my company. As long as I’m OK with people dying because of my product, that’s an obvious choice, and I’m not the first to argue that CEOs may be a little bit too comfortable with making those decisions.
Anyways, my point was that Slashdot appears to advocate free-market solutions to a lot of problems that they weigh in on… except for net neutrality. For those who haven’t heard of it, here’s the 30-second synopsis. Internet Service Providers (ISPs) want the right to block and/or filter content based on where it comes from, and to establish “tiered service” for content providers. This would give an ISP the ability to charge a company like Google different amounts in exchange for their sites and content being delivered faster (or slower) through the network infrastructure. While governments are usually slow to respond to new technology, someone in the US noticed that a lot areas of the country are only serviced by one ISP. Letting the network maintainers decide what content gets delivered to who at what speeds bottlenecks the entire Internet and creates a game of “whoever pays the most gets their site delivered faster than their competitors” that is almost impossible to break into. Net neutrality bills are hoping to make sure that doesn’t happen, and Ed Markey (D-MA) is submitting his third such bill to Congress, hoping that the new administration will help push it through.
So it looks like the government is trying to legislate the free market; how does Slashdot react? Despite all their anti-government-intervention rhetoric, they seem to be supporting it. There’s a lot more actual discussion going on than I’m used to seeing, and they seem to realize that unless AT&T decides to sell the actual physical infrastructure back to “the people,” this is their best hope of making sure they have access to the data they want. But the whole dilemma brings up an interesting question about so-called free markets; how much are you willing to give up to establish one?
If I don’t like the products or services, I have the freedom to get them from another company, and if I don’t like any of the options, I have the freedom to not get any. But what about Internet access? The denizens of Slashdot talk a lot about how angry they are at the telecom companies, but I can’t help but notice that none of them are angry enough to stop paying for Internet access. Granted, those who were angry enough to do so probably aren’t posting on Slashdot at all, so this is hardly a representative sample. But I’m starting to notice a sense of entitlement in many demographics regarding their pet topic. Everyone wants an idealized version of their service of choice, but no one is willing to give up anything in order to establish it, so nothing changes.
People want ad-free television, but aren’t willing to pay the TV stations to provide it (except for HBO subscribers). People want healthcare, but aren’t willing to pay extra taxes to fund it. People want jobs, but aren’t willing to work to find them, and believe others are responsible for their unemployment (which is sometimes true, but sometimes taken to a laughable extreme). Everyone wants more, but no one wants to give more to get it, even if they would end up getting more than they give. And while most people delight in pointing out the cognitive dissonance required to think this way in others, few people will admit to doing it themselves. I’m sure I do it too once in a while.
It’s an interesting issue, because most of the analogies thrown around regarding net neutrality cast a private entity acting as the gatekeeper of a public resource, like the proverbial troll living under the bridge. But implicit in these analogies is the idea that the actual wires that run the Internet are owned by the public, similar to the roads and pipes and electrical wires and other vital infrastructures, and they aren’t. Roads and sewers are owned by municipalities and funded by taxes, while network cables and fiber optics are still flat-out owned by the ISPs that maintain them. In the free market that Slashdot supports, those ISPs are totally within their right to do whatever they want with those wires, including charging anyone they want any price they want for access. But in the same free market, a new ISP would be able to lay down their own fiber optics and compete, and the infrastructure just isn’t set up to allow that. Remember when Google was buying up all the spare fiber optic network they could get their hands on? That’s the size of company it would take for the free market to correct this problem, and there aren’t too many start-ups willing to compete with the telecom companies and unafraid to be sued into oblivion.
Slashdot did come up with a rather creative solution to the net neutrality problem; don’t solve it. Let the ISPs offer tiered service and selective content providing, and wait for the problem to become so annoying that the government is forced into action by buying back the cables and opening them up for public use. It’s a fun idea to entertain, especially if you like the idea of giving people what they ask for even if you know it’s bad for them. But it could take years and billions of dollars to get to that point, and until then, are you willing to use Yahoo instead of Google because your ISP says so?
Yeah, neither am I.
3
How To: Set Up a Symfony Development Environment in SVN on OSX
0 Comments | Posted by dave in development
I’ve been reading up on PHP development frameworks, and Symfony has been bounced around among my co-workers as a very, very good one. Based on my own research, I’m inclined to agree; it’s scalable, easy to install, highly configurable, and uses all the development best practices that we learn about in school and rarely get a chance to use in real life. Best of all, it comes bundled with an object-relational mapper (ORM) called Doctrine; this lets me define my databases using an object-based approach, and focus on proper object-oriented design while letting the ORM figure out how to store those objects in a relational format.
Because there’s a new version of Symfony scheduled for release in November, and nothing I want to use it for will be ready before then, I decided to set up a development environment on my MacBook that I could play around with. I started looking for guides on good ways to set that up, and discovered something interesting. Most of the guides on the internet for installing Symfony under MAMP followed the same basic steps:
- Install MAMP.
- Install PEAR (a PHP package manager).
- Use PEAR to install Symfony.
But on the official Symfony installation guide, it specifically says not to install it using PEAR. And none of those guides account for getting the still-in-development 1.3 framework. Clearly, there was a failure to communicate somewhere along the line, and I was going to have to figure out my own way to get my dev environment set up just the way I like it. And you all get to benefit from it!
Note: This guide should NOT be used in setting up production environments! MAMP is not meant for proper web hosting, and you should never use a non-stable release of anything in a critical system.
The Boring But Important Part: Installing and Configuring MAMP and PEAR
First, go install MAMP, an all-in-one Apache/MySQL/PHP stack that’s great for development and testing. Just follow their drag-and-drop instructions and you should be good to go.
A few maintenance issues first. Symfony is pretty memory intensive, so we might as well account for that now. Open up /Applications/MAMP/conf/php5/php.ini and edit the line:
memory_limit = 8M
to:
memory_limit = 32M
I also strongly recommend you find and set the following properties to Off, for security/compatibility reasons:
short_open_tag = Off magic_quotes_gpc = Off
As well, open up a Terminal window and run the following two commands:
sudo mv /usr/bin/php /usr/bin/php-old sudo ln -s /Applications/MAMP/bin/php5/bin/php /usr/bin/php
This will ensure that running PHP from the command line will use the PHP installed with MAMP, instead of the system default. If you access phpinfo() through a web browser, and run php -v from a Terminal, both should list the same version number.
Right, that’s MAMP; now we need to configure PEAR, a PHP extension repository. We won’t use it to install Symfony, but we still need it because Symfony uses it to grab a few of its own dependencies. Thankfully, MAMP comes with it, so we just need to enter:
sudo ln -s /Applications/MAMP/bin/php5/bin/pear /usr/bin/pear
to make sure calling it from the command line works. If you want to, you can run:
pear upgrade-all
to bring PEAR up-to-date with the latest version. Stop and re-start your servers in MAMP, and you’re done!
The Fun Part: Installing Symfony
I’m going to be borrowing steps extensively from the Practical Symfony book, and once we get to a certain point you’ll be able to follow their steps to finish off your environment. First we have to decide where we’re going to base our application; I put all of my projects under a Programming sub-folder in my Documents folder.
mkdir -p ~/Documents/Programming/MyProject cd ~/Documents/Programming/MyProject
Note: If you want to use SVN for source control on this project, head to the section after this one right now. If you just want to develop on your own, keep reading.
Now we need to get the latest version of Symfony. But instead of using PEAR or downloading a stable package, we’re going to get the latest code straight from their SVN repository, because that’s how I roll:
mkdir -p lib/vendor cd lib/vendor svn co http://svn.symfony-project.com/branches/1.3 symfony
After a whole lot of loading, you’ll have the latest version of Symfony ready to go. Run the following from the Terminal:
cp lib/vendor/symfony/data/bin/check_configuration.php /Applications/MAMP/htdocs/check_configuration.php
And try visiting http://localhost:8888/check_configuration.php. You’ll get a quick summary of all the requirements that you need to meet to properly run Symfony, and whether you meet them or not. If it says you don’t have a PHP accelerator installed, open up your MAMP preferences and turn on XCache.
If everything’s worked so far, head on over to Practical Symfony Day 1 and start following their instructions from “Project Setup” onwards. That will take you through the rest of the process in creating your first Symfony application. It’s literally nothing than a couple of command-line instructions and a bit of Apache configuration. I bet you’re thinking “Hey, that was pretty easy!”
Well, when have we ever been satisfied with easy?
The Crazy Part: Putting the Whole Thing in SVN
This solution works well enough for people who want to work by themselves on one computer. But what if you develop on multiple machines? Or you need multiple people to work on your application? Or you want to develop along two different paths without either one affecting the other? That’s where source control comes in; I can just use SVN to get the latest version of my project anywhere, just like I used it to get the latest version of Symfony. Hey, since they’re both in SVN, wouldn’t it be nice if I could get the latest version of both my project and Symfony at the same time?
Oh yes.
Let’s assume we have a directory ~/Documents/Programming/MyProject (which we created above) and an SVN project already set up (at http://svn.mywebsite.com/MyProject, for example). We start by creating a few useful directories:
cd ~/Documents/Programming/MyProject mkdir branches mkdir tags mkdir trunk
If you want to know why you’re creating those directories, read the official SVN documentation. Otherwise, we’ll import those into our repository:
svn import . http://svn.mywebsite.com/MyProject -m "Initial import"
then delete our original directory and get an actual working copy:
cd .. rm -rf MyProject/ svn co http://svn.mywebsite.com/MyProject/trunk MyProject cd MyProject
Now that we have an empty project that’s SVN-ready, we can do the same thing we did to get the latest version of Symfony… almost.
mkdir -p lib/vendor svn add lib svn commit -m "Added vendor directory"
Here’s the key; instead of getting Symfony directly, we’re going to tell our SVN repository to link to their SVN repository as an external source:
svn propedit svn:externals lib/vendor
This will bring up your command-line editor of choice (mine is vi). Add the following line:
symfony http://svn.symfony-project.com/branches/1.3
Save and quit the editor, then run:
svn update
to get the latest version of Symfony from SVN, just by updating your own project! Perfect! Follow the rest of the steps outlined in the Practical Symfony documentation to generate the rest of the framework, then just run:
rm -rf cache/* rm -rf log/* svn propedit svn:ignore cache svn propedit svn:ignore log svn add * svn commit
This will add all of the files you’ve generated to SVN, except for the cache and log directories, which you probably don’t need to track. And there you have it! A fully packaged Symfony application that you can access using SVN, and that automatically pulls the necessary files from Symfony’s repository. The best part of this set up is that you can have all of your different environments (development, staging, production) as checkouts of the same repository with the least possible amount of customization. The only thing it doesn’t handle is configuring Apache, but that’s a lot more likely to need configuration on a per-machine basis anyways.




