Social Networking invites are the new mass emails.

December 19th, 2007

Every time I get one I think, did they send that to me because they wanted me specifically, or did they just spam their whole addressbook with the eager assistance of whatever new site they joined? The thing that’s keeping me from signing up to these sites is that I don’t want people to think that’s an OK place to contact me, and I don’t want to just leave some grumpy message about how I don’t ever check my wall messages. I’ll probably end up joining them, if only to defend my identity from Spock.

Removed tag code from theloop.php and added simple tags plugin.

November 29th, 2007

Added the Simple Tags plug-in, so now I have a tag cloud and a related posts display at the end of each post. I also have a “This post is about:[tags]” display at the end of the posts, and words in my posts that are tags are automatically linked to the appropriate tag page.

Because it’s no longer necessary, I removed the following code from theloop.php (at Synthesis):

The College Opportunity and Affordability (and record industry subsidy) Act of 2007

November 12th, 2007

Someone please explain to me why it is that universities should be forced to spend their students tuition on useless DRM-encumbered music download services no one will ever use?

Nice link roundup at the dotmatrixproject.

Updated to 2.4.bleeding(trunk)

October 27th, 2007

I was going to update to 2.3.1, but I thought I’d see if the trunk was working as expected first, and it is.

It’s actually fairly easy to upgrade using subversion, so here’s what I did.

Read the rest of this entry »

Display an interactive spreadsheet on the web with Exhibit.

October 17th, 2007

Sometimes you just want to throw some data up on the web real quick, and you don’t want to mess around with installing any database or writing any code to display it.

Exhibit is your go-to tool. To use Exhibit, all you need is to have javascript enabled in your browser and someplace to put your data files.

  1. Open your spreadsheet and copy the data to the clipboard.
  2. Make sure you have a header row, no spaces in column headings, and the first column is headed “label” as per the Exhibit instructions.

  3. Paste your data into the Babel converter.
  4. Select Tab-separated values as your “From:” format(not Excel, unless you’re uploading a file to convert), select JSON as your “To:” format, and then the “the data is text I can paste into this web page” radio button under the “data to convert” column, then paste into the text box and hit the “Upload and Preview” button. If your data is in the right format, you should see it converted into JSON in the resulting window. If you get just a download and copy button, but no display of your code, it’s either not in the right format or too big to preview. In that case, select the “text/plain” radio button in the “Result’s mime-type:” section, then hit the “Upload and Convert” button. You should see the converted data in the resulting window.

  5. Paste the converted data into a file with a .js extension
  6. Copy the converted datato the clipboard, then create a new file using a text editor(not MS Word), paste the data into it, and give it whatever name you want, and an extension of .js

  7. Include Exhibit in your webpage.
  8. There’s template HTML on the Exhibit Tutorial page, so you don’t have to write anything. Just take their nobelist.html example and change the “link rel=” in the HEAD section to your .js file name.

  9. Add filtering and sorting
  10. For each column in your data you want to be able to filter by, add the following statement to the file in the table in the body section:
    <div ex:role="facet" ex:expression=".labelofyourcolumnwithnospaces" ex:facetLabel="Label Of Your Column"></div>

  11. Upload your .js file to the same directory as the html file that references it
  12. Load you page in the browser and see how it looks!

Converting data on the fly

You can also convert your data “on the fly” by sending the Excel file through the Babel converter each time the page is loaded. This slows things down significantly, so it’s better to make the .js, but if you want to do that, replace the link statement in the head of the html file with
<link rel="exhibit/data" type="application/msexcel"
href="http://URL.of.your.datafile" />

Dates and Excel

EDIT: This is now fixed

For some reason, Excel always wants a date to be a number, and you have to jump through some hoops to get it to display as a proper date. What you have to do is to convert it into text through the use of a formula, not through the use of the menu command. Go to a column next to your data and type
=If(cellthatcontainsyourdate>0,Text(cellthatcontainsyourdate, "mm/dd/yyyy")," ").
This will output the date as a text value in the cell in which you enter the formula or leave it blank if there’s no date in the referenced cell. Without the If statement, you’ll get 01/01/1900 for any date you left out. Then paste the data into a new spreadsheet, leaving out the original columns containing the dates, and making sure to do a Paste>Special>Values so that the contents of the cells, and not the formulas, get pasted. Now copy the new spreadsheet and paste it into Babel.

Here’s some instructions on how to use a Google Spreadsheet as a data source, which is a nice way to share your Google Docs with someone who doesn’t have a Google account.

How to edit the K2 theme so that your tags replace the categories

October 15th, 2007

Find the span class "entry-category"> in theloop.php.
Change <?php /* Categories */ printf(__('in ','k2_domain'), k2_nice_category(', ', __(' and ','k2_domain')) ); ?> to <?php /* Tags */ the_tags(__('in ','k2_domain')); ?>

I’m sure there’s a fancier way of doing this that doesn’t require the theme core files, but this is a relatively minor change.

Tech Tip: Convert POST forms into GET to link directly to search results.

October 1st, 2007

Say you want to link to all clinical trials on a certain disease or using a certain treatment method. ClinicalTrials.gov has an advanced search, where you can enter your criteria. However, because the form uses the POST method to send the search query, the page URL doesn’t change and you have no way of bookmarking the resulting page. Not all search forms work like this. Google, for example, has the query in the URL, like so: http://www.google.com/search?q=post+get+url+bookmark so you can just copy and paste the URL from whatever page you’re on. It turns out that even if the form uses POST, you can often submit a GET request and get the same results. There’s even a bookmarklet that will convert the POST form to GET for you. Just click the bookmarklet on the search form page, then hit the button as usual. This time the parameters that were sent will be shown in the URL, and you can copy that URL, link to it, and it will fetch the results directly. Here’s a link to all the clinical trials being conducted on Multiple Myeloma

Added tag code to theloop.php

September 27th, 2007

<?php if (function_exists('the_tags')) { ?>

<?php } ?>

goes right after <div class="entry-content"> to display tags for current post. I haven’t implemented it here yet, but it’s working on my test blog. I also edited out the conditional statement to make the tags only showup on single post pages, by deleting the if is_single() and changing the elseif to if. I had to correct the curly brackets, too.

Props to Rich Gilchrest for the inspiration.

Are you worried about a hacker stealing the logon details of people who have registered at your site?

September 27th, 2007

Allow OpenID registration, and get out of the business of storing passwords. It’s more convenient for users, too.

This process isn’t totally ready for prime-time, but I can confirm it works on WordPress 2.3.
All you need to do is download the wpopenid plugin, and install the phpopenid library. I put the Auth folder in wp-content, but you could put it anywhere and include that directory in your php path.

Go activate the plug-in and set the options. You’ll get some complaints about the database, because of the change in 2.3 databases, but it should still work.

You can try it out here.

Do you have too many passwords to remember?

September 27th, 2007

Or worse, do you use the same password for everything? There’s a better way to do it, which relieves every site and blog owner from having to store your password.

The way to do it is to set up an OpenID, that way the only person you have to blame is yourself, and perhaps your hosting provider. Another benefit of doing this touches on a big interest of mine: owning your identity online. You see, in the OpenID scheme, your blog URL is all you provide upon login. The rest of the information is exchanged by encrypted API handshake between the OpenID provider(your site) and the site you’re logging into(the OpenID consumer).

The setup is not for the faint of heart, but it’s not that bad, and I took good notes on how I did it.

To set up your site as an OpenID provider, you need to following things:

  • A hosting account running PHP5 and offering shell access, and a domain name. I always recommend Dreamhost, and you can get hosting for only $5/month using my “Synthesis” promo code.

    Step 1: Download the latest and greatest version of the PHP script. It’s 0.6 currently.
    Log into your account, and open a shell window, and issue the following commands(if you’re not running PHP as CGI, you can skip the .htaccess part and do everything from the root URL if you want – read below to see how to tell):
    mkdir me
    cd me
    svn co https://www.siege.org/svn/oss/phpMyID/trunk/ .

    Step 2: Visit MyID.config.php in your web browser. You should see something like this:

    This is an OpenID server endpoint. For more information, see http://openid.net/
    Server: http://williamgunn.org/me/OpenID.config.php
    Realm: phpMyID
    Login

    Step 3: Edit MyID.config.php to include your info.
    - pick a username
    - generate and include your password hash
    echo -n 'username:realm:password' | openssl md5
    - optionally enter personal information to be supplied to sites.

    Step 4: Go back to your webbrowser and hit the login link on the page you loaded before. Now, you’ll be redirected and a window will popup asking for your username and password. Enter them, and press enter. If you get a message saying you’re logged in, you’re not running php as a cgi, and you can skip the rest of this paragraph. If you are running php as a cgi, you need a .htaccess file to convert the authentication headers into environment variables the script can use. This is because “The HTTP Authentication hooks in PHP are only available when it is running as an Apache module and is hence not available in the CGI version.” The fix is easy: if you didn’t make a subdirectory above, make one, and create a file called .htaccess containing the following code(you may already have an example file in your root directory).
    # Option 1, mod_rewrite (req)
    RewriteEngine on
    RewriteCond %{HTTP:Authorization} !^$
    RewriteCond %{QUERY_STRING} openid.mode=authorize
    RewriteCond %{QUERY_STRING} !auth=
    RewriteCond %{REQUEST_METHOD} =GET
    RewriteRule (.*) %{REQUEST_URI}?%{QUERY_STRING}&amp;auth=%{HTTP:Authorization} [L]

    Now, you should be able to hit the login link and get logged in.

    I get redirected to the following URL: http://williamgunn.org/me/scriptname.config.php?openid.mode=id_res&amp;openid.identity=http%3A%2F%2Fwilliamgunn.org%2Fme%2Fscriptname.config.php&amp;openid.assoc_handle=[redacted]&amp;openid.return_to=http%3A%2F%2Fwilliamgunn.org%2Fme%2Fscriptname.config.php&amp;openid.signed=mode%2Cidentity%2Cassoc_handle%2Creturn_to&amp;openid.sig=[more redacted stuff]

    Now set allow_gmp and allow_test to true in the config file, allowing encryption aka Smart Mode and testing, and load http://yoursite.com/you/MyID.config.php?openid.mode=test

    If you’re on Dreamhost, which doesn’t have support for GMP in the php binaries, you will get a file looking somewhat like this:

    bcmath warn – not loaded
    gmp warn – not loaded
    logfile warn – log is not writable
    session pass
    secret pass
    expire pass
    base64 pass
    hmac pass
    bigmath fail – big math functions are not available.
    sha1_20 pass
    x_or pass

    If you get that, you’re ready to delegate your OpenID identity. Go to the root of your domain(or wherever you wish) and enter the following code in a file named index.html
    <link href="http://williamgunn.org/me/OpenID.config.php" rel="openid.server" />
    <link href="http://williamgunn.org/me/OpenID.config.php" rel="openid.delegate" />

    If you’ve already got an index.html, just put the two lines in the head section.

    Now go login to a site that accepts OpenID, or just leave a comment here. See here for details on how to set up your site to accept OpenID, see here.