Posts Tagged ‘nerdery’

Better than silent mode on the G1

Tuesday, December 1st, 2009

I killed my two biggest annoyances with my G1 with one stone: I recorded a couple seconds of silence and set that as my default ringtone.

  • Even if the volume control on the side of the phone gets pushed in my pocket, my phone will vibrate silently (but for the noise of the vibrator) when I receive a phone call.
  • The phone cannot by design mix silent and noisy alarms (all can be silent or all can be loud), I can now set the default to noisy, set mid-day alarms to vibrate while using the silent ringtone, and those alarms facing the formidable task of rousing me from a dead slumber can still blast at full volume.

I assume these points are also true for any other Android-based phone on the market.

Detailed instructions

Set silence your default ringtone.

  1. Download snd.ogg. You can also record your own silence if you want to be all proprietary about it, but the result should be about the same.
  2. Transfer the file from your computer the same way you would any other file. If you downloaded from your phone rather than your computer, I believe it will be automatically added to your music library.
  3. Go to the Music application on your phone. In the library, press the “artists” button. There is no artist/album data associated with the file, so Android files it under “Unknown artist” and album “Music”. Scroll down to the song snd. Hold your finger down over it until a context menu pops up. Select “Use as phone ringtone”. Your default ringtone is now silence
  4. If you’ve given people in your address book their own ringtones, those will still be audible. Either adjust those settings individually or learn to live with the shame of Hanna Montana announcing your mother’s every phone call.

Silence some alarms.

  1. Having followed the directions above, go to the Alarm Clock application. Tap the alarm you’d like to silence.
  2. Tap ringtone. In the ensuing menu, select snd. Tap OK.
  3. Make sure vibrate is checked to avoid making the alarm too subtle.

Last night’s research: CiviCRM, Drupal, Joomla and OpenID

Sunday, November 22nd, 2009

Yesterday morning I read an e-mail from the Pirate Party advising everyone that they were about to debut their new site using CiviCRM, and that those who were interested in helping ought to start brushing up.

CiviCRM can be based on Drupal, Joomla or OpenID. Not being sufficiently familiar with any of those, I took the opportunity to brush up on all three. While it should go without saying that after a day I’m far from an expert, I now know just enough to be dangerous. And write blog posts.

In my preliminary reading about Drupal vs Joomla, I heard that Drupal offered superior user controls, but that Joomla was better for people who aren’t especially technical. I fancy myself especially technical, but I also tend to work solo, so I didn’t anticipate benefiting from either software’s strengths.

I had limited Drupal use prior to today, and my initial impression was not favorable for entirely superficial reasons: ugly default theme, aesthetic distaste for their logo, and the feeling that it was bloated by trying to offer too many features. However, the install went smootly and quickly, as all installs should, and I was up and running in no time.

The Joomla download was several times larger than Drupal’s and its install was somewhat more problematic, leading to an overall bad first impression. It’s pretty common to find software with a file named something like config.default.php that you’re expected to rename config.php. Joomla’s default configuration file is called configuration.php-dist. Since I’m way too cool to RTFM, I created a copy named configuration.php and went about installing. I ran into problems on about the forth step, apparently because the install process expects configuration.php to be a blank file. I made the change and the installation proceeded smoothly.

While installing, Joomla offers to install sample data, so that way if you’re a n00b testing the waters, you don’t have to put in a bunch of fake data to get started. I was really pleased with this feature, but once I had complete the install I just found myself annoyed with the fact that all the sample data was advertisements for Joomla and set about removing it. I chalk that up to my own fickleness more than any wrong on Joomla’s part. I was unimpressed with how difficult it was to wade through all the options. I’d pick out a specific target that I wanted to change, and look through all three or four menu options labeled “[thing] manager”, but I wasn’t able to make heads or tails of them at a glance. Perhaps if I’d been more dedicated to reading documentation before I got started, my user experience would have been better.

Switching back to Drupal, I found the administration much simpler. Like Drupal, you can create a box to appear on the main page, and roughly where in the overall layout it ought to appear. From my brief perusal, it looked like all of these boxes were created with the same form, which basically offered you a text box into which you dump your HTML (and PHP?). As a coder I found this much more agreeable than having to traipse all around several different menu options and have to try and divine WTF the labels on the form inputs mean. However, if I were setting up a web site to be maintained by many members of an organization, this would be a liability, not an asset. While I had previously objected on the grounds that it felt heavy, next to Joomla it seemed positively sparse, which is how I like it.

Finally, I came to OpenID. I installed the Wordpress plugin on this blog, but I ran into so many problems that I gave up. What I had envisioned was that I’d be able to comment on other OpenID-accepting forums using my URL here, and that others with OpenID users could comment here without sitting in the moderation queue. It seems that the login page now offers a OpenID option, so if a random surfer wants to comment on a post using their OpenID, they have to find their way to the login page, log in, then presumably navigate back to the post they wanted to comment on.

Even more frustrating, I couldn’t actually get it to work. The details are running together a little, but if memory serves, I tried to log in to this blog with my OpenID at this blog, and to my relief it failed. Unfortunately, it didn’t give me any error messages, so I don’t know if it failed because of user error or because allowing you to log into any site simply by typing the url of that site would be extremely stupid. I’m assuming the former. I sought out the author’s sandbox, and tried logging in there. If I recall, it went through all the usual confirm screens, then just hung on one that seemed like it should be redirecting me back to the sandbox. This may have failed because NoScript wasn’t letting it execute Javascript. I hit the back button a few times and found myself still not logged in. I tried again with my LiveJournal OpenID. It got to about the same page before NoScript stopped it under the concern that it was a Cross Site Scripting attack. While I believe that was probably part of normal operation, I don’t want to cultivate a habit of ignoring NoScript’s warnings, which I would have to if I used OpenID with an regularity. I tried it again with a browser that allows Javascript willy-nilly, but I was still unable to log in to either blog with either OpenID. I’d still like to get OpenID working, I think it’s a great idea whose time is overdue, but for tonight I’m throwing in the towel.

In the end, my decision was sort of a cop out: Because I suspect the Pirate Party will be installing their copy of CiviCRM over an existing Drupal install, I downloaded the Drupal-based version.

On today’s agenda: tinkering with CiviCRM.

VeganWiki

Saturday, November 21st, 2009

I’ve found myself spending increasing amounts of time standing in a supermarket with one can of beans in each hand wondering if I could save 55 cents by purchasing the one that contains sdaeajasdfdea, or if sdaeajasdfdea is an animal product. While being able to search the Internet from my phone is enormously helpful (seriously, how did I ever function without the Internet in my pocket?), some of these queries aren’t answered on the first page of results. In an effort to not continually be tracking down the same n ingredients every time I go shopping, I decided to start a wiki to record my findings named, for lack of a more clever moniker, VeganWiki.

I spent some time deliberating about this, because there’s already so much reference material on the Internet, I seriously questioned the need for adding more. But I didn’t find any one good resource on the matter, and some sites that seemed promising at a glance often contained errors or had a different ideas about what foods they consider vegan, making it worse than useless to me. While I hope others can benefit from this resource, the problem I was trying to solve was uniquely mine: I didn’t trust the other resources, and I don’t expect random strangers who come across this one will trust it much more.

I hope that, in spite of that, the collaborative nature of a wiki, in conjunction with judicious citations, will make it a resource useful to someone other than just me. It’s kind of a ghost town right now, but I hope you will consider adding your distinctiveness knowledge to its own.

Random Blogroll Category added to the Wordpress plugin directory

Friday, November 20th, 2009

My plugin was accepted in the Wordpress plugin directory. You can see its page here. I just rated it five stars because I’ve got a huge ego.

I also updated it to make it possible to show the entire blogroll, or to show multiple random categories in a single call to this plugin. I didn’t upload the first version to the directory because its usage was very different, and I didn’t want to cause confusion.

Changing the title on MediaWiki’s main page

Thursday, November 19th, 2009

MediaWiki is the free software that powers Wikipedia, as well as several lesser-known wikis. I downloaded it yesterday, and I found changing its appearance more challenging than I had anticipated.

By default, a page is titled with a big headline stating the name of the entry, such as propylene glycol alginate on this page. Accordingly, the main page has a big “Main Page” headline. There doesn’t seem to be an easy way to change that to a more relevant string, but I was able to do so using the following steps: Assuming you’re using the default theme Monobook, open the file skins/MonoBook.php. In version 1.15.1 (and probably other recent versions) the relevant line is on 118:
<h1 id="firstHeading" class="firstHeading"><?php $this->data['displaytitle']!=''?$this->html('title'):$this->text('title') ?></h1>

data['displaytitle'] will be blank on the main page, but I don’t know if it’s blank on other contexts also, so in order to be certain, I added a second condition to check against and linebreaks for increased readability:
<h1 id="firstHeading" class="firstHeading">
    <?php
        if ($this->data['displaytitle'] != '') {
            $this->html('title');
 
        // It's the main page; put desired
        // welcome message here.
        } elseif ($this->data['title'] == 'Main Page') {
                echo 'Welcome to this wiki!';
 
        // displaytitle is blank but it's not the
        // main page; I have no idea if this
        // condition will ever be met.
        } else {
            $this->text('title');
        }
    ?>
</h1>

Wordpress plugin: Random Blogroll Category

Monday, November 16th, 2009

During my recent trip to Portland I finished my first Wordpress plugin, Random Blogroll Category. Because of my limited Internet connectivity, I wasn’t able to implement it here or submit it to the official Wordpress plugin repository until today. Wordpress reviews every plugin, so you can’t see it there yet, but you can see it in action here: check the right sidebar: there should be two headings under the search bar: Non-profit orgs and one other one and a random blogroll category. Refresh the page a couple times to see other categories.

In the next version, I hope to include the ability to show the whole blogroll, but because this plugin alters the behavior of the function that retrieves the blogroll, that’s not easily done. A workaround is explicitly listing each category as a separate call, but nobody likes workarounds.

The great irony is that I created this because I was annoyed by how much space the blogroll was hogging on the right sidebar, but now I’m annoyed by the amount of whitespace. I still think it’s better this way: it’s exciting to have the space to implement new ideas.

Backing up a MySQL database to Subversion

Monday, October 26th, 2009

As you may know, I recently set up subversion. As of this morning I was backing up my database with a daily cron job that sent mysqldump’s output to a file called database_[date].sql.bz2. That worked, but I’d rather not have to manage the files myself.

When I created the script to commit the newly created backup files, I intentionally removed the zipping step because I wanted to be able to use subversion’s diff feature, which would be useless if I commit binaries.

#!/bin/bash
# Dump the database and put it in a repository.
# Inspired by http://www.petersblog.org/node/959
# Written on Mon Oct 26 02:59:02 PST 2009
 
STORE_BACKUPS='/home/kj/backup'
WORKING_DIR='working_dir'
DATE=`/bin/date +%s`
FILE='server_'$DATE'.sql'
 
cd $STORE_BACKUPS
/usr/bin/mysqldump -u user -ppassword --skip-opt --comments=0 --all-databases>$FILE
 
# Must commit a whole directory even though
# we're only dealing with one file. The file name
# cannot change from day to day.
/bin/cp $FILE $WORKING_DIR/server.sql
cd $WORKING_DIR
/usr/bin/svn commit -m "daily backup; file saved as $FILE"
 
# I could delete $FILE now that $WORKING_DIR has
# been committed, but I like to have a backup
# backup in case the commit fails.
#     If you want to live dangerously and assume
# everything went as planned, feel free to
# uncomment the following line to delete.
#/bin/rm $FILE

I believe this will fail if cron tries to commit the file a remote repository over ssh because the user is unable to address the password prompt. I’m told ssh is designed to not let you redirect input or otherwise script around the password prompt. A potential solution is having the server authenticate ssh users by key instead of password.

Oct 26 Edit: Minor bug fix. I haven’t tested it post-change. I don’t think I added any new bugs, but nobody ever thinks that, so use discretion before running this script.

Setting up Subversion

Sunday, October 25th, 2009

Every six months or so I decide to set up subversion on my server. Inevitably, I get some error (usually at the svn+ssh stage) I can’t find a solution to and lose interest after several hours of trying. I don’t know if I’m smarter or if errors are better documented, but I was successful.

I primarily used these instructions. Some of the errors I did encounter include:

  • When testing the online repository, I kept getting a forbidden error, even after inputting the correct password. It turns out I was giving it the wrong repository name. This would have taken me forever to diagnose without tail /var/log/httpd/error_log.
  • On import, “Unable to open an ra_local [sic] session to URL”. I had the arguments in the wrong order. It should go:
    svn import [files] [protocol]://[repository]
    I wish subversion’s otherwise excellent documentation would use more explicit terminology in distinguishing between your working copy and the repository.
  • I deleted a directory in my working copy, and when I try to check it in I get the error “Directory [directory] is missing”. I thought I could solve that by deleting it with svn delete instead of rm, but apparently that’s not the case. After a couple hours of googling and still lacking a better idea, I ran svn delete again immediately before committing. That did the trick, but I’m not sure why it was necessary
  • I have two separate config files, one for the development version on my laptop and another for the live version on the server. Now that both are drawing from a common repository, I made two config files in the same package, one for debugging and the other for live. I check in the files from my laptop and ran svn update on the server to bring them up to synchronize them. This did not synchronize them. I tried checking out a new version on the server, and although subversion indicated that it completed the operation successfully, the live version is still not using Although they both claim to be using revision 6, the live version is still showing the old config files.
  • Spent several hours finding out the hard way that can’t just add a file to a working directory and have subversion include it automatically, you need to run svn add file then commit changes. This is my least favorite feature of subversion.

I toyed with making the repositories available online. While it worked, I’d like to make them pretty before I introduce them to the public

How to add rel=”nofollow” to just one link in your blogroll

Tuesday, October 20th, 2009

I link to a site that, while I appreciate its hilarity, I really don’t want to positively influence their Page Rank. Page Rank is the assessment that Google has made about the quality of a site; more non-spam links usually correlates to higher Page Rank. You can use a link’s rel attribute – created to describe relationships between documents – to tell search engines that you’re not endorsing a it.

In Wordpress, there’s a handy field for setting the rel attribute of a link, except they’ve got some Javascript wizardry in place to prevent you from just typing “nofollow”. A little research revealed lots of plugins to alter all your links in some way, but I didn’t want that. I found a site that allegedly showed how to alter the Wordpress code, but that site’s layout had such serious defects that I couldn’t make heads or tales of what it was trying to tell me.

Then I had an idea that was so smart it made me feel stupid: alter the database. Most web software, including Wordpress, is essentially a fancy interface to get information into and out of a database1. Bypass the gatekeeper by going straight to MySQL’s command line.

First, find the id of the link you want with the following command:
select link_id, link_name, link_rel from links where link_name like '%Clearingho%'

I searched for links containing the term Clearingho; you should change it to the name of the link you’re looking for.

The first column is link_id, the bit of information you’re looking for. The second is the link name, which I included to confirm that I really am grabbing the right id. Third is the existing rel value; I wanted to make sure I wasn’t about to clobber any existing data.

The link_id in this case was 18 and the existing link_rel value was blank, so it’s a simple update:
update links set link_rel="nofollow" where link_id=18

If you wanted to retain the existing rel information, you could run the following query instead:
update links set link_rel=CONCAT(link_rel, " nofollow") where link_id=18

Refresh your blog and see the new rel=”nofollow” on your suspect link. Congratulate yourself and do a silly dance.

1 Just in case it’s not already obvious, I’d like to clarify that this is not in any way a slur against Wordpress or any other database-driven2 software.
2 This buzzword is so 2003.3
3 Yo dawg, I heard you like footnotes, so we put a footnote on your footnote so you can foot while you note.

Fixing Wordpress’ “Incoming Links” after server migration

Friday, October 2nd, 2009

I recently put this blog public, which means moving it from the address where I accessed it on localhost (127.0.0.1) on my dev box to it’s publicly visible address (kjcoop.com).

Most of the move was straightforward, but I noticed tonight that the “Incoming Links” box was still excitedly giving me the buzz about 127.0.0.1

The options table has a long string of what I believe to be Javascript in the option_value column for the row with option_name dashboard_widget_option. Rather than retype all 841 characters, MySQL’s good ol’ replace function will just update the relevant string:
update options set option_value=replace(option_value, '127.0.0.1/wordpress', 'kjcoop.org') where option_id=112;

I’m noting this here both in the interest of better remembering how useful the replace function is and for the sake of other Wordpress users who may experience the same problem with the “Incoming Links” box.