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
Well, below is a ballot feature that I'd like to replicate with Drupal's webform module. (well except for the tricksy voting feature.)
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.
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.
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.
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.
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:
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: