≡ Menu

Courses for Summer Learning

Two courses that have recently been made available (though I haven’t yet had the opportunity to take) at Code School are Powering Up With React (for React) and an HTML/CSS class called The Elements of Web Design.

Summertime – which is rapidly approaching – is a good time to commit to spending time picking up new skills and refreshing old ones. I have little experience with React, so this presents an excellent opportunity to see what capabilities are made available there.

learning new things

Whether you choose to take the above courses, or look elsewhere for learning, commit to spending a little time each day studying to pick up new skills – it may not sound like much effort to spend toward a large task, but the results could surprise you!

While I think the venerable Ruby on Rails Tutorial is still the best way to learn Rails, jumping into this tutorial can be challenging for those who are new to programming.

With the fourth and latest beta of Rails 5 being released this past week, it is appropriate that Michael Hartl, the creator of the Rails Tutorial, has devised yet another tool to help new and experienced developers learn enough to make the most of it.

Appropriately, the title of this site is “Learn Enough to Be Dangerous”.

current courses at Learn Enough to be Dangerous

As of the end of April 2016, only three “Learn Enough” courses are available: Command Line, Text Editor, and Git. However, future courses including HTML, CSS & Layout, JavaScript, Ruby, Sinatra, and the Ruby on Rails Tutorial for Rails 5 are scheduled to be added.

The cost is $29 per month, the same as Code School (if you subscribe on a per-month basis to CS). Unlike CS, there is not yet a discounted yearly rate.

Since I’m excited to see the new Rails Tutorial as soon as it’s released, I’ve decided to sign up. Were it not for the access to this mammoth resource, I don’t know that I would pay this price – but considering that the Rails Tutorial with screencasts generally costs about $150 by itself, it seems like a reasonable deal. At any rate, I’ve come to expect only the highest quality learning materials from Dr. Hartl, so I am definitely looking forward to the upcoming classes.

Changes in the ColdFusion.window.create Function Require a Modern Browser

I’m still working on upgrading some older CF8 applications to CF11. I came across an interesting problem, the exact cause of which I have not found, but I do have a solution of sorts.

When the particular application I’m working on now was written, the standard browser that would be accessing it was Internet Explorer 8. Over time, as we have upgraded our browsers, but not had time to make changes to the application to accommodate those new browsers, we had used the dreaded Compatibility View to keep the look and feel of the application unchanged.

Since we are now several versions out from CF8, it is understandable that some things intrinsic to ColdFusion have changed. Somehow, the way that the function ColdFusion.window.create renders JavaScript to create the pop-up window does not work with IE 8 or a newer browser emulating IE 8 (as we forced with the X-UA-Compatible HTTP header in IIS). After copying the website to the CF11 server, setting up everything in IIS, and navigating to the website, everything was great until I clicked on a link that executed a function (named “createCFWindow”, as in the dialog box below) that called the ColdFusion.window.create function.

This is the result:

error dialog box

After stepping through the code using Internet Explorer’s Developer Tools, I determined that the reason this “createCFWindow” function threw an exception was because the ColdFusion.window.create function was returning null rather than a new window.

When testing the website on Chrome – which this application was not designed to use – I discovered that the error did not occur, and decided to turn off Compatibility View. Sure enough, this error disappeared in IE 11 – though a host of other issues have now developed.

Now, I’m working to upgrade the application to be HTML5-compliant so it will work on IE 11 or Chrome.

Apparently, using CF UI tags became unfashionable quite some time ago, but that type of advice isn’t always heard or heeded until long after it’s announced.

Any future applications I build will use jQuery instead for this sort of thing.

Using Ruby to Get All Links from a Sitemap XML File

I was looking at the cached pages on the Wayback Machine and decided to find out if that site had an API. (It does.) I wanted to find a way to use this API to submit links to the Wayback Machine database. As it turns out, a Ruby gem called WaybackArchiver has already been written for just this purpose!

Now that I had an easy way to submit multiple URLs, I got to thinking about how this could be more easily automated. What if I had a sitemap that contained all of the links I wanted to submit? What if there is already a gem to parse a sitemaps.org-compliant sitemap, such as the one on WordPress sites that use the Google Sitemap Generator Plugin?

a sitemap.xml file

My WordPress sitemap, generated by the Google Sitemap Generator Plugin

Even though all of these things exist, I have not found where they have been combined, so I did just that. The Ruby script I wrote requires several gems:
1. WaybackArchiver, for submitting links, sitemaps, or pages to the Wayback Machine
2. Sitemap-Parser, for parsing sitemaps
3. OpenURI, for opening websites
4. Nokogiri, for parsing XML (also HTML, SAX, and Reader) files

If these gems are not installed already, you can install them at the Ruby prompt with “gem install” and the name of each gem.

The script, which I named map.rb, is below.

require 'wayback_archiver'
require 'sitemap-parser'
require 'open-uri'
require 'nokogiri'

mainSitemapURL = ARGV[0]
if not mainSitemapURL.nil?
  puts 'Running...' #+ mainSitemapURL
  #mainSitemap = SitemapParser.new mainSitemapURL
  mainSitemap = Nokogiri::HTML(open(mainSitemapURL))
  #puts mainSitemap
  mainSitemap.xpath("//sitemap/loc").each do |node|
    #puts node.content
    subSitemapURL = node.content
    subSitemap = SitemapParser.new subSitemapURL
    arraySubSitemap = subSitemap.to_a
    (0..arraySubSitemap.length-1).each do |j|
      #puts arraySubSitemap[j]
      WaybackArchiver.archive(arraySubSitemap[j], :url)
puts 'Finished.'

This script works unaltered with WordPress sitemaps created by the plugin mentioned above. These sitemaps actually produce a sitemap index, with individual sitemaps being linked here – so each of the linked sitemaps are also parsed. The above script can be run at the Ruby prompt with “ruby map.rb URL“, substituting the URL for the sitemap.

Should your sitemap be organized differently, this code may not work as-is, but may require changes depending on the node tag names.

Other pages that were helpful in developing this tool:
Looping through each xml node (on Stack Overflow)
Web Scraping with Ruby and Nokogiri for Beginners
Parsing an HTML/XML Document

Some Good Resources on Database Performance Optimization and Tuning

Database performance optimization is a skill that is very important for both the database administrator and the database developer. I decided to put together a few links here that may be useful in disseminating information about database tuning and query optimization on various database systems, both relational and non-relational. I’ll be updating this from time to time as I come across new resources.

Microsoft SQL Server:

Optimizing Databases
SQL Database Performance Tuning for Developers

Oracle Database:

Database SQL Tuning Guide


Tuning Your PostgreSQL Server


How to optimize a MySQL database


Optimization Strategies for MongoDB

database symbol