Skip to content

Instantly share code, notes, and snippets.

@mipearson
mipearson / _bs_form_field.html.haml
Created January 12, 2012 02:24
Bootstrap Form Fields
%div.clearfix{:class => errors.present? ? 'error' : ''}
= form.label field
.input
= form.send(method, field, *options)
- if errors.present?
%span.help-inline= errors
@mipearson
mipearson / layout.html
Created January 16, 2012 02:00
SkyBox Blog Gradient
<body>
<div id="body">
.. actual body content goes here, including header/footer/nav/etc ..
</div>
<div id="bg1"></div>
<div id="bg2"></div>
</body>
@mipearson
mipearson / gist:1624584
Created January 17, 2012 04:05
Capybara / Cucumber issue

I have an application that, for better or worse, responds in different ways depending on the domain that is used to access it.

Testing this behaviour with rack-test has not been an issue. We use:

When /^I visit the domain "(.*)"$/ do |domain|
  visit "http://#{domain}/"
end

which works as expected: it sets the http_host in the rack request environment and the application responds appropriately.

@mipearson
mipearson / gist:1625073
Created January 17, 2012 05:57
Full stack integration testing with cucumber - is it worth it?

So far I've been part of four projects and witnessed one that have used Cucumber and automated browser testing (eg selenium). For one reason or another, this has always felt, in retrospect, a waste of time.

I'm going to list the details of the projects here and I'd like others to contribute with their own successes and failures.

I'm doing this as there's a significant contingent in the community who believe that this testing approach is the best way forward. I would like this to be true. Instead, I'm seeing that the toolsets and the knowledge in the community are not mature enough for anything other than simple projects.

This gist was previously about BDD. It's now purely about integration testing using cucumber and using integration tests to drive development. I like BDD as a concept. I have not yet seen it implemented in such a way that made me think the effort was worth the benefit. I think that the current approach and toolsets are to blame for this.

Project 1:

@mipearson
mipearson / link_to_remote.js
Created February 19, 2012 12:14
UJS replacement of :update and :loading behaviour of Rails 2.x link_to_remote
@mipearson
mipearson / unfixable.md
Created April 2, 2012 01:44
Request for Comments: Fixing Ruby, Python and Node.js packaging on Debian, Redhat and variants

Request for Comments

Fixing Ruby, Python and Node.js packaging on Debian, Redhat and variants.

Canonical URL: http://bit.ly/wtfpackages

It's unfixable.

You shouldn't be using distribution provided packages for your primary language runtime.

@mipearson
mipearson / i_heart_asset_pipeline.md
Created April 16, 2012 02:11
I <3 the Asset Pipeline

I <3 the Asset Pipeline

People talk shit on Sprockets and the Asset Pipeline all the time. I get it. It's pretty confusing and when it breaks it can break in really undesirable ways. I was originally very sceptical, and I strongly considered upgrading to Rails 3.2 with sprockets disabled.

I didn't, and I'm glad I've stuck with the pipeline. Here's why:

  1. If you're using digested assets (by default you are), asset expiry just works. No cache clearing during dev, no "wait a few minutes for the CSS to expire", no expiring every asset on every deploy, no deployment issues where people get new HTML and old CSS or JS. Sprocket's digest strategy has so far been excellent and I'm glad it's there.

  2. SASS and CoffeeScript just work. No running guard or compass to watch and auto-compile your shit, relatively seamless integration into Rails, and effective separation of vendored code from application code.

@mipearson
mipearson / fuck-you-mysql-you-fucking-fuck-of-a-fuckstick.txt
Created April 26, 2012 03:51
Example of MySQL default being harmful
Mirrored from http://flooble.net/~pete/fuck-you-mysql-you-fucking-fuck-of-a-fuckstick.txt
mysql> create table fuckyou ( id integer primary key auto_increment, name varchar(20) not null );
Query OK, 0 rows affected (0.00 sec)
mysql> insert into fuckyou (name) values (null);
ERROR 1048 (23000): Column 'name' cannot be null
mysql> insert into fuckyou (name) values ('pete');
Query OK, 1 row affected (0.00 sec)
create temporary table source_grouped ( group_id int primary key, updated_at datetime);
insert into source_grouped select group_id, max(updated_at) from source group by group_id where group_id is not null;
update dest, source_grouped set dest.last_updated_at = source_grouped.updated_at where dest.source_group_id = source_grouped.group_id;
{
"color_scheme": "Packages/Color Scheme - Default/Solarized (Light).tmTheme",
"ensure_newline_at_eof_on_save": true,
"folder_exclude_patterns":
[
".svn",
".git",
".hg",
"CVS",
".sass-cache",