Creating a Better Print Screen

How I created a print screen command that automatically uploaded a screenshot to Google's free Picasa Image Hosting Service.

Read more
John Gould print image of Ornithorhynchus anatinus (platypus) and drupal.  From wikipedia.

Notes on Drupal Features

Notes on using the Features model to export a drupal site's configuration stored in the database into a new feature module.

Read more

Working on an Issue from the Drupal Issue Queue

How to set up a development environment with git for working on issues in the Drupal Issue Queue.

Read more
honey badger picture and git logo from wikipedia cc-share-alike

Git Log to the Rescue

A summary of the different options for viewing a project's commit history with git log.

Read more

Vim Tip: yanking or deleting a big chunk of text

Using Vim to separate database sections in a Large Database Dump.

Read more

Adding a Group By clause to a View

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.

A Drupal-centric Vim Configuration

My .vimrc

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.

Fun with grep and bash aliases

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.

Creating a Better Print Screen

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 automated!

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 screenshot.

Without further ado, here are the parts of the program.

Using Jekyll on NearlyFreeSpeech.net

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:

alias sshnfsn='username_sitename@ssh.yourhostname.nearlyfreespeech.net';

Once you save the .bashrc file, you can source it with:

Using Vim for Tricky Regular Expressions

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>

Vim Regexp

I was finally able to match the headline in vim with the following regular expression:

SAS Notes

SAS code in Emacs

The Data Step

Subsetting IF

In a Data Step you can exclude some observations from the dataset with an if statement.


data tornados_1980s;
  infile FileName;
  input year city damages;
  * this limits input data to 1980s data;
  if 1980 

  • IF .. IN statement
    if year in (1980, 1981, 1982);
    
  • AND, OR
    
    if year = '1980' and city = 'Baltimore';
    

    infile 'filename'

    In the data step, import data from a file with the infile command.

  • Notes on Drupal Features

    John Gould print image of Ornithorhynchus anatinus (platypus) and drupal.  From wikipedia.

    One of the difficulties of keeping a Drupal website completely in version control, is that a lot of the configuration is stored in the database. Each change you make to a site via clicking and saving on a site administration page is saved in the database. It is difficult to keep a history of these changes without writing the entire database to a file and then checking that into version control. But you don't want to commit an entire database into git. This is where the Features module comes into play. It helps separate the site's configuration in the database from the site's content.

    Pages

    Subscribe to Major Ursa RSS