Monday, November 12, 2012

After Oil - I'm published!


About a year ago, John Michael Greer, author of the Archdruid Report, challenged his readers to submit short stories envisioning life after the end of cheap petroleum, without descending into Mad Max apocalypse, nor relying on rescue by "alien space-bats."

My short story "Traveling Show" was among the twelve that John selected, and I'm happy to report that the book is now in publication and available from Amazon in Kindle, Nook, Smashwords and good old dead trees formats.

Many thanks to John for inspiring me to write a story, and to my fellow authors, without whom the book would not have been possible. Together we might part the mists to the kind of future where we'd like our children and descendants to live.

Tuesday, August 28, 2012

A Roadmap for Learning Web Development

Damien Roche gave some excellent advice (IMHO) to the question, "Which language to learn for Web Development Ruby or Javascript?". His last comment is the most critical: "If you don't enjoy learning new things, you're in the wrong game."

You know some Ruby, start there. Using RoR will have a positive impact on your ability to develop web applications. Although stuff like Compass, SCSS, Coffeescript isn't required, I'd certainly advise you delve into them once you're familiar with the underlying languages.

A good roadmap would be:
  • HTML, HTML5
  • CSS, CSS3
  • Javascript, jQuery
  • Ruby, Rails
  • SQL
Once you are familiar with the above, and if you plan to use RoR, these are essential:
  • RVM
  • Bundler
  • Capistrano
  • Rails console
Along with that, you will most definitely want to be able to use:
  • IDE - Eclipse, Rubymine
  • Git
  • Linux
A web developer who primarily works with Rails and Linux will have been exposed to and know (some more than others) all of the above. It is absolutely critical that you understand how these technologies compliment each other. 1,2,3 are evergreen - they will never 'go out of fashion'. So start there.

Once you've done all that, you might want to move up to the next level and learn:
  • HTML -> Haml or Slim
  • CSS -> SCSS and Compass
  • Javascript -> Coffeescript
  • Rspec and Cucumber
As you can see, there are tonnes of different tools at your fingertips. One skill which surpasses all others: the ability and enthusiasm to educate yourself. If you don't enjoy learning new things, you're in the wrong game.

Friday, August 3, 2012

apt-cyg: command line installer for Cygwin

apt-cyg  is a command-line installer for Cygwin which cooperates with Cygwin Setup and uses the same repository. The syntax is similar to apt-get.

Update Ruby from source for Cygwin

Edit: Added LibYAML and OpenSSL extension instructions from http://saltnlight5.blogspot.ca/2011/11/i-like-to-use-ruby-that-comes-with.html

Make sure Cygwin OpenSSL packages are installed.

Run Cygwin console as Administrator if using Windows 7, Cygwin was installed as Administrator and UAC is enabled, install may need admin permissions and Cygwin doesn't have a "sudo" command.

If you get fork errors, try rebasing Cygwin.

If rebasing fails, try deleting C:\cygwin\etc\rebase.*

http://permalink.gmane.org/gmane.os.cygwin/135305

> $ /bin/rebaseall
> /usr/lib/perl5/5.14/i686-cygwin-threads-64int/CORE/cygperl5_14_2.dll: skipped because nonexistent.

And this is caused by a minor perl packaging problem. You can simply
ignore this warning.
I'll fix it with the next perl update.
--



$ ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [i386-cygwin]
$ cd /tmp
$ wget http://pyyaml.org/wiki/LibYAML
$ tar xvf yaml-0.1.4.tar.gz
$ cd yaml-0.1.4/
$ ./configure && make && make install
$ wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz
$ tar xvf ruby-1.9.3-p392.tar.gz
$ cd ruby-1.9.3-p392.tar.gz/ext/openssl
$ ruby extconf.rb
$ make && make install
$ cd ruby-1.9.3-p392/
$ ./configure && make && make install
$ wget http://production.cf.rubygems.org/rubygems/rubygems-2.0.3.tgz
$ ruby -v
ruby 1.9.3p392 (2013-02-22 revision 39386) [i386-cygwin]







Saturday, July 14, 2012

Finished Rails Tutorial, but I'm still hungry!

Power House below the San Francisco Cable Car Museum - courtesy Christian Mehlführer
After 3 months of part-time slogging I've made it to the end of Michael Hartl's excellent (and free!) Ruby on Rails Tutorial. I really appreciated Hartl's inclusion of the whole Rails workflow, from installation and config, through TDD (test-driven design) and BDD (behaviour-driven design) with RSpec, Capybara and Cucumber, source control with git on Github, and a taste of CSS and Ajax, to actual deployment on Heroku. In fact, you can see the results of all this work at https://furious-cloud-4562.herokuapp.com/.

Along the way I learned a lot, with some side trips into setting up a development environment and finally coming to grips with Vim. It was a bit like I imagine driving a San Francisco cable car - I got where I was going, over lots of hills and curves, in relative ease and comfort, by pulling a few levers (typing in code) at the right time and watching the results roll by. 

But I could tell there was something "under the street" pulling me along, like the power house under the San Francisco Cable Car Museum - lots of big machinery, moving fast, with cables and gears disappearing into dark, unexplained tunnels. I think the next step, now that I've had a ride around on the Rails car, is to step down into the motor room, with conductor David A. Black's book in hand, to get a better understanding of the Ruby engine that drives everything. 

I found the end-of-chapter exercises a bit daunting, especially without an answer key to check against once I'd make my best attempt at it. I found some answers, often for older versions of the tutorial, on StackOverflow and the now-unsupported Get Satisfaction support site for the Rails tutorial.

I really like the BDD testing approach, and I'd like to delve into that next, but I haven't found much online beyond the RSpec documentation (which appears to be generated by rspec tests), a new "gamified" RSpec tutorial at Code School that I haven't tried yet (opinions, anyone?), and a now outdated book from the usually excellent Pragmatic Programmers. Again, I am loathe to spend time and money on a book that was published more than 2 years ago, given the rapid velocity of code changes to the Rails ecosystem. 

Tuesday, June 26, 2012

Online Coding and CS courses

In a comparison of seven (eight, actually) of the current crop of online dev schools, Chris McConnell at DailyTeckk notes the topics available for study (Web dev, programming), languages used (mostly Python and JavaScript) and costs (free to monthly subscription):
Two more notable sites I've found:
Edit: Steampunk Nancy Wu notes a couple of other sites in her survey of the online learning landscape:
If you've come across any other high-quality online learning sites, that you've personally tried and want to recommend, leave a comment here!

Wednesday, May 30, 2012

Friday, May 25, 2012

Ruby one-liner: rename files

I wanted to strip a 20-character prefix, starting with the characters "IP_", from from a dozen XML files in a directory. Each file has a value of a different length following the prefix, e.g. "IP_stuff_foo.xml", "IP_stuff_bargain.xml", etc. I could probably do this by hand, or with a Windows batch file, but seeing as I'm learning Ruby (again), I thought I'd try to get it down as a Ruby one-liner, and here it is:

ruby -e 'Dir.glob("IP*.xml").each { |f| File.rename(f,f[24..-1]) }'
  • ruby -e calls Ruby to -"e"xecute the code in single quotes
  • Dir.glob("IP*").each finds all files in the current working directory that start with the string "IP". The glob() method returns an Array object, e.g. ["IP_foo.xml", "IP_bargain.xml", etc.], so the Array each() method returns "each" element in turn.
  • Each file name is passed in turn into the variable f in the block { ... }, where the File.rename() method does its magic.
  • File.rename takes two parameters, the name of the file to be renamed, and the new name for the file.
  • The new file name is a substring of the characters following the 20 character prefix. The substring is created by returning the remainder of the string after counting backwards, "-1", for "20" characters, f[20..-1].
  • Once File.rename() gets the substringed value, it renames the file.



Monday, May 21, 2012

tmux for Ruby on Rails

A couple of weeks ago I stumbled on tmux as a way to manage the proliferation of terminal windows when doing Ruby on Rails development.

My Rails 3.2 development environment is a Ubuntu guest OS running on a VirtualBox VM hosted on my Windows 7 desktop. Since I wanted to stay on my Windows desktop most of the time, rather than interact with Ubuntu through the somewhat laggy Virtualbox display, I would ssh into the Ubuntu guest using a Cygwin terminal (mintty). And being a good ol' Rails fanboy, I started using Vim and all its plugins as a really nice Rails/Ruby editor.

However: once I got a couple of Vim editors, a rails server, a rails console, a log file tail, and a Guard or RSpec session all running at once, plus the Ruby on Rails tutorial and Rails app open in browser windows, my Windows desktop started to look like Mah Jongg game in full swing. I was spending more time tabbing around looking for the right window than actually learning anything!

Tmux brings some order to that chaos. According to the tmux man page, "tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen." After some tweaking and fiddling, this is the layout I've settled on:


I've split a single "window" named "rails" into to three "panes": top-left I have Guard running Rspec tests, bottom-left I have the Rails server, and at right my main Vim editing session. On a second window named "logs" I have a tail on the Rails server log file.

The cool thing about this is that it all starts up automatically when I run a shell script that instructs tmux to set up the windows and start all of the processes I need for my Rails development session. Tmux will even maintain the session in case my terminal connection dies.

I relied on these excellent introductions to TMUX to get started:
Here's the shell script I cobbled together to create that session:



And my .tmux.conf file:



Thursday, May 17, 2012

Wikipedia on my iPad Sucks!


I love Wikipedia.

What's not to love about the universal reference, all 3,952,630 pages kept up-to-date by an 85,000-strong army of contributors, who do it all for love, that's available online, from anywhere, including my iPad, even offline, thanks to the All of Wiki app that lets me carry the whole 4.73 Gbytes of it around with me whereever I go, so that if I, as an ignoramus Canuck, riding to work on the bus without a handy WiFi connection, get the hankering to know just who played Zaphod Beeblebrox in the original BBC radio broadcast of the Hitchhiker's Guide to the Galaxy, well, heck, I can just pop open All of Wiki and discover it was the aptly-named Mark Wing-Davey, who also played Zaphod in the TV series... in fact, with the addition of perhaps a towel, I would be perfectly equipped to face the Vogons with my Wikipedia-enabled iPad.

Besides, I don't think Vogon ships are equipped with 802.11n WiFi, so that's perfect.

The iPad is pretty much how I envisioned the Hitchhiker's Guide when I first read Douglas Adam's opus many years ago. So if I love Wikipedia so much, why do I say it sucks? Here's what the desktop version looks like on my iPad:

I don't know about you, but i find it hard to read 6-point type on an iPad. Granted it's a now-ancient iPad Mark I, but i don't think the whiz-bang Retina display would make much difference, it's still tiny type.

Let's try the two finger splits and zoom in:


Terrific, the type's bigger now, but it didn't reflow to fit the screen. Okay, you say, switch to the mobile version:

Big improvement, now I see tiny type one block at a time, and it still doesn't reflow when I zoom in.

C'mon, Wiki guys 'n gals, this is the Age of Mobile, I know you've heard about responsive web design (it's right here). Let a thousand screens bloom! You've recorded all that's vital to human knowledge, surely you can make it comfortable to read on my iPad, and Nokia N8, as well as my desktop?

Keep up the great work, though, we do love ya.

Wednesday, May 16, 2012

Lather. Rant. Repent. Love it!

Eric Lloyd (where are you?) summed up the link between code cruft and developer turnover in his comment on the thread Is 4-5 years the “Midlife Crisis” for a programming career? - Programmers

"Lather. Rant. Repent."

How many organizations get this? How many can see past the sunk cost of ancient code and infrastructure to realize when it's time to update?

'via Blog this'

Monday, May 14, 2012

Windows batch: echo without new line

Two ways to use set with /p to 'echo' without a new line:

echo|set /p=.


<nul set /p=.

Both examples rely on the set command's behaviour when given the '/p' switch. The '/p' switch turns 'set' into a prompt for input. Usually, this would be employed to solicit interactive input from the user. The value entered at the prompt can be stored in a variable, e.g. 'set /p armageddon=Push Big Red Button?', where the variable 'armageddon' is set to the user's response to the prompt question.

The first example works by having 'set /p=.' output the '.', then get a response from the output of  an empty 'echo' statement piped into the command. The response from echo is discarded, because there is no variable defined for the '=' in the 'set' statement. The second example works by redirecting the 'nul' device into the 'set' statement.

Each time the statement is executed, another dot is output on the same line. This technique could be used to make a progress bar in a batch file, e.g. each time through a 'for /f' loop.

The statement could also be wrapped in an if-else block to flag errors, e.g.

if %foo% equ 1 (
    <nul set /p=.
) else (
    <nul set /p=F
)

The output is a series of dots for success, with F's marking failures:
....F...F.

Big thanks to arnep for this elegant solution.

'via Blog this'

Wednesday, May 9, 2012

Ruby 1.9.2 load path update

I encountered an odd error when I changed the "load" statement to "require" in section 1.3.3 on page 19 of David Black's book The Well Grounded Rubyist.

As of Ruby 1.9.2, the current directory, ".", was removed from the load path for security reasons. The load path is stored in the global variable "$:", which you can display by running the command 'ruby -e puts $:'

The effect of this change means the step on page 19, changing load "loadee.rb" to require "load" will fail with an error:

'require': cannot load such file -- loadee (LoadError)

The solution is to either add the current directory, './loadee', or use require_relative 'loadee'. I hope this helps anyone else who puzzled over that error.

Thursday, May 3, 2012

DRY is for software, not for humans


Right now I'm stepping through a manual testing procedure provided as a PDF document, using Acrobat Standard to make comments (It's the process, don't ask why).

The fun part is stamping each step with the big green checkmark or the big red "X" as I complete each step.

I'm on step 368. In the interest of saving a few keystrokes/bytes/pages, Step 368 tells me to "Repeat steps 132 through 138." Step 368 also tells me what values to use for this section instead of the values that were used in steps 132 through 138.

Great, I have to split the screen (took a while to find that command, why can't I just double-click a toggle on the pane containing the page?), then scroll the top half back to find step 138, then mentally substitute the new values for the old ones, while eyeballing the HMI to make sure I'm clicking the right buttons and fields.

This is DRY for humans. I think Don't Repeat Yourself is great for software. Who wants to chase around through sixteen different configuration files or print statements to change a value? But humans benefit from repetition, especially in a tedious list of test steps.

Yes, we use automated testing on the application level. This is more functional testing - do the right values show in the right fields (are the fields even there to begin with?), can I click a button, does the right thing happen... stuff that's tricky to automate and stuff that automation might not catch. When I have to stop the flow, scroll up through screen after screen of identical-looking steps, find the old steps, substitute the new values, make sure I don't lose my place, well, it's no wonder I go off and rant about it.

Now the troubling thing is, the test procedure document was generated by an application that sucks in XML data files that spell out the content of each step, then spits out the PDF all nicely formatted and tabulated.

For the sake of exercising a few more CPU cycles, the scripts could include the repeated steps from a template, substituting in the new values, thus saving my limited brain cycles for understanding why the HMI doesn't match up to the values in the steps. Or something more important.

Friday, April 27, 2012

Where is my Cygwin whereis?

THE useful whereis command was AWOL from my most recent Cygwin install. As blog.arithm mentions you can this and many more Unix-y commands from the util-linux package, "a suite of essential utilities for any Linux system":
addpart, agetty, blockdev, cal, cfdisk, chfn, chkdupexe, chrt, chsh, col, colcrt, colrm, column, ctrlaltdel, cytune, ddate, delpart, display-services, dmesg, elvtune, fastboot, fasthalt, fdformat, fdisk, flock, fsck.cramfs, fsck.minix, getopt, halt, hexdump, hwclock, initctl, ionice, ipcrm, ipcs, isosize, kill, last, line, logger, login, look, losetup, mcookie, mesg, mkfs, mkfs.bfs, mkfs.cramfs, mkfs.minix, mkswap, more, mount, namei, need, newgrp, partx, pg, pivot_root, provide, ramsize, raw, rdev, readprofile, reboot, rename, renice, reset, rev, rootflags, script, scriptreplay, setsid, setterm, sfdisk, shutdown, simpleinit, swapoff, swapon, taskset, tailf, tunelp, ul, umount, vidmode, vipw, wall, whereis, and write

Friday, April 13, 2012

iPads

Usually I'm the only one reading an iPad on my daily bus commute. This morning, I spotted no fewer than three other guys (yes, guys) tapping away on various iPad models. Steve Jobs must be smiling down from Heaven.

Wednesday, April 11, 2012

Parsing Large XML Documents in Ruby

Bill Rawlinson tells how in Parsing Large XML Documents in Ruby. The takeaway: use Nokogiri despite the state of its documentation. Bill gives us an example code listing as well. Thanks.

Gmail: how to remove "on behalf of" from sender name

I use my Gmail account to send email from my philip@psteiner.com email account, but I noticed the recipient sees it as sent from me "on behalf of" my Gmail account, i.e.
From: dontusethisemail@gmail.com on behalf of Philip Steiner <philip@psteiner.com>
The tricky thing for me is that my psteiner.com domain is hosted on Google Apps, so I have no mail server available at the psteiner.com domain, nor do I want to pay bucks every month just for this service - at least not when Google can provide it for free.

Luckily Steve Mould over at LifeHacker was generous enough to share his solution for configuring Gmail to use Google Apps as the outgoing mail server. Huzzah!

How to configure cygwin to use ctrl + arrow to move cursor a word at a time

TruMaze points the way to DOS box fumble-finger compatibility

Tuesday, April 10, 2012

Curses, Cygwin! Let's be clear...

Out of the box Cygwin doesn't include the 'clear' command. Hmm. Install ncurses to get it. Then add alias cls='clear' to your .bashrc or .bash_profile. Also learned bash responds to Control-L to clear the screen.

Sunday, April 8, 2012

Rails 3 on Ubuntu 11.10 on VirtualBox VM on Windows 7

Okay, so Rails runs pretty well for development on Windows 7 using RailsInstaller, but you're still running in a Windows environment. This is apparently now tolerable, but still not recommended, for two-fisted Rails development. I figure the best approach is to set up a development environment that's similar to the deployment environment. The defacto commercial Rails stacks now consists of some Linux distro, Passenger, Rails, MySQL and Git, so that's what I'll approach in this setup.

In the spirit of (and cribbing from) notes that Alan D. Jackson made while setting up Rails 3 on Windows with Ubuntu on a VM, here's my experience doing the same thing:
  1. If you don't have it already, download and install Putty or Cygwin for the ssh client
  2. Download VirtualBox for Windows Hosts. Based on this comparison of VMs, VirtualBox is the best choice for this application.  
  3. Install VirtualBox. I installed version 4.1.12.
    1. Not knowing any better, I left all of the defaults selected. We'll soon see if that was the right choice.
    2. The install wizard proceeded as expected. Let it start VirtualBox.
  4. Download the latest Ubuntu ISO file.
    1. Hrm, first question. I'm running Windows 7 64-bit, so I guess that means I want 64-bit Ubuntu? I don't know, the VirtualBox setup wizard lets me select either 32- or 64-bit. However, the Ubuntu download page recommends 32-bit. I'll go with the 32-bit for now.
  5. Set up a new VM
    1. Click the "New" VM button, name it "Rails 3.2 on Ubuntu". Helpfully VB selects Ubuntu from the OS list.
    2. Memory: the default is 512Mb. Alan recommends 384. Since I have 3Gb available, I'll splurge on 512Mb.
    3. Virtual Hard Disk: create a new 8Gb disk.
    4. Virtual Disk Creation Wizard: leave the default "VDI" selected as recommended
    5. Virtual Disk Storage Details: leave the default "Dynamically allocated" selected as recommended
    6. Virtual Disk File Location and Size: leave the default values selected
    7. Review the Summary, then click Create
  6. File -> Virtual Media Manager
    1. Select CD/DVD Images
    2. Add the Ubuntu ISO image
    3. click Close
  7. Select the new VM image -> Settings 
    1. Storage
      1. Storage Tree: Select IDE Controller -> Empty
      2. Attributes: click the tiny little CD image to right of the "CD/DVD Drive" dropdown and select the ubuntu ISO image
    2. Network
      1. Select Adapter 2 tab
      2. Check Enable Network Adapter
      3. Select Host-only Adapter
      4. Click OK
  8. Start the VM, then select "Install Ubuntu".
  9. Let the Ubuntu installer do its thing, then reboot the VM.
  10. After the VM reboots, install guest additions to get shared folder?
  11. Install samba (Windows file sharing)
    1. sudo apt-get install samba samba-common 
    2. sudo apt-get install python-glade2
    3. sudo apt-get install system-config-samba
    4. Open Samba Server Configuration from Ubuntu desktop -> Dash home -> Applications -> Samba
    5. In Samba Server Configuration, select File -> Add Share -> Basic
      1. Directory: /home/[your name]
      2. Leave share name and description as is
      3. Select Writable and Visible
      4. On the Access tab, select Allow access to everyone. You'll still have to logon as the user from Windows
    6. In Preferences -> Server Settings, 
      1. change the workgroup name to your PC's workgroup name. You can find the Windows workgroup name in the Windows "System" control panel
      2. Leave all of the other settings at their defaults.
    7. In Preferences -> Samba Users, you might have to set the Samba password for the user account
    8. Close Samba
    9. In windows, browse to \\server\user (e.g. \\ubuntu\philip), then enter the username/password when prompted
  12. Install Open SSH Server
    1. sudo apt-get install openssh-server
    2. ssh from Windows desktop via Cygwin or Putty: ssh you@your_ubuntu
    3. Create a .bash_profile file to source .bashrc for aliases, etc. when you log in via ssh:
      if [ -f ~/.bashrc ]; then
          . ~/bashrc
      fi
  13. Dev setup
    1. Install aptitude (if needed): sudo apt-get install aptitude
    2. Install basic packages: sudo aptitude -y install curl git-core build-essential zlib1g-dev libssl-dev libyaml-dev libreadline5-dev sqlite3 libsqlite3-dev autoconf automake nodejs
  14. Install rvm (Ruby Version Manager) 
    1. curl -L get.rvm.io | bash -s stable
    2. Reload shell (or close and reopen it): source ~/.bash_profile
    3. Add rvm setup to .bashrc file: 
    4. if [[ -s "$HOME/.rvm/scripts/rvm" ]]; then source "$HOME/.rvm/scripts/rvm" ; fi
  15. Install Ruby and Rails. Insert the latest version numbers:
    rvm install 1.9.3 && rvm --default ruby-1.9.3 && gem install rails sqlite3
  16. Smoke test:philip@ubi:~$ ruby -v && rails -v
    ruby 1.9.3p125 (2012-02-16 revision 34643) [i686-linux]
    Rails 3.2.3
  17. Create a Rails test site:
    1. mkdir ~/sites && cd ~/sites
    2. rails new rails_app && cd rails_app && rails s
    3. Browse to http://yoursite:3000/, if all goes well you'll see the default Rails home page
  18. Make Rails faster! Edit this setting in ~/.rvm/rubies/ruby-1.9.X-pXXX/lib/ruby/1.9.X/webrick/config.rb to speed up browsing the rails app from the Windows host:# :DoNotReverseLookup => nil,
    :DoNotReverseLookup => true,
  19. Now the app can be edited from the Samba share on Windows.

Tuesday, April 3, 2012

How to replace WEBrick with Thin for Windows development

WEBrick still seems awful slow on Windows. Last time I played with Rails, Mongrel was the goto replacement for WEBrick. Alas, Mongrel's no longer supported. So then I learned Thin is the new Mongrel. Here's how to get it working on Windows:

First, you might have to do this to install thin on Windows:
gem install eventmachine --pre
gem install thin


thanks to frogz
Then add the line gem 'thin' to your Gemfile to make Thin the default server when you run rails s, et voila:
=> Booting Thin 
=> Rails 3.2.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop

Monday, April 2, 2012

Rails: How to kill WEBrick 1.3.1 on Windows 7

This worked for me, using RailsInstaller on Windows 7 - launch the WEBrick process into a separate command window by using the start command:

C:\Sites\myapp>start "rails" rails s


This will open a new command window entitled "rails - rails s", running the WEBrick process, leaving the original command window available for use. 

When you're ready to kill WEBrick, just close the "rails" command window. Brutal, but effective. 

Is Node.js the next Big Next Thing?

Andrew Chen explains that Node.js might be poised to be the next Big Next Thing for web apps. He asserts that "Rails, PHP and Visual Basic were all successful because they made it easy to build form-based applications," and if the Node.js community can make something as easy as How to build a blog engine in 15 min with Rails, then it may pick up real traction.

Or it may become just a footnote in web history - anyone remember ColdFusion?


1949 torus for fusion experiments, Clarendon Laboratory, Oxford courtesy Robin Stevens

Wednesday, March 28, 2012

Rats in the attic

Sometimes you have to deal with the rats in the attic.

A coworker dropped by to brainstorm a perplexing problem he noticed in the report he was working on. The report is a PDF document generated from XML using XSLT and Apache FOP. An index table appears on the last page of the report, listing the name and page number of each section in the report. All of the sections were listed with the correct page number, except the section output on page 2 of the report, which the index showed as starting on page 1.

After tracing through the legacy XSLT code for a couple of minutes, we realized that the section start was flagged in the XSL-FO code in an "invisible" table that happened to come out at the very bottom of page 1, forcing the "visible" table over to page 2. Thus the table of contents correctly but deceptively showed the section starting on page 1. The code base that generates this report is several years old, and it has gone through multiple hands, as such code often does, so we had no idea why the original designers chose to output the section start flag in this way.

We came up with a couple of possible fixes he could to try, like eliminating the "invisible" table and moving the flag into the visible table, or if the invisible table was really necessary, apply a "keep with next" attribute so it would always stick to its corresponding section.

My coworker then said the problem reminded him of a scene from Bad Boys 2 (caution, link is not PG or SFW!), wherein Cuban drug lord Johnny Tapia, crawling through the attic where he stashed a mountain of stolen cash, discovers a nest of huge rats gnawing through the piles of loot. After blasting the rats with a cannon-sized revolver, Tapia exclaims to his henchman, "Carlos, this is a stupid f****ing problem to have, but, it is a problem, nonetheless!"

Wednesday, February 15, 2012

A Fundamental Law of the Universe

...the primary rule of IT support: whoever touched it last owns it.
Remy Porter for WTF!

Wednesday, January 11, 2012

How to write regexs matches that span multiple lines in Visual Studio search

Visual Studio has its own weird syntax for searching with regular expressions. Here's how to make a match across multiple lines. Given the sample XSL blocks below
<xsl:apply-templates select="Alph" mode="frobit"/>
<xsl:apply-templates select="Bob" mode="zap"/>
<xsl:apply-templates select="Cam"/>
I want to match the two statements with the mode="frobit", even though the first one has a carriage return in the middle. In VS, you'd use this regex statement to match just the first and last lines, skipping Bob with mode="zap":

select.*\n@.*mode="frobit"

The first bit, select.*\n, is standard Perlish for "match from the word select to the end of line character, \n."

The at sign @ is VS's way of asking "please can you find zero or more carriage returns, but only as few as needed." The alternative is the "greedy" match, using an asterisk *, which says "find as many lines as you can ending in carriage returns before you hit mode="frobit", so the match in this case would make one giant match, including all of the text from select="Alph" all the way to the last "frobit" on Cam, capturing poor Bob in the middle along the way.

Friday, January 6, 2012

How to clean up Windows Media Player

If you've relocated or removed a media directory but its contents are still showing up in WMP's libraries list, try deleting the contents of C:\Users\[username]\AppData\Local\Microsoft\Media Player. That should clear out phantoms!

Tuesday, January 3, 2012

How to restore TortoiseSVN icons in Windows Explorer

From the TortoiseSVN FAQ
With TortoiseSVN 1.3.0 and later, you can also rebuild the icon cache by calling TortoiseProc from the command line like this TortoiseProc.exe /command:rebuildiconcache