Just a quick snippet
if (typeof console == ‘undefined’) { var console = { log : function() {}, debug: function() {} }; }
if (typeof console == ‘undefined’) { var console = { log : function() {}, debug: function() {} }; }
When Des Traynor says “Quality is Fractal he means that by examining one piece of a whole, one can pass a judgement on the whole. In his example of a steak, it doesn’t matter if the steak is terrific, if the gravy is served cold or the waiter is ugly and smells of cigarettes.
I’m not convinced. And this could be because I’m working on my overall consistency. I think this idea requires a consistency that may not be present in the end product. For instance, I might write a glorious function for part of a website but put it together with the rest of the framework and my implementation is less than glorious. You could examine the function and make a judgment that the whole is terrific — but the whole is flawed and weak.
I won’t argue that if one piece is great and another is not so great, that the lower “average” between the two drags the overall quality down. That’s true too; I think that inconsistency is a flaw in a product. ( That’s why I’m working on it myself. ) That’s not what I’m saying; what I’m saying is that it’s hard to judge the whole effectively when there’s different levels of greatness.
With chatter today about website speed, here’s a quick test to see how long a webpage takes to download.
Keep in mind that this should be run at some interval with an average taken. Server load and speed should be taken into effect.
$ time wget –quiet –delete-after –page-requisites http://www.gmail.com
An example output is:
real 0m0.421s
user 0m0.000s
sys 0m0.012s
“time” gives you how much time something took; the command after the time command. You want the “real” number.
“wget” is a great tool for downloading stuff from the web. The –page-requisites flag gets the CSS(link) (Cascading Style Sheets), JS, images and other things necessary for the page to be displayed. The other options (quiet, delete after) are just there to clean up the output.
This also doesn’t take into account how much time a browser might take arranging the pieces into a pie. A bunch of nested tables will cause the client to slow down. Not specifying image height and width will cause browsers to slow down. A slow computer … well, you get the idea. Run this and take an average of the REAL value and you should have a pretty good idea of how slow your site is.
Note
If you’re plugging this into a php script, keep in mind that “time” is outputting that into the STDERR stream.
Just a quickie note:
Had to add a SPF record to a domain where the DNS is at ultradns.com.
Skim down to the “txt” areas, and add a text one like this, with your domain as the first textbox.
This one is because this particular client uses google mail for their domain.
v=spf1 include:aspmx.googlemail.com ~all
This one is a seriously generic and just allows any server that’s listed as an MX for the domain.
v=spf1 mx ~all
The ominously named “git” is a rather dull knife in my toolbox. I’m used to subversion (svn). I use svn routinely for my own work, as a backup. So I modify some files, do a svn commit and then push my files to where ever they need to go.
Git’s another beast. Because it’s an distributed system, doing a “git commit” doesn’t send my files to the backup. I have to do a “git commit;git push” for that. I’m liking the .gitignore file (compared to svn propedit syntaxes). And I’m liking the easiness of branching. I’ve got a couple of projects that are pretty much duplicates of one another with different filling. Like making a pie, but this one is apple, that one is cherry. With subversion, it feels a lot more like those projects are full of stuff. But git feels leaner. Which is good, right?
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?
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.
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.
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!”
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”?
What do you think results in the most clear code?