Oct 7 2010

Blog Geekery: Facebook Comment Crossposting

One of the biggest problems with blogging to multiple places is that comments also get spread out all over the place. While as far as I know it's impossible to cross-post all comments everywhere, there is a neat WordPress plugin that will import Facebook comments to WordPress.  It's called Facebook CommentsTNG.  For those interested, here are the details:

  • You give the plugin your Facebook login info.  Don't worry, I looked over the code — it's not sending your login info to some third party or anything.
  • Every hour, or every day, or manually (your choice), it will scrape your Facebook notes for comments, and post them on your WordPress blog.
  • This only works for Notes that Facebook has automatically imported via an RSS feed from your blog.

Setting It Up

After installing and activating the module, and giving it my FB login info, I tried to test it, and it didn't work. Since it didn't work out of the box, I do that thing I do: I tinkered with it until it worked.  So here are the steps I took to get it to work, by the numbers:

  1. Install and activate Facebook CommentsTNG plugin.
  2. Click Test. It will likely show a blank screen.  If it actually shows some stuff, skip ahead to step 6.
  3. Go back to Facebook in your browser and refresh. It will probably have logged you out.
  4. Log in again. Go through the steps of verifying that everything is okay.
  5. In WordPress, click Test again. This time it should show you your friends' notes.
  6. Go to http://m.facebook.com/notes.php, scroll down, and click My Notes.
  7. In the URL there will be a variable like http://m.facebook.com/notes.php?id=123456789&fbb=r5b9aec88&refid=21 — copy that number after "id=".
  8. Paste that number into the Page ID setting for the plugin.
  9. Click Test again. This time it should show you your posts.

If that all worked well, you're set. Click to have it check hourly, or daily. Or if you want to control exactly when comments get scraped, select Manual.

Caveats

This is not a perfect solution. Comments on WordPress don't get posted back to Facebook. But the bigger problem is that this only works if you have Facebook auto-importing your blog posts from the RSS feed.

Why is this a problem? Because Facebook breaks the formatting to all hell when it does this. I would much prefer a plugin that scraped comments from RSS Graffiti feeds to my profile. I looked into hacking it to do this, but unfortunately RSS Graffiti links (and I assume links auto-posted to your profile by any other application) don't show up when you view your own stream in the mobile site. And with all the AJAX on the non-mobile version of Facebook, it would be a nightmare to try and parse the main page.

There is a plugin that cross-posts RSS Graffiti comments (Facebook Comments Importer)… but only if RSS Graffiti is importing your posts onto a fan page, not onto your profile.

Summation

If I want to have my comments cross-posted, then I have to either continue using the shitty Notes auto-import on Facebook, or make a fan page for my blog and have RSS Graffiti import there (which means my friends won't see new posts unless they're fans of that page). I don't like either solution, but for the time being I think I'll stick with the Notes auto-importer. My blog posts will look shitty on Facebook, especially whenever they include pictures (which they almost always do), but it's the best solution I've got for the time being.

Except, now that I've stopped importing blog posts to Facebook, it refuses to recognize my blog's RSS feed. Damnit, Facebook.

On a related note, I just found out there is a similar plugin for LiveJournal — so if you automatically cross-post entries to LJ (as I do), comments on LJ will also be scraped and posted on your main WordPress blog site. Just installed that and, of course, it doesn't seem to be working right. So I'm going to tinker with that now.


Sep 13 2010

How to Install Red5 0.9.1 on CentOS 5

 

I run an unmoderated roleplaying chat, and I've been wanting to upgrade the chat software I'm using (currently Flash chat from Tufat.com) to something a little better. Most of the "better" packages require having a Flash server installed, but Adobe's is pretty expensive. There's an open-source alternative written in Java called Red5.

However, Red5 currently suffers from pretty bad documentation. So, here's a tutorial on how to install Red5 0.9.1 under CentOS 5.

  1. Get root access (I'm not sure if this step is really necessary, but it was in my case)
    From the command prompt, execute:
    sudo -i
     
  2. Install Java
    From the command prompt, execute:
    yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel
     
  3. Install Ant
    From the command prompt, execute:
    cd /usr/src
    wget 
    http://opensource.become.com/apache/ant/binaries/apache-ant-1.7.1-bin.tar.gz
    tar zxvf apache-ant-1.7.1-bin.tar.gz
    mv apache-ant-1.7.1/ /usr/local/ant

     
  4. Export variables for Ant and Java
    From the command prompt, execute:
    export ANT_HOME=/usr/local/ant
    export JAVA_HOME=/usr/lib/jvm/java
    export PATH=$PATH:/usr/local/ant/bin
    export CLASSPATH=.:$JAVA_HOME/lib/
    classes.zip
    echo 'export ANT_HOME=/usr/local/ant' >> /etc/bashrc
    echo 'export JAVA_HOME=/usr/lib/jvm/java' >> /etc/bashrc
    echo 'export PATH=$PATH:/usr/local/ant/bin' >> /etc/bashrc
    echo 'export CLASSPATH=.:$JAVA_HOME/lib/
    classes.zip' >> /etc/bashrc

     
  5. Download and install Red5 Server
    From the command prompt, execute:
    cd /usr/src
    svn checkout 
    http://red5.googlecode.com/svn/java/server/trunk/red5
    mv red5 /usr/local/
    cd /usr/local/red5
    ant prepare
    ant dist

     

    You should see lots of output, and at the end it should say "Build successful."  If you see some errors instead of that, it's probably because you don't have Java or Ant installed correctly.  I'm not really experienced enough to give troubleshooting tips with that.
     

  6. (Optional) Edit Red5 config file
    By default, the config sets Red5 up to bind to all IPs.  If you don't want it to do that, edit red5/conf/red5.properties file, and anywhere you see the IP 0.0.0.0 replace it with your server's actual IP address. You can find this IP by executing this command:
    /sbin/ifconfig eth0| grep 'inet addr:'
    Then use the IP address listed directly after "inet addr:"

     
  7. Install Tomcat container
    This is necessary to make it so that you can verify your installation and administer it via the web.

     

    1. Create the directory red5/plugins.
    2. Go to http://www.red5.org/wiki/AppServer/JEEContainerPlugins, download the pre-compiled Tomcat JAR and save it to red5/plugins
    3. Look inside of that Tomcat JAR (you can rename it to .zip and unzip it if need be), extract the jee-container.xml file, replace your current red5/conf/jee-container.xml file with that one.
    4. Go to http://code.google.com/p/red5/source/browse/#svn/repository/tomcat, save the latest version of each file there to red5/plugins
      • As of when this guide was written, this includes 6.0.26 of Catalina and Jasper and Tomcat-Coyote, and 6.0.20 of Tomcat-dbcp, Tomcat-juli, and Tomcat-juli-adapters
         
  8. Start Red5 and test installation
    From the command prompt in the /usr/local/red5 directory, execute:
    ./red5.sh
    If all goes well, that should end with something to the effect of "[INFO] [Launcher:/installer] org.red5.server.service.Installer – Installer service created".  If it hangs at "Bootstrap complete," that most likely means that you did not correctly install the Tomcat container in the previous step.

Note that when you launch from the command line, if you kill that terminal window then Red5 will stop running as well. In not too long I'm going to update this tutorial to show you how to get around that.

 

 

 


Sep 8 2010

iOS 4.1 Preliminary Review

There were a few neat improvements in iOS 4.1. It had some smaller bug fixes of course, like fixing the proximity sensor so that you're less likely to hit the mute or end call buttons with your cheek while you're talking. Neither has happened to me, but my girlfriend did once suffer from the accidental mute issue. It also has a game interaction feature, where you can invite friends to join in on games, earn achievements (I couldn't personally care less, but there seems to be a craze over achievements in the gaming world), and that sort of thing.

But there were two big updates that really interested me personally: high-def uploads, and HDR photos.

High-Def Uploads

Now the built-in movie uploader (which can upload to YouTube) is able to upload in full 720p high-def. if you're on a WiFi network. It used to force the resolution down, so my first iPhone 4 test video actually got uploaded as low-def.

HDR Photos

HDR stands for "high dynamic range." You only really need to use this option if the photo you're taking has very bright and/or very dark areas that you want to come out better. The phone snaps 2 shots in quick succession and uses some magic to combine them into one good shot with (more) consistent lighting.

Here's an example, normal on left, HDR on right:

 

You can click the images for higher-resolution versions.  However, this doesn't really do much for photos that aren't high-contrast. Here's an example of a normal and HDR version of a picture with consistent lighting:

 

The second one actually looks worse, in my opinion — a little more washed-out (since it's darkening the really light areas and lightening the dark areas). So make sure to only use this option when you need it.


Aug 29 2010

vBulletin Login Integration

I run a roleplaying chat website that has a forum and a separate chat section. However, the forum is integrated into the main site, and the chat. I was recently looking at moving from phpBB to vBulletin as the forum software[1], but needed to make sure that I could still plug the chat and the rest of the site into that easily. Apparently the vBulletin people are paranoid about giving out any code that is in any way related to vBulletin, even this sort of thing. So I did some digging, and found out how to do it.

Here's an example of how to do that. It really is pretty simple.

<?php
// This gets the vBulletin user login info
$curdir = getcwd();
chdir('/path/to/your/forums');  // Change to vBulletin directory
require_once('/path/to/your/forums/global.php');
chdir($curdir);  // Change back to previous directory

// This is the part that actually deals with users
if ($vbulletin->userinfo['userid'] == 0) {
  // User is not logged in; maybe show login form here
  echo "Not logged in.";
} else {
  // User is logged in
  echo "Welcome Back, <b>".$vbulletin->userinfo['username']."</b>";
  // See if user is in a certain user group
  if ($vbulletin->userinfo['usergroupid'] == '6' ) {
  // Maybe this is an admin usergroup, so show admin stuff here
  }
}
?>

So I hope someone else out there finds this useful. If you want to see what all data is contained in $vbulletin->userinfo, just do echo nl2br(print_r($vbulletin->userinfo, true)).

Caveat: I have yet to try this myself, so I'm not 100% sure it will work. But it seems to make sense, and is similar to integration of phpBB and SMF.

[1] Why move from phpBB to vBulletin, when vBulletin costs nearly $200? Overall vBulletin is just better, but here are a few more specific reasons, in order of importance:

  • vBulletin supports Facebook Connect out of the box. That means users don't have to sign up for an account on the forum — they can just click the Facebook Connect button, click to verify, and then bam… they have an account and they're logged in.
  • vBulletin has better anti-spam controls. My forum gets hit with more spam than regular posts. The best anti-spam measure is to require that new users pass a reCAPTCHA test. Modules that make phpBB do this are buggy at best. Granted, SMF (which is free) also has a module that does this pretty easily. It does not, as far as I can tell, currently have a working module for this. The best contender that I found costs $20, and seemed to have a broken implementation on their own site. Not very heartening.
  • vBulletin has a better plugin system. It's nowhere near as awesome as that of WordPress, but still much better than the "send file to server via FTP, edit your existing files" method of phpBB. Granted, a lot of the vBulletin community still does modifications in the old hack-ish way. SMF has a similar system to vBulletin. So as you can see, if it weren't for the damn Facebook Connect thing, SMF would probably win out. It's possible that between now and when I get around to this, the SMF mod will be working though.
  • vBulletin is neater. It's just got a lot more AJAX stuff, a WYSIWYG editor, and other little features that add up to making it a nicer overall experience.

Aug 25 2010

New AT&T DSL Service, Actiontec GT701D Modem

Recently AT&T was running a deal where their 6Mbps DSL service is $20 a month for an entire year, then $45/mo after that (they might still be running it). I was paying about $65/mo for cable modem service through Comcast, so even after buying the modem, this will save me about $500 the first year, and $240 every year thereafter. Slightly slower service, but really that’s a no-brainer for me.

The default modem that AT&T recommends is the Motorola 2210. According to all reviews I’ve read about this modem, it overheats and dies a little over a year after setup. So searching for alternatives, I found the Actiontec GT701D, which (as an added bonus) was also $30 cheaper. The only downside is that AT&T tech support can’t help much with the setup. I figure I’m handy with computers, so I’ll take the gamble on the cheaper and better modem.

Short story: everything worked out fine (eventually) and now I’m on my DSL connection.

The Actiontec didn’t initially connect up with the automagic detection, so I had to do a bit of snooping. It’s a very good thing that I still had my old ‘net connection running, to do some Google Fu. After a bit of searching I found the right settings. For anyone else out there in this situation, here’s what those settings are:

Username: attreg@att.net
Pass: attreg
VPI: 8 (this is for AL, FL, GA, KY, LA, MS, NC, SC, TN; other states use 0 for this)
VCI: 35
DSL Mode Setting: ADSL2 (EDIT: after a modem glitch and talking to Actiontec support, this is apparently supposed to be MMODE. No clue why ADSL2 worked before).
ATM QoS class: UBR

Note that the username/password are only for initial setup. You have to go to the registration URL to set up your real username/password. But do note that the password you use for your modem is the alphanumeric string that gets automatically assigned to you, not the one that you type in yourself.


Aug 9 2010

Subversion Checksum Mismatch Workaround

This post relates to Subversion, a version control system. This is used most commonly in programming to allow multiple programmers to work on the same set of files at the same time without stepping on each other’s toes. It also lets you “roll back” your code to any point in time, so if you screw something up, it’s ultra easy to go back to the point before that.

Some writers also use this sort of things to keep copies of their writing, and then if they change/remove something that they later decide they shouldn’t have, it’s easy to peek back at what it was like.

Anyway, sometimes when dealing with Subversion, you might get an error like this when trying to run svn update:

svn: Checksum mismatch for ‘/path/to/repository/.svn/text-base/some-file.php.svn-base’; expected: ‘e5b110ec4409891e81f38203d45e4f5d’, actual: ‘c84a851f87b9b62934b44adc457dcfd0’

There are two fixes for this.  The first is to just delete the directory containing the code where the checksum mismatch is (including the .svn directory below it), and run svn update again from one directory up. But if, like me, the checksum mismatch is in the base directory and it’s inconvenient to do that*, there is another solution. Basically you will check out a fresh copy of the affected directory, and copy over the SVN file with the checksum error.

  1. Check out a new copy of the repository in some other directory. If the problem is in a subdirectory, you only have to check out that subdirectory.
  2. Rename the file mentioned above (the one with the checksum error, /path/to/repository/.svn/text-base/some-file.php.svn-base in this example) to add -bak on the end of it.  It’s always good to have a backup.
  3. Copy that file from the working copy you created in step 1 to your “real” repository location.
  4. Run svn update to see if it works. If not, make sure that in step 3 you copied the file to the correct directory (it needs to go under the .svn/text-base/ directory).
  5. Once that works, you can delete the other working copy you checked out, as well as the -bak file you created.

I’m putting this here in the hopes that Google will index this, and someone else with the same problem might find it useful.

* In my case, I have a lot of images and other things that need to be there, but that aren’t in the SVN repository, so just wiping it out and checking out a whole new working copy of the repository doesn’t really work.


Jun 29 2010

MySQL Training

A few weeks ago, I went to a MySQL training seminar focused on developing and tuning high-availability applications with MySQL, hosted by Percona and paid for by my work. It was an extremely informative seminar. We’ve hired the people at Percona before as our database ninjas, as I like to call them. They are not at all cheap to hire for consulting, but they are absolutely worth every penny. These guys live and breathe MySQL.

Anyway, I took away some good tidbits from the session, but more than that I gleaned some good general philosophies. For example, when diagnosing a problem first make sure it’s really a problem. If only a few users are experiencing it intermittently, then maybe it’s not worth 40 man-hours to investigate and fix. Another tips is: have good instrumentation. Don’t take educated guesses as to what might be slow — build in some metrics so that you can see exactly where a problem is.

A lot of this stuff is still sinking in, but I’ve already started putting some of it to use immediately. Good company investment, and a good personal investment too.


Mar 24 2010

MySQL “Can’t create table” error fix for WAMP

This is a post for the MySQL geeks out there, and also for anyone who had a similar problem and might be searching for a solution.

I was trying to copy our testing server’s database to my local machine, so I can do some local development (I’ve set up a web server and database on my personal computer, so that I can test things out before moving them to the development server). I’m using WAMP for that, which is a very simple way to set up a local webserver on Windows.

Well, when I tried to import the database I got the following error:

Error Code: 1005 - Can't create table 'whatever' (errno: 121)

So I edited my.ini, and increased max_allowed_packet, like so:

[mysqld]
max_allowed_packet=32M

I’ve heard that some other people have also had to increase wait_timeout to something like 45 seconds to fix this error.


Mar 4 2010

Google Flops?

Google Buzz, and before it Google Wave, seemed to have great potential. I played with both when they came out.  But my interest quickly waned, and from what I can tell I’m very much not alone in that.

Part of the reason is that I think Google jumped the gun. In marketing, you have to be careful about when you create a buzz (pun intended). And especially with products like these, they’re only useful if everyone is using them. In both of these cases, I think Google was directing the general tech populace to use products that were incomplete.

With Wave, they should have had permissions from the get-go, so that you could invite people to see, but not edit, a Wave. They have that now, which is nice, but it’s a bit late in the game — comparatively few people regularly use Wave any more. There are a lot of other things they did wrong with Wave, too: it was much buggier than I’d expect from a Google beta, slow as molasses, and too broad in scope. That last one is really what killed it, I think. People generally want a clear path for using a product; they want a sexy sports car, not a bunch of parts that they have to figure out how to best put together to build a sports car that suits their needs.

With Buzz, they went the other way. It’s too damn simple. I have lots of friends. Some I’m closer to than others. Some I want to pay more attention to than others. So maybe I’d like to be able to easily see a Buzz stream from only certain groups, instead of everybody. Maybe once I start or participate in a discussion, I’d like to select whether I get emails specifically for that discussion. (And while I’m at it, hey Facebook! How about being able to turn off receiving emails just because I thumbed-up a post that 50,000 other people feel the need to comment on?) Maybe I would like to have my Twitter posts show up in some decent timeframe, instead of the next day if I’m lucky.

Overall, I love the things Google does. Chrome is amazing, and broke the web browser mold when it came out. Gmail has been my email client of choice for years now. Their search engine revolutionized the web.

Then again, not every hit can be a home run. I like that they’re trying new things! I just think that a lot of these things have great potential, but were executed poorly. And that makes me sad.


Mar 2 2010

Computer Building Fun

Two tools I really didn’t think I’d need for building a system: needle-nosed pliers, and a file. Where the hard drive went in, there was a retaining bracket that was preventing a hard drive screw from passing, so I had to bend it. And when I replaced the case fans with better and quieter ones, the size on the front one was off by a fraction of a millimeter, which required filing off the plastic around where it went in.

However, this time no blood was spilled. I think that might be a first. So, I consider it a success!

I also remembered how annoying it can be to build a system. I got a power source that can handle 2 video cards (“Crossfire capable” they call it, for ATI cards), but the kind I got took both of the power connectors. So I can’t actually use 2 without upgrading my power source. Talking to NewEgg about that, but so far no luck asking for an exchange.

Also, I remembered a little hack for installing Windows clean, using an upgrade disc. You can use an upgrade version as the full version in one of two ways when installing it fresh (i.e. wiping whatever is already on there, if anything: install it fresh and then install it over itself, or (the quicker, easier way) do a simple registry edit.

Something else I realized: I have a Logitech Performance MX wireless mouse (no, I did not just realize this, shut up). It is pretty awesome, but my only complaint has been that it will randomly stick, and for 30 seconds or so it stutters and jumps around the screen when I try to move it. Today I tried something that seems obvious: I moved the damn wireless receiver to a USB port closer to the mouse. Guess what? No issues since then. I know, I’m a frackin’ genius.

Okay, so how does the shiny new system work, you ask?

It’s fast. Very fast. I attribute almost all of that to the SSD. That’s a solid-state drive; a hard drive with no moving parts. They are expensive, for much less space than you will get with a normal hard drive, but they are about twice as fast, 1/4 the size overall, use far less power, make no noise, and emit almost no heat. For laptops, they are about the most awesome thing you can have. For desktops, still quite awesome.

One not-fast bit is logging into Windows. It gets to the login screen, I enter the password, then… it sits there for 20 seconds before continuing. I’m not sure why this is, and I don’t think it initially did it. But it doesn’t happen when I’m waking the computer from sleep or hibernate, and I almost never have cause to do a full power-off or reset, so that’s not really a big deal.

The only other pet peeve I have is that, even though there is a connector for it, the case has no hard drive activity indicator light. And since the SSD is even more silent than a ball-gagged ninja, there’s no way for me to know when lots of hard drive access is going on. I mainly look at this when the system seems to be randomly crunching/slow though, and since that hasn’t yet happened… I can live with it for now.

My work-oriented stuff is very fast as well. We use Subversion, a system that lets multiple people work on the same code at the same time without stepping on each other’s toes, and it also retains a complete history of every change ever made to the code, so that you can roll back if you screw something up. Performing updates and commits with this is very notably faster than it was on my old system (also a quad-core system, with 5 GB of RAM).