February 2012
1 post
January 2012
1 post
Stopwatch
require 'singleton'
module Stopwatch
if defined?(ActiveRecord) && defined?(ActiveRecord::ConnectionAdapters)
ActiveRecord::ConnectionAdapters::AbstractAdapter.class_eval do
def log_with_watcher(sql, name = "SQL", binds = [], &block)
Stopwatch.instance.event("sql '#{name}'.") do
log_without_watcher(sql, name, binds, &block)
end
end
...
November 2011
2 posts
Simple Trie for Autocomplete
require 'test/unit'
class Trie
def initialize()
@root = TrieNode.new
@entry_count = 0
end
def empty?
@entry_count == 0;
end
def size
@entry_count
end
def add(key, value)
return if key.nil? || key.empty?
current_node = @root
key.each_char { |character|
next_node = current_node.get(character)
next_node = current_node.add(character) unless...
October 2011
2 posts
Handy Git Commands
source /usr/local/etc/bash_completion.d/git-completion.bash
alias gits="git status"
git add -p
[alias]
staged = diff --cached
[color]
status = auto
branch = auto
diff = auto
Chris's Reading List
C
C Programming Language (2nd Edition) by Brian W. Kernighan and Dennis M. Ritchie
Java
Java Programming Language, The (4th Edition) by Ken Arnold, James Gosling and David Holmes
Thinking in Java (4th Edition) by Bruce Eckel
Advanced Effective Java (2nd Edition) by Joshua Bloch
Advanced Java Concurrency in Practice by Brian Goetz, Tim Peierls, Joshua Bloch and Joseph Bowbeer
Ruby
Learn to...
September 2011
1 post
August 2011
2 posts
USGA Handicap Index Effective: 8/1/11 - 12.3
– http://www.ghin.com/
June 2011
1 post
May 2011
1 post
April 2011
4 posts
Mizuno HttpServer
…couldn’t resist making a few changes to mizuno including an abstract handler, jmx suport, and slf4j logging. It’s just a placeholder for now…still fleshing out some new ideas.
module Mizuno
class HttpServer
include_class 'org.eclipse.jetty.server.Server'
include_class 'org.eclipse.jetty.servlet.ServletContextHandler'
include_class...
my tungle profile →
http://tungle.me/michaelbarinek
March 2011
2 posts
February 2011
2 posts
January 2011
3 posts
3 tags
calculating median values via mysql
Here is a quick mysql sql snippet that I used to calculate median values grouped by year…
select a.year, avg(a.rownum), avg(a.value) from (
select if(@current_year=year, @rownum:=@rownum+1, @rownum:=1) as rownum,
@current_year:=year as year, amount as value from (your_data_or_select) as amounts, (select
@rownum:=0) as r, (select @current_year:=0) as y order by year, amount) as a,
(select...
December 2010
4 posts
pivotal labs boulder - burgers in december…
November 2010
1 post
October 2010
6 posts
1 tag
Rails 3 with RVM and Cruise Control
Here are a few notes on how to get individual CruiseControl.rb project Builders running with RVM.
[Note: I’m making an assumption here that you know and understand Bundler and RVM.]
[Also: Cruise may or may not be running on RVM]
Create and check in a .rvmrc file in your rails root directory. Here’s an example.
rvm ruby-1.8.7-p174@rails-example
Then, add a project build command...
@pivotalboulder thank you for helping out last week with #mountainrb, we have a...
– twitter
September 2010
5 posts
1 tag
Scoping with confidence
We’ve recently scoped several projects in Boulder. While scoping, several clients asked how we’re able to estimate a project’s cost with such confidence. I’ve thought about this a bit and I actually think this is pretty interesting and remarkably similar to something we’ve all been doing for a while: estimating user stories in Tracker.
Scoping a project is very...
1 tag
Nesting and authenticating resque-web on ey-cloud
Wouldn’t it be nice to include the resque-web interface underneath your current application’s url?
Wouldn’t it then be nice to use the same authentication mechanism that your web application uses?
Here’s a solution that we used on a recent Rails 2.3 ey-cloud project that accomplished both goals.
First, we created a simple resque_web.ru file within our Rails 2.3 project....
1 tag
Dependency musings
Recently there has been a lot of discussion around project dependencies. As a result, it has been pretty hard to decide when and if to include a new gem into a project.
Overall, I think I tend to weigh in heavier on the side of exclude everything possible except what is absolutely necessary. That being said, here’s the mental check list I tend to work through when deciding whether or not...
1 tag
Cucumber performance improvements with Devise...
We’re using Devise’s token_authenticatable to improve our Cucumber test suite performance.
Here’s an example feature
Scenario: I would like to edit a user account
Given I am logged in as an admin user
...
And here’s the token_authenticatable step
Given /^(?:I am logged in|the user is logged in|the user logs in|I log in)(?: as an? (\w+) user)?$/ do...
August 2010
6 posts
Reindexing Solr from Cucumber
Here’s a quick snippet that we’re using to reindex Solr from our Cucumber features.
“And I reindex assets” helps to ensure that we didn’t leave any cruft around from previous
tests and that we’ve properly indexed our Pickle model.
Background:
And I am logged in as an admin user
And an asset with snowboarding tags: "snowboarding" exists with title:...
1 tag
Fast user switching with Devise
Ever wondered how to login as another user within Devise?
Recently we had a feature request that would provide Admins with the ability
to sign is as another user. You could imagine live demonstrations or even production
support calls where you would like to be signed in as another user, yet not
have to ask for or decrypt their current password. After stewing for a bit, we found a
pretty nice...
1 tag
Managing your ey-cloud-recipes
If you’ve recently forked the ey-cloud-recipes on GitHub and then had issues
managing and deploying multiple projects with disparate dependencies using the
single forked gem, then we have a solution that has worked well on a recent project.
We’ve tucked the cookbooks directory underneath our Rails project. To apply Chef
changes, we installed the ‘engineyard’ gem and us...
…Pickle is flawed as a concept
– http://elabs.se/blog/15-you-re-cuking-it-wrong
Agile the Pivotal Way →
Ian McFarland, Principal and VP of Technology for Pivotal Labs, reprises his popular RailsConf 2010 talk. Ian describes the technical and social aspects of how Pivotal practices agile software development.
July 2010
1 post
1 tag
June 2010
2 posts
May 2010
2 posts
Kentucky Derby 136 Race Replay
April 2010
5 posts