WordPress Sitemaps for Multisite Setups

I run several WordPress blogs with one codebase. This allows me to update the codebase once, for all by blogs and also allows me to share plugins. It’s convenient and the way to go if you want to focus and tailor your blogs by topic or audience.

One detractor from this setup is trying to get sitemaps generated for each blog. At the time of posting, current plugins which generate sitemaps were not able to successfully handle this type of multiblog, one code base setup. This is annoying at minimum and possibly damning depending on how well the bots can crawl my page.

My first thought was to go ahead and modify the plugin. How hard could it be? Answer, too hard. I’m sure it can be done, but I have better things to do then swim in that code and figure it out. Next thought, write my own simple plugin. After all, how hard could it be? Answer, too hard. I’d rather figure out the WordPress API later and need sitemaps generated now.

So, I was left to my own crude devices. What I created were 31 lines of simple bliss which gets the job done. The code hinges on two facts: 1) Google accepts simple text files with URLs as a valid sitemap and 2) it’s easier to locate at the tables WordPress employs and figure them out with a few queries then learn an API/workflow or decipher a bunch of code.

Now, detractors will say that it is better to follow the API and build a plugin. That way the code will continue to work as WordPress evolves. And they are correct. That would be the way to go. But hey, this code was quick to write and will tie me over until something better comes along.

Now for the code, written as a php file

  /* Set base url for blog */
  define('BASE_URL', 'http://merit.oryo.us/b'); 
  /* Set table name for posts, could be as simple as wp_posts.  */
  define('TABLE_NAME', 'merit_wp_posts');
 
  /* Set relative paths here to load db credentials */
  require("wp-load.php"); 
  require("../../../wordpress/wp-config.php");
 
  $link = mysql_connect('localhost', DB_USER, DB_PASSWORD);
  if(!$link) {
    die("Couldn't connect: " . mysql_error());
  }
 
 
  mysql_select_db(DB_NAME, $link) || die( mysql_error());
 
  $result = mysql_query("SELECT ID,post_name,post_status FROM " 
    . TABLE_NAME . " ORDER BY post_modified DESC" );
  if(!$result) { die("Error: " . mysql_error()); } 
 
  while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    if($row['post_status'] == "publish") {
      /* Tweak line to display proper url, 
       BASE_URL . "/index.php?id=" . $row['ID'] . "\n" will surely work */
      print BASE_URL . "/" . $row['ID'] . "/" . $row['post_name'] . "\n";
    }
  }
 
  mysql_free_result($result);
 
  mysql_close($link);

As you can see, there’s not much too it. Simple and unsophisticated but works. Of course, to use this you need to have some understanding of what you are doing. If you can’t make since of the code, best to wait until a sitemap plugin comes along that will properly handle a WordPress site with multiple blogs.

Typing spanish characters and accents in Linux

Being able to properly type and input spanish characters in text is important. If you don’t believe me, ask someone who speaks Spanish to explain the difference between año and, well, ano. Trust me, if you are trying to use año (ie, year), you don’t want to end up writing ano (ie, anus). Plus, for those hosting WordPress blogs or webpages in Spanish, if you want your pages to be properly crawled and have appropiate ads displayed, better to write with the proper characters, accents and punction.

Now, if you are working in a Linux environment like I normally do, it turns out that being able to input the necessary comments and punctionation is easily accomplished. We will use the popular “Dead keys” method. This will allow us to type an ñ by first pressing shift and tilde followed by an n. Similarly, we can type an accented charcter by first pressing followed by the charcter that we want to accent. If you want use the original functionality of the dead keys, just follow the key press with the spacebar. It doesn’t take too long to get use to.
To get started, just execute the following command


my-box:~ $  setxkbmap -layout us -variant intl

When you need to switch back, leave of the variant parameter


my-box:~ $  setxkbmap -layout us

Now, I need to say here that this will only work in when running X windows. But, I’m not trying to help you do a full blown switch to an international keyboard nor load a different keymap on the system level. This is just to help the casual user with US keyboard properly input Spanish characters, accents and punction. This could be used to write up a homework, communicate with a friend or post in another langauge with our friendly Linux box.

Así, ¿qué esperas? ¡Hazlo ya y no lo vas a arrepentir!

Type in Algebra Problem Get Answer

Are there any websites out there that will let you type in an algebra problem and get an answer?  The short answer is no, there isn’t.  There are a few sites that have so called “solvers”.  These you will mostly find unsatisfactory as they will “solve” problems that you can already do and do them fast with your own calculator.  What you will find are forums and some simple calculators.

For those of you who have a bit more time and patience, the forum route is a good one to take.  Algebra.com has a number of wonderful math tutors who will solve your problems few of charge provide you post it in the right spot.  The solutions and explanations I’ve seen there are correct and very helpful.

For the do-it-yourselfer, you can get some answers to your algebra problem using some online calculators.  These can be a bit more finicky and do require that you have somewhat of an idea of what is going on.  One drawback here is that there is no additional human interaction.  The software which implements the calculator probably will do a decent enough job but there are no guarantees.  Most of the calculators you will find are for simplifying polynomial expressions and solving linear and/or quadratic equations.  If you want to solve radical equations, logarithm equations or rational equations you’re probably going to be out of luck.  One of the more interesting and slightly more advanced online algebra calculator that I’ve seen recently is the radical expressions calculator.  It’s capable of solving most roots and does so in a step by step process.

Setting up NCBI Blast on Unix System

While installing a precompiled version of NCBI blast on your localbox is fairly straightforward, there are a few gotchas that got me.  Let me eloborate in hopes that they won’t get you too.

If you’re following the instructions kindly provided at NCBI’s site, good.  Continue.  They’re quite adequate and will work for most.  If you’re still reading this message, I take it the instructions were lacking.

One problem you might have is installing at database.  I don’t know why, but the update_blastdb.pl script that is packaged with the binaries did nothing but waste my time.  You can still download the gzipped files and install them yourself.  I chose to go the NONFORMATED DB route because the preformated databases that I downloaded where missing some files.  Formatting the databases is a simple task and can be done with the formatdb command.

NCBI recommends that you place your databases in a seperate directory.  To let blastall, megablast, et al. know about the dbs you must place an .ncbirc file in your home directory or have one in the current working directory when you “blast” a sequence.  If you don’t know who will be using the programs, you can tell blast where the databases are located with the “-d” flag.

megablast -d ../blast/db/nt -i myseq.fasta -o megaoutput.bls

It makes more sence to me to state the db path explicitly since you probably don’t want to make sure that every user has a .ncbirc file in their home directory (assuming this install is for a multi-user system).  Explictly stating the db path also is helpful when calling the program from a script.

Howto Setup a Access Point with RaLink r61

This post is dedicated to my trials and the perils of trying to setup hostapd with a RaLInk rt2561/rt61 pci wireless network card.  It has been a long hard road, mostly because documentation is scarse.  To get an idea of what’s out there, have a look at the AP-mode “howto”.  Note the humorous comment at the beginning…”[it] is not aimed for beginners.  Hell, that howto isn’t aimed for anyone as far as I’m concerned.  So, let’s see if we can’t do a little better.

First, you’ll need to install

  • libnl-1.1 or better
  • udev-1.25 or better (I’m using 1.35, but apparently 1.25 will do)
  • hostap-0.70 or better (use git clone git://w1.fi/srv/git/hostap.git)
  • linux-2.6.29-rc6 or better

Okay, first we’ll take care of the kernel.  Make sure that the soft link /usr/src/linux points to your shiny new kernel’s source.   We also need to patch the net/mac80211/cfg.c file.   Go ahead and open this file and towards the very beginning, change…

static bool nl80211_type_check(enum nl80211_iftype type)
{
switch (type) {
case NL80211_IFTYPE_ADHOC:
case NL80211_IFTYPE_STATION:
case NL80211_IFTYPE_MONITOR:
#ifdef CONFIG_MAC80211_MESH
case NL80211_IFTYPE_MESH_POINT:
#endif
case NL80211_IFTYPE_WDS:
return true;
default:
return false;
}
}

to this…

static bool nl80211_type_check(enum nl80211_iftype type)
{
switch (type) {
case NL80211_IFTYPE_ADHOC:
case NL80211_IFTYPE_STATION:
case NL80211_IFTYPE_MONITOR:
#ifdef CONFIG_MAC80211_MESH
case NL80211_IFTYPE_MESH_POINT:
#endif
case NL80211_IFTYPE_WDS:
case NL80211_IFTYPE_AP:
case NL80211_IFTYPE_AP_VLAN:
return true;
default:
return false;
}
}

Finally, compile the kernel and the RaLink driver (Device Drivers -> Network Device Support -> Wireless Lan -> Ralink Driver Support).

Next, we’ll take care of hostapd.  Enter the hostap/hostapd directory and copy defconfig to .config.  Now, edit .config and set the driver to nl80211.  You should have CONFIG_DRIVER_NL80211=y.  Run “make” and hopefully everything compiles.  Edit hostapd.conf to your liking.  In particular, you will want to change the country code and channel to whatever is appropriate and the driver to nl80211.  I followed the steps in this nice tutorial to get WPA-PSK set working with hostapd,  At this point, you should be able to fire up hostapd with ./hostapd -d hostapd.conf and be up for business.

As I said before, I had a number of problems when trying to set this up.  Here are some pitfalls to avoid…

  • Make sure you can set the channel of your device.  The iw tool set can help out here.  Something along the lines of “iw dev wlan0 set channel 8″ should work for you.  If it doesn’t, make sure you are using a 2.6.29-rcX kernel.
  • You MUST patch the net/mac80211/cfg.c file or your device will not be able to enter into master (AP) mode.
  • iwconfig is useless as far as hostap is concerned.  You won’t be able to use it to get into master mode.  Don’t even try.  Not even once.

Of course, once you get your ap up and running, you’ll need to setup a dhcp server to handle ip address for your clients and also do some routing/forwarding for them.  Perhaps, I’ll touch on that next time.

Also, please inform us of your own success and any pitfalls you encountered and overcame.

Gimp Tutorials Over Must Know Techniques

It’s come to my attention that there isn’t a concise list of Gimp tutorials dealing with basic and have to know techniques. Sure there are lists of tutorial sites out there (like this one from TutorialBlog) but with those you have to slink through them all to get at the good ones. Plus, you’d be hard pressed to find one of those tutorial sites categorize their gimp tuts by technique. What I hope to achieve here is just such a compilation, solid tutorials covering the basics to gotta know it stuff organized by technique. Enjoy and please feel free to let me know if you think an addition should be made.

Paths

Drawing Arcs with Gimp


Path Basics from Gimp.org


Useful Things to Do with Paths


Creating Overlays with Paths from Mike’s Picks


Brushes


Best of GIMP Brushes
by Techzilo


24 Sweet Brushes for Gimp complements of Kristarella


See Stars by Editing Your Brushes


Grids and Guides

Grids and Guides in Gimp


Gradients

30+ Gradients offered by Gimp-tutorials.net


Shadows

Inner Shadow

Grids and Guides in Gimp

Let’s get down to the nitty “griddy”. That’s right. Last time we created our bulletin board and this time where going to fill it. We’ll add some paper and some post-it tabs and do so quickly using grids and guides.

Again, we’ll be working with our bulletin board. If you haven’t done the first part of the tutorial, you can grab the bulletin.xcf.

First, let’s turn on the grid (View->Show Grid). At present, the grid might be too sparse. We’d like to have the points on the grid 15px apart. This can easily be done. Simple configure the grid (Image->Configure Grid) and set the spacing to 15px.

Now, with our grid setup the first item we want to add is a sheet of paper. Create a new layer and call it paper. Go ahead and make a 300×375 rectangular selection for the sheet of paper.

Did you get it? It’s easy to do than you might think. Sure the grid can help you “eye ball” it, but it’s real power comes from snapping to it. Activate snapping now (View->Snap to Grid) and try the selection again. It should be much easier now. Once you have the selection, fill it with #f1f1f1.

The next step will be to add some lines. You remember good ol’ ruled paper, right? That’s what we’re after here. Create a layer for the lines and call it “rules”. Select #b2c7fd and the pencil tool with a 1px brush. Starting from the 4th grid part from the top, draw lines back and forth. To do this, hit one side with a dot and then hold down the SHIFT key and move over to the over side. When you have the line you want, hit the mouse again to draw the line. Continue down the sheet. At some point you may want to turn of the grid to see how you’re doing.

Next, paint a pink line (#bc5858) down the left edge and cut out a few holes.

For our next trick, we’ll add some post-it tags. We could do this with grids but we’ll use guides. But first, go ahead and turn off the the grid (View->Show Grid) and turn off snap to grid (View->Snap to Grid). Now, turn on guides (View->Show Guides).

Hmm. Nothing happened. Where are the guides? Well, we have to add them. To add a horizontal guide, click up in the rule on the top and pull down. You should see the guide. Drop 6 horizontal guides and a couple vertical guides as shown. It will help to zoom in to 200%.

Turn on snap to guides (View->Snap to Guides) and make rectangular selection inside the guide. Create a new layer and call it “post it tabs”. Fill each rectangle in with a post it type color. Then set the opacity of the layer to around 60%.

Finally, create another layer, “post it tabs overlay” and use the pencil tool to draw a darker border around the tabs.

From there, with a few more touches you can get …

The curious can check out the bulletin2.xcf file.

Free College Algebra/Calc Help at Mathmat.oryo.us

A couple days ago we unleashed a sister site, mathmat.oryo.us, which will offer math help. At present, there’s the math forum which has a section dedicated to college algebra. High school algebra and Calculus are on the way. It’s completely free. Spread the word if you would.

Building a Bulletin Board with Gimp

With this post, I hope to start the first of a three or four part post tutorial on how to create a realistic bulletin board using our beloved Gimp. The result were striving for is something more or less what I have on my fleshed out, but not completely finished home page. At the end of the post we should have the following.

To start, create a new 800×600 image and set the fill to transparent. Now let’s get to work on the frame. What we’d like to do is create a 20px wide frame all the way around the image. So pop quiz, hot shot, how ya gonna do it?

Well, if you don’t have any ideas, you can always do what I did (After all, this is a tutorial). I selected the entire image. You can use the Fuzzy Select tool (magic wand) if you like or Select->All. Then I shrunk the selection by 20px (Select->Shrink). The last step is to invert the selection.

Now create a new layer (Layer->New Layer) and call it “Frame”. With the layer active, fill the frame with #dba368.

Next, we want to give the frame some feel. It looks way to flat and bland. Therefore, let’s add to level to the frame. This is really nothing more than a frame for our frame. Do do this create a new layer and call it “Frame Bevel”. Select the paintbrush and the Circle Fuzzy brush with a 7px radius. We also need to use a darker shade of brown (#af6a31 worked for me). Make sure the “Frame Bevel” layer is active and then paint a border around the frame. This can easily be achieved if you zoom in to 800%. Go to the top left and dot the corner with the dark brown. Now scroll all the way to the bottom and hold down SHIFT and CRTL. You should see a line. This is what will be painted when you click the mouse. Go ahead and move the cross hair down to the lower left corner and give your mouse a click. You should have a nice straight line. Continue your way around the frame until you make it back up to where you started. Do the same with the inner part of the frame but with a lighter color (#f6cba0 should do).

Let’s check our progress…

Now that’s not to bad. We used a fuzzy brush to give us several shades of brown and thus give us the bevel effect. However, it looks like we over did it a bit. Let’s try to sharpen up the inner portion of the frame. To do this, select the Eraser tool and the circle brush with a 5px radius. Zoom in again and use the same trick to go around the frame and shave of about 1/3 of the bevel on the inside.

Now we have our frame. Let’s add the corkboard. At stock.xchng I found this image of a corkboard. Grap it and open it up. As is, its way to large. Scale it down to 1000×800 and copy it. Now paste it in (Edit -> Paste Into). Pull up the Layer dialog and make a new layer out of the pasted layer (corkboard). Press the new layer button to do this and move the board underneath the other layers.

The final touch is an inner shadow for the corkboard. Switch to the “Frame” layer and and select the frame. Feather the selection by 10px (Select->Feather). Next, create a new layer and call it “Inner Shadow”. Fill the selection with black. For more help with technique, you can check out my Inner Shadows tutorial.

That’s it. Here’s the xcf file.

Next time we’ll add some “flair”.

Now available, part 2 of building a bulleting board, Grids and Guides. Check it out.

Free SSH Hosting

Not too long ago I found myself in a predicament. I wanted to be able to log into my box at home from work but both where behind firewalls and both had dynamic ips allocated. The solution was using ssh and port forwarding.

To get this to work, I needed a third computer that I could log into and set up the port forwarding. I combed the web looking for a free option. I thought, ” There are plenty of free web hosts out there, surely some must be offering ssh access as well.” Wrong. If you don’t believe me, look. If you’re looking right now, keep looking. When your done, come back.

Since there’s not a free option out there, you have to find a reasonable web host that will give you ssh access. I ended up going with bluehost and I can’t complain. I signed up and had ssh access with in hours, I kid you not. Plus, since you’re given unlimited bandwidth, you can setup you ports and forward them one without worrying about gobbling up MBs.

When you consider that bluehost will also give you the ability to host an unlimited number of domains and store an unlimited about of data on their hosts, its a deal hard to pass up. Go bluehost for your free ssh needs and a whole lot more.