This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CardCreator < Struct.new(:listener) | |
class Failed < RuntimeError | |
attr_accessor :model | |
def initialize(model) | |
@model = model | |
end | |
end | |
def self.create(iteration, attributes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The best approach depends on how you define a blog entry. If you think | |
# of a blog article the same way I do, that means "all pages with a date". | |
# | |
# In Ruby you can re-open a class and redefine its methods. Normally, this | |
# would be a horrific thing to do (as others could be very confused by | |
# your code) but in the context of a typical Nesta site I don't think it's | |
# particularly bad news, and its very convenient. | |
# | |
# So, in app.rb, add this (which is very similar to the default): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11:53:07 web.1 | /Users/graham/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/sass-3.1.15/lib/sass/plugin/compiler.rb:29:in `<class:Compiler>' | |
11:53:07 web.1 | /Users/graham/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/sass-3.1.15/lib/sass/plugin/compiler.rb:28:in `<module:Plugin>' | |
11:53:07 web.1 | /Users/graham/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/sass-3.1.15/lib/sass/plugin/compiler.rb:9:in `<top (required)>' | |
11:53:07 web.1 | /Users/graham/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/sass-3.1.15/lib/sass/plugin.rb:4:in `<top (required)>' | |
11:53:07 web.1 | /Users/graham/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/haml-3.1.4/lib/sass/rails3_shim.rb:15:in `block in <top (required)>' | |
11:53:07 web.1 | /Users/graham/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.2.1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval' | |
11:53:07 web.1 | /Users/graham/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.2. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Card extends Serenade.Model | |
@localStorage = true | |
@property 'title', serialize: true | |
class CardSet extends Serenade.Model | |
@localStorage = true | |
@hasMany 'cards', as: (-> Card), constructor: Card, serializeIds: true | |
# Create one card, and one card set, and save them to the database. | |
the_set = new CardSet(id: 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I said "I'll send you a link..." at least three times last night. | |
Thought I may as well send 'em to the list... | |
Daniel Tenner's example videos for validating product ideas without | |
writing any code are linked from this post: | |
http://swombat.com/2012/1/27/create-your-own-video | |
He's also got loads of other ideas on validating things that you can | |
find with this search: http://swombat.com/search?q=validat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Mongoid #:nodoc | |
module Components #:nodoc | |
extend ActiveSupport::Concern | |
# All modules that a +Document+ is composed of are defined in this | |
# module, to keep the document class from getting too cluttered. | |
included do | |
extend ActiveModel::Translation | |
extend Mongoid::Finders | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'open3' | |
def python | |
Open3.popen2(%w(python -u)) do |stdin, stdout| | |
stdin.puts yield | |
stdin.close | |
puts stdout.read | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'open-uri' | |
HOSTNAME = "http://localhost:9393" | |
def retrieve_all_pages | |
pages = [] | |
Dir.glob('content/pages/**/*.{mdown,textile,haml}').each do |filename| | |
page = filename.sub(/^content\/pages\//, '') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Presenter < Struct.new(:object) | |
include ActiveModel::Serializers::JSON | |
class << self | |
def presenter_model | |
name.to_s.sub(/Presenter$/, "") | |
end | |
def method_missing(name, *args, &block) | |
if ! presenter_model.empty? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## No matter how hard I try, I can't think of a good reason to do this. | |
$ rails console | |
irb(main):001:0> myobj = 1 | |
=> 1 | |
irb(main):002:0> myobj.send(:helper) | |
=> #<ActionView::Base:0x007fc22080e3c0 @assigns={}, @helpers=#<Module:0x007fc22080e370>, @_controller=nil, @_config={}, @_content_for={}, @_virtual_path=nil, @output_buffer=nil, @lookup_context=#<ActionView::LookupContext:0x007fc2204e53b0 @details_key=nil, @details={:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml, :haml], :formats=>[:html, :text, :js, :css, :ics, :csv, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json], :locale=>[:en, :en]}, @skip_default_locale=false, @frozen_formats=false, @view_paths=[]>, @controller=nil> | |
irb(main):003:0> myobj.instance_variable_get(:@helper) | |
=> #<ActionView::Base:0x007fc22080e3c0 @assigns={}, @helpers=#<Module:0x007fc22080e370>, @_controller=nil, @_config={}, @_content_for={}, @_virtual_path=nil, @output_buffer=nil, @lookup_context=#<ActionView::LookupContext:0x007fc2204e53b0 @details_key=nil, @deta |