Apache ModRewrite Problem

Posted on November 13th, 2009 in PHP by Russ

Ok, here’s a perplexing one.

If (cookie does not exist) AND (cache file exists) THEN redirect user.
[code]
RewriteCond %{HTTP_COOKIE} !^.*cookiename.*$ [NC]
RewriteCond %{REQUEST_URI} ^/?original/page/
RewriteCond -s other/page/index.html
RewriteRule .* other/page/index.html [L]
[/code]

Result: 404, file (/original/page/) does not exist (note that /original/page is itself a redir).

So … what am I doing wrong?

Automatic Updated Services

Posted on November 3rd, 2009 in PHP by Russ

After finding out how easy it was to update my twitter status from a script, or to send direct messages, I’ve got several processes that will send me a twitter DM when they’re done. Real Estate updating script finished? It “pings” me. Server offline? Nagios “pings” me. Or it’ll just update its status and I’ll follow it in my RSS reader.

And now I’ve discovered “posterous.” and Posterous will feed an RSS feed.. so I could email Posterous (post at posterous dot com), and follow that on an RSS reader and whammo, it’s all done too. More content allowed … maybe a full php error handler? Who knows. Yeah I know I’m cheap for not shelling out for HopToad, but that’s what we get with bills like mine.

capistrano for php site rollouts

Posted on September 23rd, 2009 in PHP by Russ

I’ve stumbled across the idea of using capistrano for rollouts. I like the idea. It’s not so good for development, though. Here’s what I mean.

On the one hand, my current setup — I make some changes to some code and test it. My testing is on another server. I update the remote server with rsync. It’s quick and painless. I probably do this about once every five to ten minutes while I’m building something. Do it, look. Do it, look. Do it, look. Then when I’m happy and it’s reached a milestone, I commit it to subversion. This is the point where the capistrano would fit in- because it checks it out from the subversion repository.

Now, after doing “cap deploy” every five minutes, I have 12 slightly different copies of the site in the releases directory. What I should have done is use rsync to push my changes to the dev server and use “deploy” only for rolling the code out to the production server– two different tasks that are only superficially the same.

Amazon Didn’t Lie

Posted on September 14th, 2009 in PHP,Uncategorized by Russ

I’ve been wondering why the feed-getting scripts on http://www.newconsolegames.com/ kept hanging and causing server problems. Seven or so of those scripts all running at once can cause that!

So I spent an hour fixing some error reporting to them. And then tested it– and what did I learn? First, I coded it using “fopen(url,r) which didn’t get me anywhere when fopen died. I didn’t do any error checking on that– so what was hanging the system was an infinite “fopen did not return a resource” in a while loop.

Second, fopen was dying because I ignored Amazon’s requirement that we start signing our AWS requests effective 8/15. … Now I have to figure out how to do that and implement it on about five sites that get amazon info and update databases! Stupid me. I could have done this better. But I was “busy!”

Code Design Question

Posted on May 6th, 2009 in PHP by Russ

Let’s suppose I’m using a third party API class, oh, I don’t know, let’s say “Facebook.” I’ve got a $facebook=new Facebook; and $facebook->api_client->bar(), et cetera. And suppose, I want to do something with it, but I’m using a class too. Let’s say, I want a class “Pets.” I’ll need to use the facebook class for communicating with the facebook servers and configuring stuff.

Which is the “Best Practice”?

  • extend the facebook class like “class Pets extends Facebook” …
  • use a facebook variable in the Pets class – $pets=new Pets; $pets->fbook =& $facebook;
  • Don’t tie the two objects together

What do you think results in the most clear code?

Specialization is for Insects

Posted on April 30th, 2009 in PHP by Russ

I know, it’s a Heinlein quote.

A few years ago, I was in the same sort of position I’m in now. That is, looking for a full time gig to support the family. Need a PHP Programmer / System Administrator? :)

Then, I split my resume into two parts- a “programmer” resume where I tried to speak more to people who wanted programmers, and an “administrator” resume where I did the same with more of an admin slant. This time around, I didn’t bother with that. I figured I’d put my cards on the table and play my strongest suits together- I’m good at both.

I’ve started asking “Why Me? Why did you pull my resume out of that stack of six thousand resumes to ask me to come in?” Because, let’s face it; the openings have a lot of applicants, and the hiring people have to choose on something.

The two people of whom I’ve asked this question have said the same thing; “your combination of PHP skills and your System Admin chops.” Well, not in those exact words, but pretty close.

So if you’re following the instructions of some resume writers, and focusing on one skill set for your job search, don’t be afraid to change it up a bit and lay your cards out too.

Fouled up, foul mood

Posted on November 8th, 2008 in PHP,Webmastering by Russ

Seth Godin could not have posted this at a more appropriate time for me.

Not that I was doing 4% less, but it did totally suck. Here’s the situation. I have a site I’ve built for a client. I do regular maintenance on the site and I keep it in a subversion repository. I also do development for this site. I have a development site set up for it where only I can see the results.

Early last month, I was asked to develop a feature for it. It was actually similar to many other parts of the site but to implement it right, I needed to rewrite a fairly major portion of the navigation pages. Then I had to duplicate it for a different category of navigation, and since it’s either working one way through a standard link (product.php?id=4) and through a javascript update of elements, I had to do a lot of testing.

I did a lot, a lot of testing of it and was really proud of how it worked. I developed it in Linux / Firefox and tested it with Windows Firefox 3 and IE 7. I don’t really have to support IE6 at the moment. I tested all of the static link possibilities and then I tested all of the javascript possibilities. It was set, and I committed it to the repository. The client wasn’t ready for it yet, and since we’ve had problems where I’ve made something live where either he or I weren’t around to make sure it was right (thus the emphasis on testing ), I was waiting for him to say to make it live.

Before he did, however, he had some smaller things to change. So I changed them and made those changes live. I had typos, however, on the copies I committed to the repository. I changed his code live for these smaller things, so these weren’t tested. This was a problem- I wasn’t ready to roll out the bigger changes to “live” but I did need to roll out some later newer changes.

So when he was ready for these bigger changes, I rolled them out. And then this happened over IM:

client: dont you test this shit before you go live
client: just forget it
client: i'll do it differently
client: less chance of you destroying my site that way
client: revert back to before you broke it
me: i'll brb. off to shoot myself.
client: how about before you do that you get my frikking page to load in IE?
client: you're making us look bad
... ( client asks if I can handle the other way without taking down his site) ...
me: If I can't handle it, I'll subcontract some eight year old in india to do it for me.
client: or a 3 year old in china
client: do you practice being inept in front of a mirror or is it just a natural state
client: does it just come naturally?
client: a gift?

I had to take over 200 dollars off the invoice from last month ( for the changes that didn’t work ) and my entire day was put into a blender and frappiccinnoed. Nice, huh? And all because I made his smaller, newer changes live and didn’t properly test them with the revisions that I had tested

Here’s a couple of things I should have done. First, made the changes to my development area and tested them before I did them to the live site. Second, made use of the “branch” and “tagging” features and branched the code when he needed the smaller changes made, then merged it afterwards (and tested). Really, it’s the testing that’s the problem. Even in my “full time gig,” my testing could use some work.

How Subversion Externals can help you

Posted on October 25th, 2008 in PHP by Russ

Most of us have, when we go to design a new website, a way we configure the working environment. For example, I like to have a “setenv.inc” file to set up a database connection and create a smarty object, I like to have Smarty templating and the Pear/DB class in my /libs directory.

It’s kind of a pain to copy over the last website’s configuration, clean out the cruft I don’t need for the new one, and restructure it for a new website. So here’s what I did.

First, I copied over the last website’s configuration and cleaned out the cruft, at first without any other tools; just my stuff ( no database, no smarty, et cetera ). I created a subversion repository and imported this, then checked it out, giving myself a working directory.


svnadmin create /home/svn/repos/rgh_libs/
svn import . /home/svn/repos/rgh_libs/
cd ..
rm -rf blankdir
svn co /home/svn/repos/rgh_libs blankdir/

Then, because Smarty makes available a subversion repository (and look, it’s unstable for the trunk branch. Don’t panic if it breaks :) ), I went into the blank directory and set up an externals definition:


cd blankdir
svn propedit svn:externals . (note that it's applying to the blank dir, which I'm in; there's a period on the end of the line. )
(edit file to look like:)
libs/smarty http://smarty-php.googlecode.com/svn/trunk/
(save and exit )
svn up

That last svn up will bring in the smarty libraries to your libs/smarty directory. And look, it’s the entire package. We don’t need the entire branch, we just need the libs. Remove the libs/smarty dir, edit the svn properties, and reupdate

rm -rf libs/smarty

(edit file to look like)
libs/smarty http://smarty-php.googlecode.com/svn/trunk/libs/
svn propedit svn:externals .
(save an exit )
svn up

I also like using the blueprint css, the pear DB package, magpierss and simplepie. Unfortunately, those packages don’t currently have a subversion repo, so I have to download them and add them to the repository. On the plus side, they’re smaller than the smarty package.
I add them, and then commit my changes with a tag.

When I start a new website, I can do a “svn export /home/svn/repos/rgh_libs newsite/” and I’ll get the current version of smarty (and whatever other packages I saved ). But I didn’t have to update the smarty version and I didn’t have to store multiple copies of smarty in my repository.

Hyperdesk

Posted on July 31st, 2008 in PHP by Russ

The hyperdesk site is finally live. It’s been a long road of about eight months of nightly work. Once the client was satisfied that the html/css he wanted was out of my league ( way out of my league ) he had another company set up the html and css and start up the javascript.

Their work with mootools was a lot smoother than my work with prototype. :)

The site owes a lot to mootools.net, PEAR and smarty. I went with using the Pear libraries for database access, the Smarty tools for templating and the mootools for javascript. I’ve built a secondary site at hyperdesk themes that’s using the same stuff and also the blueprint css libraries. Once nice thing about building a site for myself ( or to my own standards ) is that while I can say “this is ugly” ( the animation is currently ugly ), I can also say “make this better via the blueprint grid.” and not “move this over 2 pixels, no too far!”

Competitive?

Posted on July 22nd, 2008 in PHP by Russ

How does one “become more competitive?”

Competetiveness is a virtue of companies. Basically, people who believe in it consider that there’s a limited amount of income available ( or public attention or whatever ) and they’re driven to get “their fair share” or “most of what’s out there.”

Here’s a list of values a client poses for his company. It’s not my list, but I think it’s an interesting one to look through:

  • Creative in approach to solving problems
  • dedicated to his own ideas
  • high value on time
  • competitive
  • thinks big
  • forward thinking/future oriented
  • innovative

I like to think t hat I’m dedicated to my own ideas, innovative and creative with regards to problem-solving. However, I’m not sure I place a high enough value on time, or that I think big enough. As far as “competitive,” don’t make me laugh. :)

How does one groom oneself to become more competitive?

« Previous PageNext Page »