Submitted by bart on Wed, 2015-01-07 10:32
Blocks in ruby are anonymous blocks of code passed to a method. In the following examples, we are passing a block of code to the
each method of the players array. Blocks are delimited with either
do ... end keywords or braces. The iterated value is set to the variable name in the special "goal posts" (eg
|player| in the first example,
|p| in the second). The variable name can be any legal variable name and is local to the block
Array Iteration with Each
Iterate through an array of player instances.
Submitted by bart on Thu, 2014-09-18 18:48
Well, below is a ballot feature that I'd like to replicate with Drupal's webform module. (well except for the tricksy voting feature.)
See the Pen Election Badge Experiment by Bart Lantz (@majorursa) on CodePen.
Submitted by bart on Tue, 2014-07-15 12:26
These are some quick notes on how I added a group by clause to a query for a view in Drupal 7.
I have a custom database in a module that I wrote and one of the fields in it: video_id corresponds to a node nid. So I wanted to pull this database into a view. However there can be many rows in my database for each node and all I wanted for the view was to print one message Update answer key if there was one or more entries in the database and a different message Create answer key if there were no entries.
Submitted by bart on Thu, 2014-06-12 14:59
These are notes for some of the trickier situations for writing Rules.
Trigger Rule when a Node field has changed
In order to get the node-unchanged selector, the only event must be "Before Saving Content".
Submitted by bart on Mon, 2014-05-26 09:42
In this post I'll describe my .vimrc, my vim configuration file. An important thing to keep in mind is that Vim has a handy built in help system. If there is any command that is unfamiliar to you, then you can look it up in a vim session by typing
:help <command> and vim will pop open a buffer with the documentation for that command.
I generally use vim while in a ssh session on a dev server and this vimrc works well for that.
Submitted by bart on Mon, 2012-07-30 11:34
Just a quick post to write up an bash alias I just created to list the sites enabled on a server and each sites location.
I often need to look up the list of sites enabled on a web server and also the document roots of each of these sites. In the past this meant loading the Apache configuration file into emacs or vim and searching for the site I was looking for. Today I decided to create an alias for this task. Here is the original combination of grep commands.
Submitted by bart on Mon, 2012-05-14 01:15
After reading Randall Degges excellent post How I learned to
Program, I decided to
give creating a screenshot program a try. It's always a bit of work to
take a screenshot, upload it to the web and then grab its permanent
link. So being a geek, I thought it high time this process was
I tried writing the program in python only, so that there were fewer
dependencies, but using the commandline program
scrot as the screenshot
snapping program added a lot of flexibility to the options for the
Without further ado, here are the parts of the program.
Submitted by bart on Fri, 2012-05-11 19:55
NearlyFreeSpeech.net is a good simple, bare-bones fit for a Jekyll
site once everything is set up. The price can't be beat, you can put
down a $10 payment and just try it out. With a Jekyll site, that $10
investment should last a while!
Set Up SSH Alias
The first thing to do is set up an ssh alias in your .bashrc file.
The hostname and username that are assigned at nfsn are generally
pretty easy to forget, so I always create an alias for them, like:
Once you save the .bashrc file, you can source it with:
Submitted by bart on Sat, 2012-04-14 00:00
How I did part of a SAS assignment in R
The residual plot in SAS was corrupted, luckily I was able to recreate
it in R. (And actually it looks better in R too.)
Submitted by bart on Mon, 2012-04-02 12:15
So, I was trying to convert an orgmode file to html. There is an orgmode-export-as-html function, but it was choking on something, so I needed to do the conversion by hand. I tried many, many times to convert the file with emacs regular expressions, but was unsuccessful. The difficulty was the orgmode headlines, which look like this:
*** Use the sort function
I wanted to simply transform this into
<h3>Use the sort function</h3>
I was finally able to match the headline in vim with the following regular expression: