Skip to content

Instantly share code, notes, and snippets.

@ddemaree
ddemaree / shell_output.txt
Created May 15, 2012 12:28
Error compiling Core Data model in RubyMotion 1.4
› rake
Build ./build/iPhoneSimulator-5.1-Development
Build ./vendor/AFNetworking
Link ./build/iPhoneSimulator-5.1-Development/CB Ruby.app/CB Ruby
Compile ./resources/Cashbox.xcdatamodeld
./resources/Cashbox.xcdatamodeld:0: error: Compilation failed for data model at path './resources/Cashbox.momd/Cashbox.mom'
rake aborted!
Command failed with status (1): ["/Applications/Xcode.app/Contents/Develope...]
Tasks: TOP => default => simulator => build:simulator
@ddemaree
ddemaree / 01_rubymotion.mdown
Created May 9, 2012 16:25
DRAFT: RubyMotion first impressions

Title: RubyMotion first impressions

For the last couple of days I've been playing with RubyMotion, Laurent Sansonetti's amazing new toolchain that allows developers to write fully-fledged, native Cocoa apps for iOS using MacRuby. Having seen some of what the MacRuby community is doing with it, heard what guys like Marco Arment and John Siracusa have to say about it, and having cut myself on some of its rough edges, it feels like a good time to stop and take down some first impressions.

What I like

While it's true RubyMotion isn't that much less of a black box than Xcode — in that it's still a proprietary framework that slurps in code and spits out either errors or a working iOS app — being able to configure and build a project using only a Ruby Rakefile feels much simpler and nicer.

RubyMotion's configuration DSL is simple and task-oriented, and effectively does a job that in Xcode is spread across six or seven (or more?) different .plist files or project settings.

@ddemaree
ddemaree / 2012-04-27-cucumber.mdown
Created April 27, 2012 17:37
Cucumber blog post

RubySource Talks to Matt Wynne About Cucumber

Link: http://rubysource.com/matt-wynne-on-using-cucumber/

Wynne is the co-author (with Aslak Hellesøy) of Pragmatic's The Cucumber Book. In this interview by Pat Shaughnessy, he explains a bit about what Cucumber is for and how it can help teams deliver good software:

Q: So do you view Cucumber as a pair or group programming tool?

Wynne: I view it as a team communication or collaboration tool really. So by playing the game, forcing yourselves to try to describe what you want the software to do, together, what you end up doing is surfacing all the things that you haven’t actually figured out yet and all the things that you’re not really sure about. This is what Dan North calls deliberate discovery.

@ddemaree
ddemaree / hiw01_ruby.mdown
Created February 25, 2012 05:50
How I Work, Part I: Ruby

How I Work, Part 1: Ruby

Since the first of the year I've been trying to write one of that sort of post where the blogger describes the tools they use. Obviously, I haven't succeeded yet. And what's more, it's taken me until now to precisely identify why it's been so hard.

It's not that I find these "setup" posts to be a form of pornography. They are, and I do, but in this scenario I would be the porn star, not the lonely guy who looks for tips on productivity blogs in lieu of an actual life. And it's not that my setup isn't interesting. It's not that mind-blowing or innovative, honestly, but over the years I've learned a lot about what I need to do my job and that knowledge feels worth sharing.

What I've concluded, rather, is that in trying to talk about my tools in a single post, I was going about it totally the wrong way. Tools and best practices are things I care deeply about, and trying to cram everything into a single, 5,000-word monster post would be exhausting for me to write, at least as tir

@ddemaree
ddemaree / 01_README.md
Created November 30, 2011 05:23
How Sunspot implements its wonderful search/index DSL

This code is extracted/adapted from Mat Brown's Sunspot gem. One of Sunspot's nicest features is an expressive DSL for defining search indexes and performing queries. It works by instance_eval-ing a block you pass into it in the context of its own search builder object. In this code, the pig thing1 statement is roughly equivalent to zoo = Zoo.new; zoo.pig(thing1).

Sunspot's DSL has to resort to trickery: the instance_eval_with_context method uses eval to get the block to give up the object it considers to be self, then sets up an elaborate system of delegates and method_missing calls so any methods not handled by the DSL are forwarded to the surrounding object. But as a result, this syntax is minimal and beautiful, and it works the way you expect whether or not you prefer blocks to yield an object.

Without this trick the block would be restricted to either the original, "calling" context (as a closure) or the DSL's "receiving" context (using instance_eval), but not both.

Using `ins

@ddemaree
ddemaree / .gitignore
Created October 6, 2011 17:08
@font-face code examples for AIGA Chicago presentation
*.woff
*.svg
*.ttf
*.eot
@ddemaree
ddemaree / application.js.coffee
Created June 12, 2011 21:54
Simple Google Maps API v3 integration in CoffeeScript, with non-JS Static Maps fallback
#= require jquery
#= require jquery_ujs
#= require lib/modernizr
#= require lib/jquery.lettering
#= require_tree .
$ ->
$('*[data-googlemap]').googleMap()
true
@ddemaree
ddemaree / 01_random_specs.rake
Created June 8, 2011 21:54
Rake task for running a random sampling of RSpec tests
namespace :spec do
SPEC_SUITES = %w(models requests integration helpers controllers lib)
def sample_spec_files(num=5)
[].tap do |specs|
SPEC_SUITES.each do |dirname|
files = Dir[Rails.root.join("spec", dirname, "**", "*_spec.rb")]
specs.concat files.shuffle.first(num)
end.shuffle
end
@ddemaree
ddemaree / 01_ticket.rb
Created May 30, 2011 20:58
I cannot believe this is valid Ruby syntax. P.S. - I love Ruby
class Ticket < ActiveRecord::Base
SEARCH_COLUMNS = {
:tickets => [:token, :subject, :body, :customer_name, :customer_email],
:notes => [:body, :author_name, :author_email]
}
def self.conditions_for_keyword_search(table, keywords)
# Because we may use this string elsewhere, we don't want to mutate the only copy
query_words = keywords.dup
@ddemaree
ddemaree / config.ru
Created April 9, 2011 14:49
Rackup file for Rails 2.3.x projects (very useful for getting legacy apps running on pow.cx)
# Rails.root/config.ru
require "config/environment"
use Rails::Rack::LogTailer
use Rails::Rack::Static
run ActionController::Dispatcher.new