The blog has moved to http://jessehouse.com/ ... Many google searches point here so I am leaving it operational, but there will be no new posts.

Saturday, July 6, 2013

Puppet Solo (AKA: supply_drop)

Similar to knife-solo for use with chef, supply_drop allows you to provision servers using puppet without the need for a puppet master server. It uses capistrano for executing commands on the remote server. I put together a working sample set of puppet and supply_drop deployment scripts for provisioning a postgres server.

See the github repo at  https://github.com/house9/puppet-solo-hello-world

Resources




Monday, June 24, 2013

WAL-e chef cookbook

Postgres has various backup and restore options
Do you have a recovery plan in case your Postgres server crashes - your daily pg_dump is probably not going to cut it.
Postgres uses Write-Ahead Logging (WAL)
Write-Ahead Logging (WAL) is a standard method for ensuring data integrity. A detailed description can be found in most (if not all) books about transaction processing. Briefly, WAL's central concept is that changes to data files (where tables and indexes reside) must be written only after those changes have been logged, that is, after log records describing the changes have been flushed to permanent storage. If we follow this procedure, we do not need to flush data pages to disk on every transaction commit, because we know that in the event of a crash we will be able to recover the database using the log: any changes that have not been applied to the data pages can be redone from the log records. (This is roll-forward recovery, also known as REDO.)
Setting up Continuous Archiving and Point-in-Time Recovery (PITR) for your Postgres WAL files is very complex, lucky for us the WAL-e project has simplified this process greatly. WAL-e has utilities for sending all WAL files to an AWS S3 bucket as the log files are being generated. More Information, see:
Recently I put together a chef cookbook which installs WAL-e on a Postgres instance, see:

Tuesday, June 11, 2013

Vagrant and puppet postgres 9.2 on ubuntu

Some vagrant configuration to install postgres 9.2 using puppet



Resources

Saturday, June 1, 2013

Vagrantfile for setting up multiple machines with chef configuration

Example Vagrantfile below for setting up multiple virtual machines and using chef to provision them



Resources

Thursday, March 21, 2013

HipChat is now free!

Just got an email from HipChat - now free for small groups - awesome!


Saturday, February 23, 2013

> random tricks you can do with Rails

There are bunch of really good nuggets in this presentation:


Ruby on Rails continuous integration (CI) with Jenkins the easy way with Chef and Knife

Do you need a CI build setup for your Ruby on Rails app?

Here are some chef / knife solo scripts that will deploy a Jenkins server to run your CI build - you could be up and running in less than 1/2 an hour

https://github.com/house9/ci_chef_jenkins_rails

Check out the README for details


Wednesday, December 19, 2012

rails :remote => true jQuery events

I constantly find myself looking these up, saving this link for future reference

https://github.com/rails/jquery-ujs/wiki/ajax

contains all of the rails custom jQuery events for remote forms, such as "ajax:success", "ajax:before"; also includes the method signatures.


Sunday, December 16, 2012

Sending email with Rails Mailers, The Random bits...

See the rails guides and railscasts for getting started with Rails Mailers; 
this article includes some additional information on Rails Mailers not included in those articles.

RailsCasts: http://railscasts.com/episodes/206-action-mailer-in-rails-3
Rails Guides: "Action Mailer Basics" on the rails guides - The guide covers all of the common mailer tasks
  • setup and configuration
  • attachments
  • layouts

Random Bits
These examples were created using rails 3.2
Add importance headers

NOTE: many email clients will ignore these headers

Add receipt header

NOTE: many email clients will ignore these headers

Testing mailer headers with rspec

If you have rspec-rails gem installed with your rails application then running the generator will stub out most of your mailer tests, including a fixture file for the mailer view, which you may or may not want to remove.

NOTE: test against mail.header, not mail.headers

Use a different layout for some Mailer actions

our default layout is the customer facing one but we want to override it in some cases




Saturday, November 3, 2012

Setting up a C.I. build (Continuous Integration) for a Ruby on Rails application


It has never been easier than with Semaphore - Hosted Continuous Integration


How easy is it

  • add semaphore ssh key to your github repo
  • then semaphore automatically determines your ruby version, database, etc...
  • you can tweak the build steps later, the defaults are pretty good

It will automatically detect new branches!!! That means zero setup when the new branch is added



It is not cheap, for personal side projects it might not make sense?
But well worth the money if you are doing paid development

Git Log Formatting

The git log command is great and has tons of good information, but the output doesn't give you that nice 'overview' of the commit history, too much detail on too many lines

I've been using the following in my .gitconfig file
l = log -20 --format='%h %ad %d %an: %s' --date=short
typing 'git l' renders the following output:



Last night I watched the Destroy All Software "PRETTY GIT LOGS" screencast which takes 'git l' to the next level

now 'git l' renders


   

Wednesday, September 5, 2012

414 Request-URI Too Large


How to configure nginx to accept larger querystring requests

Increase the 'large_client_header_buffers'

This is located in the 'http' section of the configuration

Example:



Saturday, August 25, 2012

Unofficial Twitter Bootstrap Documentation

Unofficial Twitter Bootstrap Documentation
http://unofficial-twitter-bootstrap-documentation.com/

The current project I am working on is running bootstrap 2.0.2 and after the release of 2.1.0 the online documentation for 2.0.x was gone.

I went ahead and compiled the archive docs from the bootstrap github repo into a single site - hopefully others find it useful.

Sunday, July 1, 2012

Rails - ActiveRecord created_by and updated_by gem


Often your application will want to track who created and updated your data.
On a previous rails 2 project I used a plugin called userstamp which worked well, but until recently it did not support rails 3+

I didn't find any other gems out there at the time, so I put together the clerk gem,
you can install it as a gem in your rails 3+ applications by adding gem 'clerk' to your Gemfile, see the README on github for details

NOTE: the current version relies on your database tables having columns named created_by_id and updated_by_id and the gem does not support any custom configuration.



Sunday, April 29, 2012

postgres: random useful things

Run sql statements from the command line, use the -c flag


create a random value


crazy updates using regexp_matches


postgres: terminate all database connections

Using psql from the command line you can terminate all connections to a database

Comes in handy when you want to do things like restore your staging or development database


Friday, December 30, 2011

Inspect all jQuery events on an element

Very useful

$("SELECTOR").data("events");


All bound event handlers are stored in the elements data context under the events key
This can be very useful when debugging with tools like FireBug

$("form").submit(function () { alert('submit form'); });
$("form").data("events");
> Object { submit=[1] }


Resources

Friday, December 2, 2011

Get table and column information in postgres

Use the information_schema catalog - http://www.postgresql.org/docs/9.1/static/information-schema.html

Get table and columns from the public schema




This can be useful, maybe you want to auto generate some text that creates foreign keys based on a naming convention - for instance let's say we have a ruby/rails method called make_fk_unless_exists




The 'code' column would render something like

make_fk_unless_exists :projects, :milestone_id, :milestones
make_fk_unless_exists :tasks, :project_id, :projects
...