Skip to content

Instantly share code, notes, and snippets.

View markfeedly's full-sized avatar

Mark van Harmelen markfeedly

View GitHub Profile
@markfeedly
markfeedly / gist:7603865
Created November 22, 2013 17:37
DRY factories
if I have spec/factories and features/factories then is it all dry
eg I only need to add a factory used by rspec and cucumber in one of these directories?
I'd add spec/factories, see how it goes
if it doesn't 'just work', then put something like
Dir[Rails.root + "spec/factories/*.rb"].each {|f| require f}
inside a features/support/factory_girl.rb file
@markfeedly
markfeedly / gist:7609608
Created November 23, 2013 01:27
rebuild the (test) db from db/schema.rb
rake db:drop
rake db:setup
rake db:test:prepare
@markfeedly
markfeedly / gist:9204300
Last active August 29, 2015 13:56
experiment with markdown slides

header 1

  • bullet
  • bullet 2

##page 2

  • Some Ruby code examples
['a', 'b'].map { |x| x.uppercase }
@markfeedly
markfeedly / commit_msg.rb
Last active August 29, 2015 13:56
simple webapp for the kids
require 'sinatra'
require 'open-uri'
get '/' do
@result = open("http://whatthecommit.com/index.txt").read
erb :index
end
__END__
mark@T410s-a:~/01rails/virtual-museum$ cucumber
WARN: Unresolved specs during Gem::Specification.reset:
tzinfo (~> 0.3.37)
minitest (~> 4.2)
arel (~> 4.0.0)
polyglot (>= 0.3.1)
rake (>= 0.8.7)
sprockets (~> 2.8)
atomic (< 2, >= 1.1.7)
WARN: Clearing out unresolved specs.
@markfeedly
markfeedly / warehouse.rb
Created March 28, 2014 15:30
Intro to testing using RSpec for 1-UP workshop
require 'rspec/autorun'
class WareHouse
attr_reader :quantity
def initialize
@quantity = 0
end
end
@markfeedly
markfeedly / suth
Created April 5, 2014 22:03
sutherland input
For someone who denies being able to see into the future, Sutherland has a remarkable record of helping to create it. In the late 1960s, the Bell Helicopter Company used low-light cameras to help pilots land at night, and devised a system which turned the camera when the pilot turned his head. Sutherland, by then a professor at the University of Utah, wondered why the camera couldn’t be replaced with a computer. With the assistance of Bob Sproull, he created a gizmo — with the wonderful name The Sword of Damocles — which let a user peer into a computer-generated graphical display which, like Bell’s remote camera, adjusted automatically to head turns.
[http://timenerdworld.files.wordpress.com/2013/04/image2.jpg 640]
@markfeedly
markfeedly / frustrating
Last active August 29, 2015 13:58
my crap metaprogramming
# so I want to dry up this kind of method, which occurs only four times, but since I anticipate using this construct a few more times, and page.rb is looking long, the effort of metaprogramming seems worthwhile
# with I guess moving the defn of spec attr acessor out into an included module
# so here is the code to dry, shown for categories
def categories=(c)
if history.last.try(:new_record?)
history.last.categories = c
else
OK Ive created a Subscription model, and expect somewhat to hang stuff off there
class Subscription < ActiveRecord::Base
belongs_to :user
belongs_to :page
end
There is an indexed id in the table cause I created it thus
class CreateSubscriptionsTable < ActiveRecord::Migration
@markfeedly
markfeedly / deviseblues
Created July 3, 2014 08:04
problem invoking devise effectively from a controller
current code https://github.com/markfeedly/social-museum/tree/update-mail
rake routes
user_session POST /users/sign_in(.:format) devise/sessions#create
devise sessions controller
# POST /resource/sign_in
def create