Technology Errors

json/common.rb:122:in `parse’: 574: unexpected token at ” (JSON::ParserError)

I have been writing some scripts in ruby to parse JSON generated data. To do this it requires the json ruby gem which works great to parse through JSON output. Anyhow I was loading files into ruby and parsing them without issue until i got to a larger file and I received the below error.

Error:
/usr/local/lib/ruby/gems/1.8/gems/json-1.1.3/lib/json/common.rb:122:in `parse’: 574: unexpected token at ” (JSON::ParserError)
from /usr/local/lib/ruby/gems/1.8/gems/json-1.1.3/lib/json/common.rb:122:in `parse’
from tickets.rb:13
from tickets.rb:11:in `open’
from tickets.rb:11

Details
Technology Insights

Use vi To Find And Replace Content While Breaking a Line

The power of the Unix command vi never ceases to amaze me. I have known how to search and replace easily using vi for a long time however I didn’t know how to find and replace plus insert a line break during the replace. After toying around with vi for awhile I was able to figure it out. The example below shows how to find and replace certain text while inserting a line break.

Contents of a File:

sql

  1. (1,2,'title one','2009-04-20 17:55:46','description one'),(2,2,'title two','2009-04-20 18:05:54','description two'),(3,2,'title three','2009-04-20 18:23:10','description three'),(4,2,'title four','2009-04-20 19:33:42','description four'),(5,2,'title five','2009-04-20 19:45:34','description five')
Details
Code Snippets

Add Google Content Ads Between Your WordPress Search Results

I have been thinking about the best way to display ads on my WordPress blog search results for a long time because there are numerous options. You could just display content ads at the top, bottom, or both locations, you could add a WordPress plugin, or you could create a custom page with Google custom search results geared for your page. I played around with the latter two options but wasn’t happy with eaither result. One of the ways to do the Google custom search results is using an iFrame and iFrames suck. Anyway I decided to add some custom PHP code to display the ads however I ran into a problem quickly which was the fact that you can only display 3 of the same ad on any one page so if you want to display ads in between each search result it would get a bit more tricky.

Details
Technology Insights

Create a WordPress Template to List All Tags on a Single Page: wp_tag_cloud

Previously I created an article about listing all WordPress tags on a single page however some things have changed since that time. When going back and looking at the article it looks like some of the tags have changed since that time. I do have a WordPress plugin installed called Simple Tags so take that into account when using the below directions. This plugin is recommended to provide you more control over your tags. The easiest way to display all tags is to create a blank WP page and assign a template to it that specifically lists all tags. Follow the below instructions and you will have a page listing all of your tags in no time at all.

  1. Add a Template Page:Add a new page called tag-cloud.php to your server in the theme directory of your WordPress installation. The location of the new file will be wordpress-root/wp-content/themes/theme-name/. You can copy the contents of the page.php file from the default theme or your theme and then make the following two modifications.
Details
Technology Errors

PostgreSQL SkyTools walmgr: CDTWARNING: archive_mode enabled, yet archive_command is not set

If you are running walmgr for log shipping with PostgreSQL and you see the below error in your postgresql.log file it is because you are missing the recovery.conf file. The recovery.conf file should be located in your data directory on the slave server which typically is /var/lib/pgsql/data.

Error:
CDTWARNING: archive_mode enabled, yet archive_command is not set

This means you probably have not run the below command as the postgres user on the slave server which is the command that actually generates the recovery.conf file.

Details