Skip to content

Instantly share code, notes, and snippets.

View cmeiklejohn's full-sized avatar
💭
Always working.

Christopher S. Meiklejohn cmeiklejohn

💭
Always working.
View GitHub Profile
@cmeiklejohn
cmeiklejohn / mongodb index question
Created February 20, 2011 22:50
Why is this not using the index?
> db.collection.getIndexes();
[
{
"name" : "_id_",
"ns" : "test.collection",
"key" : {
"_id" : 1
}
},
{
@cmeiklejohn
cmeiklejohn / AnotherController.rb
Created February 27, 2011 05:10
Is this really the right way to do this?
# Rails 2 way.
SomeController.new.process( request, response )
# Rails 3 way.
status, headers, body = SomeController.action(:show).call(request.env)
response = ActionDispatch::Response.new(status, headers, body)
self.response_body = response
class MicropostsController < ApplicationController
before_filter :set_micropost, :only => [:show, :edit, :update, :create, :new]
before_filter :authenticate, :only => [:create, :destroy] # Same here?
# Omitted.
def destroy
@micropost.destroy
redirect_back_or root_path
@cmeiklejohn
cmeiklejohn / utf8_header.rb
Created April 24, 2011 00:38 — forked from derencius/utf8_header.rb
thor file to add utf-8 header on ruby files. useful for converting ruby 1.8 projects to 1.9
class Utf8Header < Thor
desc "add", "Add Content UTF-8 on top of all .rb/.feature files"
# copy & pasted from https://gist.github.com/738245
def add
files = Array.new
["*.rb", "*.rake","*.feature"].each do |extension|
files.concat(Dir[ File.join(Dir.getwd.split(/\\/), "**", extension) ])
end
files.each do |file|
@cmeiklejohn
cmeiklejohn / parse-me.rb
Created May 17, 2011 23:11
minimal capybara use outside of rails
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'capybara-webkit'
Capybara.run_server = false
Capybara.current_driver = :webkit
Capybara.app_host = 'http://www.google.com'
module MyCapybaraTest
@cmeiklejohn
cmeiklejohn / array_regexp_match.rb
Created July 13, 2011 16:49
Array of regexp matching with include?
class Array
def include_by_regexp_or_string?(str)
any? do |o|
o.is_a?(Regexp) ? o =~ str : o == str
end
end
end
@cmeiklejohn
cmeiklejohn / Questions
Created August 9, 2011 00:52
Frozen Rails Give-away
Day job: Software Engineer at Swipely
Your Rails contributions (if any): Around six or so bug fixes to rails. Have also fixed bugs in a bunch of other gems. Recent contributor to rubygems.org.
What's your Ruby/Rails experience?: Been working with rails off and on since around 2006. Full time Rails developer currently.
How do you use GitHub?: All of my source code, dotfiles, projects in progress, contributing to other projects.
@cmeiklejohn
cmeiklejohn / vowstobi.coffee
Created September 10, 2011 21:24
vows and tobi not working, anyone?
# coffeescript issue
vows = require('vows')
tobi = require('tobi')
should = require('should')
getBrowser = () ->
tobi.createBrowser(80, 'www.google.com')
vows
vows = require('vows')
tobi = require('tobi')
should = require('should')
vows
.describe('Test')
.addBatch
'A hit':
topic: () ->
browser = tobi.createBrowser(80, 'www.yahoo.com')
{
"author": "drip <drip@drip.io>",
"name": "drip",
"description": "npm continuous integration",
"version": "0.0.1-5",
"repository": {
"url": "https://github.com/drip/drip.git"
},
"engines": {
"node": "~v0.4.7"