Skip to content

Instantly share code, notes, and snippets.

View markfeedly's full-sized avatar

Mark van Harmelen markfeedly

View GitHub Profile
@markfeedly
markfeedly / pesky
Last active August 29, 2015 14:12
pesky sql not enough rails knowledge
If we have nils for taggable_id in tag_items, then when I go to
http://localhost:3000/collection_items/b
the server log looks OK, like this (hey I only put this in for comparison,
no need to read it (yet?)), skip on below
~/01rails/social-museum 0 $ rails s
=> Booting Puma
=> Rails 4.1.4 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
@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
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 / 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
@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 / 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
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 / 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__
@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 / 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