Technology

Broadly defined "technology" e.g. software, water pumps

The Optimist Effect OR Shit Rolls Downhill Sunlight Shines Up

So, I was reading this internal memo from SGI about some problems they had with a new release of software that was slower and had all sorts of problems.

There's some great insight in it, though it is long. Then I got to this part:

Optimists tend to be promoted, so the higher up in the organization you are, the more optimistic you tend to be. If one manager says "I can do that in 4 months", and another only promises it in 6 months, the 4 month guy gets the job. When the software is 4 months late, the overall system complexity makes it easy to assign blame elsewhere, so there's no way to judge mis-management when it's time for promotions.

To look good to their boss, most people tend to put a positive spin on their reports. With many levels of management and increasing optimism all the way up, the information reaching the VPs is very filtered, and always filtered positively.

It reminded me of a project I was working on where I wanted to create a web application to do the work and someone else on the project wanted to create it in Access because "that's the way we've always done it here and because it's faster." I estimated 3 weeks to get the functionality created in a website with some benefit of being able to re-use much of that work on future projects. The people pushing Access promised 1 week to get it done. Decision made, do it in Access, we don't have time to do something that's better but will take 200% more time. Well, it took 4 weeks to get it done the first time. Then, there were bugs in it and the process of touching all the desktops to roll out a new version took almost a week in itself.

Shit may roll downhill in an organization, but sunlight definitely seems to shine directly uphill.

Where are Drupal Users?

Here's a Frappr map showing some Drupal users. A few months ago Colorado had just one lone dot (but many users). As of this post it's got 4 users registered with Frappr.

Groups.Drupal.Org promises to replace this but in the meantime, Frapp away.

Drupal Fun at the Shell

So, if you have Drupal installed and maybe even configured and now you're saying hey, what database do all of my installations use? Are my settings files secure?

Well, you already know that I love DreamHost because of the shell access and why?

Well, fun stuff like this!

Drupal's Scripts

There's a few fun examples in the base directory of your drupal install in the scripts folder. code-clean.sh will get rid of backup files and clean up the code. There are also examples of scripts to use to call the site's cron script (you are doing that, aren't you? here's why you should) Lots of fun examples in that scripts directory.

A little database security

Let's say you have a bucket of domains hosted on the same account so they are all in the same home directory and you just realized that your settings.php files are readable by other people with shell access (permissions of 644) which is necessary on many shared hosting accounts because of the way they run PHP, but not necessary on DreamHost using php running as your user. If someone has the information in your settings.php file, they could get into your mysql database with some decent privileges. Yikes! So, just use this one liner to find those files, and chmod them down to something more reasonable like 600.

Find the files and list the permissions:

find ./ -name 'settings.php' -exec ls -l {} \;

And then to tighten down those permissions:


find ./ -name 'settings.php' -exec chmod 600 {} \;

Great! Security, and only one line of commands.

To break down what's happening in that line, I use the find command to find files. ./ is expanded by the shell to look for anything in the form {stuff}.{stuff} such as "knaddison.com" so that it looks in all the directories that correspond to domains. I have lots of other directories in my home folder, but I know I don't need to search those so I don't want to waste my computer's time. Next, I use the -name flag to only look for the file called "settings.php". Fair enough. Then, I use the "exec" command to call chmod.

My first Drupal Patch

Shortly after reading Steve Dondley's message about giving credit for Drupal commits I actually made a patch for a problem with node preview that got committed. You can see the commit message in cvs log for node.module

There it is:

revision 1.613
date: 2006-03-09 21:59:43 +0000;  author: killes;  state: Exp;  lines: +2 -2;  commitid: 51f74410a5114567;
#52586, node preview broken with php5, patch by greggles

Simple, but yeah, it did make me happy.

Also, note that I didn't actually find the problem or the solution, I just created the actual patch file. While I'm on that subject it's worth mentioning a couple of points:

Lots of people go around demanding changes to open source projects or getting upset that their pet bug hasn't gotten the attention they feel is appropriate. If you have a pet patch and you can't code, you can at least:

  • Make sure that your description of the bug includes concrete steps to repeat the problem.
  • If appropriate, create a simplified test case and/or script to recreate the problem.
  • If you know in the code where the change is, don't just explain what to do or paste code into the bug, but actually create a patch file.
  • Make sure all of the flags in the bug description are approriate such as component, severity, etc.
  • Advertise your bug - put it in your forum signature, in your email signature on the email account that goes to related mailing lists, stick it on your website, but publicize the bug so others can see it and help

If you do those things and the bug is still ignored then either your bug isn't really a problem or the project is dead.

remove "not verified" from comments

Note: this is a really bad way to do this - see the comments for the right way.

I disagree on this point, but a friend asked and other folks have previously been confused so I removed the "not verified" label from a site and I was confused on where to do it. A little bit of grepping and I found it's in common.inc:

@@ -898,7 +899,8 @@
$output = $object->name;
}

- $output .= ' ('. t('not verified') .')';
+ //burrell says "no 'not verified' on the comments"
+ //$output .= ' ('. t('not verified') .')';

Remove Table of Contents from Drupal Book

Continuing on from the project I just mentioned...I wanted to remove the list of pages (which is analogous to a table of contents) from the book pages. On this particular site I'm using the book block on the right hand side, so having this information on the bottom of top level page makes for duplication of links and just seems plain funny. Below is the relevant diff -u on the subject:

Edit: This is actually a really bad idea. See the comments below for the right way to do it for Drupal 6.

@@ -469,9 +469,9 @@
   if ($node->nid) {
     $output .= '
'; - /*if ($tree = book_tree($node->nid)) { + if ($tree = book_tree($node->nid)) { $output .= '
'. $tree .'
'; - }*/ + } if ($prev = book_prev($node)) { $links .= '

Dates in Drupal

So, I'm converting a site from a current static HTML version to a drupalized version and in the process we are taking comments that were created over email from a "contact me mailto:" email on the old site and putting them into forum discussions on the new site. Most of the discussions were "receive email, send response" variety, so it's just a node and a comment.

In order to give a feel of the time of the original email and the response, we used the node administration facility of setting the time when creating the nodes. That works great, but when you enter comments you don't have the same control over the time. So, we calculated the average response time in the emails and decided to set comments to be that far in the future after their node. The first curious thing to me was figuring out what dates in Drupal are based on - turns out it's the Unix Timestamp which is fairly common.

So, armed with the knowledge that the average comment lag was 183807 seconds, I ran the following sets of queries to get the desired offset:

mysql> create table gjk_junk as SELECT n.nid, created +183600 as new_time FROM node n inner join comments c on n.nid = c.nid;
Query OK, 19 rows affected (0.96 sec)
Records: 19 Duplicates: 0 Warnings: 0

mysql> create table comment_bak as select * from comments;
Query OK, 19 rows affected (1.61 sec)
Records: 19 Duplicates: 0 Warnings: 0

mysql> update comments c, gjk_junk g set timestamp = new_time where c.nid = g.nid;
Query OK, 19 rows affected (0.20 sec)
Rows matched: 19 Changed: 19 Warnings: 0

mysql> select c.cid, c.timestamp, b.cid, b.timestamp from comments c inner join comment_bak b on c.cid = b.cid;
+-----+------------+-----+------------+
| cid | timestamp | cid | timestamp |
+-----+------------+-----+------------+
| 2 | 1140696532 | 2 | 1141291314 |
| 3 | 1110370045 | 3 | 1141291509 |

Syndicate content