I’m messing around with my domain settings

I’m going to map bnmng.com to another server because I’m so much more than just an erudite blogger, I want to have a place under my URL for such projects as my WordPress themes and by blog reader/sharer if I ever get around to finishing it.

This blog will still be under https://bnmng.wordpress.com, but no longer under bnmng.com.

If you’re one of my countless devoted followers, there’s no need for panic or suicide! I think I can keep the old RSS feeds going by creating a directory on the new server called “feed” and creating an index.php file with the following code:

<?php

$url='https://bnmng.wordpress.com/feed';
if(isset($_SERVER['QUERY_STRING'])) {
$url=$url . '?' . $_SERVER['QUERY_STRING'];
}
$output=file_get_contents($url);
echo $output;
?>

So the RSS feed “http://bnmng.com/feed?cat=262&#8221;, which was mapped to this wordpress blog but will be mapped to the new server, will grab and return the contents from “https://bnmng.wordpress.com/feed?cat=262&#8221;. That should work.

I don’t know if email subscriptions will be affected at all, but I think when I select bnmng.wordpress.com as my primary URL, those will automatically be updated.

Blog Reader / Post Sharer

I’ve been experimenting a way to share posts on my sidebar. Rather than a static blogroll which just lists blog titles or an RSS feed which shows every post from the feed, I want to specifically select the posts that appear on the sidebar. I don’t know if there’s already something out there that does this.

I’m working on a blog reader which lets me select posts. When I choose to share a post, it writes an XML file which includes only those selected posts.

On my blog, I have an RSS widget which reads the file that I created.

My source is a yahoo pipe:

I use the regex module to add a feed title to the beginning of each post. Doing this is useful for a mashup because the feed title would otherwise get lost.

But the source can be any valid feed, either a mashup or a feed from a single blog.

What my reader does is displays all posts from the source feed, each with a “Share” button, which, when pressed, recreates my XML file. The XML file is an RSS feed which only includes posts which I have selected. It doesn’t include posts which have scrolled off my feed, so this isn’t like a bookmarking service which will save bookmarks indefinitely.

The result is on my sidebar, titled “Selected Posts from my Blogroll”.

It only updates when I use it, so my sidebar will be stale if I don’t keep up on it.

The server that this all runs on is at suffolkian.com. My xml output file is http://www.suffolkian.com/bnmng_blogroll/selectposts/selectedposts_bnmng.xml

I’m still just experimenting, but if you want to use this application or help me test it, use the contact form and let me know your user name, email address, desired password, and source feed. This is real low security, so you probably shouldn’t use the same password that you use for your online banking. I’ll make a configuration file for you and email the link to your reader and the link to the xml file that the reader generates. I make no promises that it will work or that you won’t loose your saved posts as I make changes to the code.

Alternate Run command for Ubuntu 11.10

I have a habit of solving problems that have already been solved better by someone else, and I may be guilty of this here, but I wrote my own command prompt script because I didn’t like the default command prompt in Unity. A more sane way to solve the problem might be to install and setup gnome-shell, as described here, but I still like my script.

The script presents a list box with [type command] as the first choice and your command history as all the other choices, with the most recent on top (your command history is blank the first time).

Dropdown box of historical command list, with first choice [type command'

Using Ubuntu 11.10 with Unity, after creating your script with the listing below, save it in an appropriate location and make it executable.

Then choose system settings > keyboard > shortcuts > custom shortcuts, as detailed here: Click the gear in the upper right corner of your screen and choose System Settings. From there, find the keyboard widget (not the keyboard layout widget), choose the shortcuts tab, and click custom shortcuts.

Click the + sign at the bottom, and add the path name of the script file. Then click on the shortcut field (it probably says “Disabled”) and click again if necessary until it says “New shortcut”. Then press the keystroke that you want to assign. You probably want alt+f2.

Keyboard control panel, the selected item from the left menu is Custom Shortcuts

You may have to disable alt+f2 elsewhere to avoid conflicts, but I didn’t disable it for the Unity plugin in CCSM and I’m not having any problems.

Below is the script.

#!/bin/bash

#Filename: launch (or whatever you want to name it)

#Command Launcher
#Brings up a dialog box from which you can choose a command from your history
#Also has a choice to type in a command

#Works in Ubuntu 11.10 with Unity
#Requires zenity

#Make this file executable.
#You can create a hotkey in the "Command" section in CCSM

#You can directly edit this history file
HISTFILE=~/.launchhistory
TEMPFILE=~/.launchtemp

# Setting the field separator to be newline, to preserve whitespace
OLDIFS=$IFS
IFS=$'\n'

# Populating the list box with commands
# The first command to appear in the least box is [type command], which brings up a text box
echo "[type command]" > $TEMPFILE

# The remaining commands in the list box come from the history file
for hist in `cat $HISTFILE`; do {
echo "$hist" >> $TEMPFILE ;
} ; done

# Setting the field separator back to normal, to run the command properly
IFS=$OLDIFS

#calling the zenity list box to bring up a choice of commmands
runthis=`cat $TEMPFILE | zenity --list --column='choose' `

#If user chose [type command], bringing up the zenity text box
if [ "$runthis" == "[type command]" ]; then {
runthis=`zenity --entry --text="run"`
} fi

#Running the command, and if successful adding the command to the history file
$runthis && {

# Setting the field separator to be newline, to preserve whitespace
OLDIFS=$IFS
IFS=$'\n'

#Putting the new command at the top of the tempfile
echo "$runthis" > $TEMPFILE

#Putting the old commands from the history file into the tempfile
for hist in `cat $HISTFILE`; do {
#But not repeating the newest command
if [ "$runthis" != "$hist" ]; then {
echo "$hist" >> $TEMPFILE;
}
fi
} ; done
#Saving the tempfile as the history file
cat $TEMPFILE > $HISTFILE

#Setting the field separator back to normal before exiting
IFS=$OLDIFS
} ;

Feed Combining: Yahoo Pipes / RSS In Page

On Tina’s old blog, which is still online but not updated since she moved to WordPress, there is a blog roll on her sidebar which shows her blogs in order of most recent update. I can’t find anything that works as well for WordPress. There are various feed combiners for WordPress, but all that I found leave out the name of the blog that the item comes from. And I wanted that to be included.

The best way I found was to use Yahoo Pipes, an online feed combiner from Yahoo. I use the RSS output from Pipes as the source for WordPress’s standard RSS module. Pipes is difficult to understand at first, but it has a video tutorial that should be enough to get a novice started. More advanced operations, like what I’m about to describe, are for people who are more experienced with internet applications.

What I like best about Pipes is the Regex module, which allows me to alter the feed of each item before it gets combined with other feeds. I use the Regex module to put an identifier in the title of each item.

The Feed module gets piped to the Regex module. In the Regex module I select item.title, and replace ^ with the name I want to use followed by a colon and a space. So “The Apocalypse Trade” becomes “Krugman: The Apocalypse Trade”. (^ is Regular Expression syntax for the beginning of a string).

I pipe all of the Regex-modified feeds into a Union module, then pipe the Union module into a Sort module. Finally, the sort gets piped to the Pipe Output. An example of the output is in my main blog.

Yahoo Pipes Editor

To get the RSS feed, I click “Back to My Pipes” and select the pipe I want, then click “View Results”, then “Get as RSS”.

The Regex module has much more capabilities than what I’m using it for and Pipes has more modules than I’ve explored.

Gigaom has a more in depth article.

The interface is a little hard to get use to and Yahoo Pipes intermittently fails to retrieve a feed, but it’s power and versatility make up for any shortcomings.

For a tool that works in wordpress.org and doesn’t require an external combiner, use Rss in page. RSS in Page does not provide a new feed, but it will embed the output of a combined feed into a page or text widget. There’s no graphical interface but if you’re familiar with using shortcodes and can learn some simple formatting commands it’s very versatile.

Installing Ubuntu 11.10 (Oneiric Ocelot)… All I had to do was check the friggen box!

Installing 11.10 from scratch (erasing the hard drive) on a Dell Inspiron e1505 with Broadcom wireless card … When you see the checkbox about installing third party software, go ahead and put a check in it. You won’t get a chance to install the Broadcom driver later.

Using software-center or the command line, everything I tried resulted in some kind of error. The “Additional Drivers” icon, which is a front end for jockey, showed the drivers that needed to be installed but failed at every attempt to install them. Jockey-text, from the command line, also failed.

It seems to be a problem reading the installation disk post-installation, even with the disk included in the sources list. And of course I had to use the disk because I couldn’t get on line. I haven’t figured it all out and probably won’t.

When I re-installed from scratch, with the 3rd party box checked, the appropriate Broadcom drivers where installed and the system is, so far, working fine.

An improvement, and another use for the safetags function

A while ago I wrote a function which checks HTML snippets and ensures that tags which should be closed are removed unless they are actually closed. For example, if user types

<div style="whatever">Blah Blah

and forgets to close the div tag, then that div tag will be removed. Sure it would be better if the div tag was fixed, but that requires more code. This is good enough for me.

Another use for this function is excerpts. An original article may have all the tags properly closed but the excerpt might have an opening tag with it’s matching tag cut off.

A copy of the function is here.

It is not a validator. It ignores tags like p and br which will work even if not coded properly. You can edit the function to change which tags are allowed.

I used the function to alter Virginia CURE’s website from the original cover-wp theme. For comparison, I found a couple of other websites which use cover-wp: NELA Lives, Hedge Futures, and Marco Luthe. I’m not familiar with these websites, I just looked for websites that use the cover-wp theme. Eventually, any of these websites might disappear, or any of them might change themes, including Virginia CURE. But as I’m writing this they’re good examples. Virginia CURE’s excepts have the paragraphs preserved, the others don’t. The cover-wp theme uses a customized get_the_excerpt function, which in turn calls the built-in php function striptags to remove all of the tags.

Here’s copy of functions.php which I altered from cover-wp. I renamed it functions.txt so it can be viewed. I also made a small change to get_the_excerpt.

If anyone who reads this knows of a better function then I’d be interested. I’m just an amateur hack. But for now, my function works better than anything I found.

I fixed a couple of problems since I first posted it.

Passing by Value or Reference

I’m a function, perhaps I’m main(). I have an integer named Nicky, which has a value of 4. I want that value doubled, and there’s a couple of ways I can have it done. I could just do it myself, but that’s too much work, so I’m going to call a function.

By Value

One way is to use a by-value function that will do the math for me:

“Dubvee, speaking, what’s the value?”

I tell it “4”. It has its own integer, which it calls it Narco. Narco takes on the value that I passed, so now Narco equals 4, just like Nicky. It doesn’t really matter to me what the function calls its own integer. It could have called it Nicky, too. I never see Narco, and Dubvee never sees Nicky. “Ok,” it says “I’ll get right back to you.”

Dubvee is a value returning function which takes its variable by value. This is how Dubvee would be declared in C++:

int Dubvee (int Narco);

And this is how Dubvee might be defined:


int Dubvee (int Narco) {  
	Narco = Narco * 2;
	return Narco;
}

Dubvee does the math, calls me back, and says, “8”.

There’s a couple of things I can do with this 8. I could just say it out loud and forget about it. I could get another variable and assign it the value of 8, or I could assign Nicky the value of 8. Those three options are illustrated below in C++ syntax:


cout << Dubvee(Nicky) << endl;    //I print the value of Nicky doubled, but I never store it
Mike=Dubvee(Nicky);                //I assign Mike the value of Nicky doubled
Nicky=Dubvee(Nicky);               //I double Nicky directly

By Reference.

Let’s say I don’t want to tell the function Nicky’s value. I want the function itself to find Nicky. Instead of telling Nicky’s value, I tell the function where Nicky is. I want a call by reference function.

“Dubre speaking, where’s your integer?” I give Dubre a number which represents Nicky’s location. For this blog post, we’ll call it Nicky’s address. Technically that’s not true, but it’s a good enough explanation. Dubre finds Nicky, using the address, and doubles it. Now Nicky equals 8. Dubre never told me “8”, it just did the work and left. Dubre would be declared as follows:


void Dubre(int & Naria);

and defined as follows:


void Dubre(int & Naria) {
     Naria=Naria*2;
}

The ‘&’ symbol means that the function expects an address of an integer, not the value of that integer. Since Dubre doesn’t pass anything back to me, it’s declared with void, and there’s no return statement.

Similar to Dubvee, Dubre doesn’t need to use the same name that I use. The difference is, even though Dubre is using the name Naria, it’s refering directly to Nicky. Naria and Nicky are two names for the same integer.

This is how I double Nicky using Dubre:

Dubre ( Nicky); 

Note the “&” symbol in the declaration and definition is not used in the call.

Dubvee is a void function, AKA a procedure, which takes its parameter by reference. Since there’s no return value, I can’t make an assignment like “Nicky=Dubre ( Nicky );” or “cout << Dubre (Nicky);".

What may be confusing at this point is, even though I passed an address, the name Naria refers to the variable at that location. So if Dubre doubled Naria with "Naria = Naria * 2;", it's doubled Nicky, not Nicky's location. In C++, that rule applies to function parameters. If you see the "&" symbol used differently, then different rules apply.

A function that uses reference parameters can return a value, and a function that uses value parameters doesn’t have to.

When I pass by value, my original variable is never touched by the function. It gets the value of the variable and makes a copy. Because it never gets the original variable. It's usually not the most efficient way but it's easier and safer to code functions that take parameters by value.

When I pass by reference, I'm giving the function direct access to the variable. This can be dangerous, but it's more efficient because they don't have to make a copy of the variable. Remember, variables aren't always integers; they can be very large and complex.

Combining feeds

A friend suggested I combine my schizophrenic group of blogs into a single blog. I’m not ready to do that but I did decide to display a feed from all my blogs on a single page. Easy enough, but I wanted to combine them all and sort them by date, rather than have a separate feed for each. I found a simple feed puller in a book called Plug-In PHP, by Robin Nixon. From that I modified and expanded the code to allow combining different feeds into one. Also, the books code worked for my wordpress blogs, but then I also wanted to make another feed which included blogs that I read, and my daughter users blogger. I had to write new code to accept her feed. I don’t know if this takes all kinds of feeds, but it does what I’ve needed it to do so far.

<?php
//Sort posts by publication date
function sortpdate ($a, $b) {
 $adate=strtotime($a[‘pubdate’]);
 $bdate=strtotime($b[‘pubdate’]);
 if ($adate == $bdate) { return 0;}
 return ($adate < $bdate) ? 1 : -1;
}

function RSStoHTML ($urllist, $usortfunction, $fullposts=3, $maxposts=12, $titletag=”h4″, $classprefix=””) {
//Takes blog posts from multiple blogs using a comma separated list of feeds, usorts them, and echos them
 

 $urls=explode(‘,’, $urllist);
 $i=0;

 $showitems=array();

 foreach ($urls AS $url) {
  
  $rss=file_get_contents($url);
  $xml = simplexml_load_string($rss);

  //The two foreach loops that follow pickup wordpress and blogger
  //I don’t know yet if these fail on other types of feeds.
  foreach($xml->channel->item as $item) {
   $i++;
   $showitems[$i][‘blogtitle’]=@$xml->channel->title;
   $showitems[$i][‘bloglink’]=@$xml->channel->link;
   $showitems[$i][‘blogdescription’]=@$xml->channel->description;
   $showitems[$i][‘itemlink’] = @$item->link;
   $showitems[$i][‘pubdate’] = @$item->pubDate;
   $showitems[$i][‘itemtitle’] = @$item->title;
   $showitems[$i][‘summary’] = @$item->description;
   $showitems[$i][‘content’] = @$item->children(“content”, true)->encoded;
  }
  foreach($xml->entry as $item) {
   $i++;
   $showitems[$i][‘blogtitle’]=@$xml->title;
   foreach (@$xml->children()->link AS $child ) {
    if($child->attributes()->rel==’alternate’) {
     $showitems[$i][‘bloglink’]=$child->attributes()->href;
    }
   }
   $showitems[$i][‘blogdescription’]=@$xml->subtitle;
   foreach (@$item->children()->link AS $child ) {
    if($child->attributes()->rel==’alternate’) {
     $showitems[$i][‘itemlink’]=$child->attributes()->href;
    }
   }
   $showitems[$i][‘pubdate’] = @$item->published;
   $showitems[$i][‘itemtitle’] = @$item->title;
   $showitems[$i][‘summary’] = substr ( @$item->content , 0, 30 );
   $showitems[$i][‘content’] = @$item->content;
  }
 }
 usort($showitems, $usortfunction);
 $out=””;
 $i=0;
 while ($i < sizeof($showitems) && $i < $maxposts) {
  if($i<$fullposts) {
   echo ‘<‘, $titletag, ‘ class=”‘, $classprefix, ‘itemtitle”><a href=”‘, $showitems[$i][‘itemlink’], ‘”>’, $showitems[$i][‘itemtitle’], ‘</a></’, $titletag, ‘><p class=”‘, $classprefix, ‘pubdate”>’, (date(‘l, Y F d’, strtotime($showitems[$i][‘pubdate’]))), ‘ in <a href=”‘, $showitems[$i][‘bloglink’], ‘”>’, $showitems[$i][‘blogtitle’]>”” ? $showitems[$i][‘blogtitle’] : $showitems[$i][‘bloglink’], ‘</a></p><p class=”‘, $classprefix, ‘summary”>’, $showitems[$i][‘content’], ‘</p>’;
  } else {
   echo ‘<‘, $titletag, ‘ class=”‘, $classprefix, ‘itemtitle”><a href=”‘, $showitems[$i][‘itemlink’], ‘”>’, $showitems[$i][‘itemtitle’], ‘</a></’, $titletag, ‘><p class=”‘, $classprefix, ‘pubdate”>’, (date(‘l, Y F d’, strtotime($showitems[$i][‘pubdate’]))), ‘ in <a href=”‘, $showitems[$i][‘bloglink’], ‘”>’, $showitems[$i][‘blogtitle’]>”” ? $showitems[$i][‘blogtitle’] : $showitems[$i][‘bloglink’], ‘</a></p><p class=”‘, $classprefix, ‘summary”>’, $showitems[$i][‘summary’], ‘</p>’;
  }
  $i++;
 }

 echo $out;
}

$urls=”https://bnmng.wordpress.com/feed,http://bnmngfarming.wordpress.com/feed,http://bnmngcomputing.wordpress.com/feed,http://healthyinsuffolk.wordpress.com,http://sashabyproxy.wordpress.com&#8221;;
RSStoHTML ($urls, ‘sortpdate’);

I Don’t Get Facebook or Myspace

I have to admit that I don’t understand why Facebook and Myspace are so popular. For a couple of months, I was addicted to Facebook, but it wore off. I never liked Myspace. It’s strange how they’re basically the same thing but so different. Anyway, I don’t get why so many people are so devoted. If you want to share your thoughts with the world, why not start a blog? If you want to play a game, you can join one of the many gaming sites for games that are worlds better than anything on Facebook. You can send messages by email and chat with messaging systems. Social networking sites are like internets within the internet, and offer basically the same services that can be found outside, except you have to do everything through a clunky interface. The only thing that they seem to offer is the ability to say to some people ,”you’re my friend” and by default, saying to everyone else, “you’re not my friend”. So is that it? Is petulant schoolyard politics what makes these social networking sites so popular?

A variation of joomlart’s ja_purity template with resizable header and horizontal submenu

Update 2010 July 6: I’m still getting a few hits on this and I apologize to everyone who may have gotten headaches trying to make this work. This procedure provided a good solution for me at the time but there are much easier ways to achieve the dropdown menu, which can be found in the joomla documentation.

All below is from the original post.

I made a template which is basically a copy of ja_purity with a modified header and support for the submenu which I described in earlier posts. I’m still new at this so I’m sure there will be some problems and I want to hear about them so, please tell me.

Download bnmng_ja_purity_1_0.zip

In addition to standard ja_purity features:
Header images can be of a different size than the original images.
Entire header can be resized to match taller or shorter header images.
Mask can turned on or off on left and right side independently.
Logo text can be displayed with logo image.
Horizontal Submenu’s can be added by creating the menus. You don’t have to alter the index or css.

Notes:
I removed some of the choices for the template width.
You should know the height and width of your header and logo images

To install, put the bnmng_ja_purity folder in your templates directory, than put the language files (not the folders that they are in) in the appropriate folder. The name of the folder that the zipped language files are in tells you where they should go.

To create horizontal submenus, create a new Joomla menu to represent each submenu. Using module manager, set the position of each horizontal submenu to “subhornav” and set the menu assignment for each to display when the appropriate menu item from the parent horizontal menu is selected. Remember that the horizontal submenus are actually individual menus.

The ja_purity template on which I based my version was made by joomlart.