Skip to content

Instantly share code, notes, and snippets.

@ahoward
Created February 15, 2012 21:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahoward/1838996 to your computer and use it in GitHub Desktop.
Save ahoward/1838996 to your computer and use it in GitHub Desktop.
1) Consider the following HTML:
<div id="content" class="foo">
<div class="bar">
<a href="/foobar">Foobar</a>
</div>
</div>
And the CSS for this page is:
#content a {
color: red;
}
.foo .bar a {
color: blue;
}
What color is the link and why?
purple.
red. i spose id is more selective that classes.
2) What's the illusion that text shadows, box shadows, and gradients allow web designers to create?
depth.
3) In HTML5, does the "type" attribute need to be declared on SCRIPT and STYLE tags (ie., "type=text/javascript" or "type=text/css")?
yes. but it does not have to be a known type. if un-known, it will be
ignored.
4) In the "lean startup method", how is success defined?
no muda. no work or processes that do not support the product.
5) Match the following rendering engines with their corresponding browsers:
Presto IE
Webkit Opera
Gecko Safari
Trident Chrome
Firefox
1) write a javascript class, called 'Foo', with a class method 'bar' and an
instance method 'bar'
var Foo = function(){
this.x = 42 // instance variable
};
Foo.prototpe.bar = function(){}; // instance method
Foo.bar = function(){}; // class method
var foo = new Foo();
2) write a ruby class, called 'Foo', and a mixin, 'Bar', that adds a
*class_method* 'baz' and an *instance_method* 'baz'
#
#
#
class Foo
end
#
# one method...
#
module Bar
module InstanceMethods
def baz
end
end
module ClassMethods
def baz
end
end
def Bar.included(other)
super
ensure
other.send(:include, InstanceMethods)
other.send(:extend, ClassMethods)
end
end
#
# another method...
#
module Bar
def Bar.included(other)
super
ensure
other.module_eval do
class << other
def baz
end
end
def baz
end
end
end
end
foo = Foo.new
foo.baz
Foo.baz
3) what's wrong with this code
buffer.match( /^foo.*bar/ )
it does exponential backtracking
4) what's wrong with this code
class Farm
include Mongoid::Document
before_save do |farm|
farm.ensure_no_blank_comments!
end
def ensure_no_blank_comments!
errors.add('teh comments are fubar') if
comments.any?{|comment| comment.content.blank?}
end
class Comment
embedded_in :farm
field :content, String
end
embeds_many :comments
end
farm = Farm.find(id)
params = { :content => nil }
comment = farm.comments.build(params)
comment.save!
callbacks only fire on the object being saved. in this case our well
intentioned callback on the farm object is not triggered by saving an
embedded comment.
Suggested Reading:
* http://guides.rubyonrails.org/
* http://projects.dojo4.com/documents/94
* http://projects.dojo4.com/documents/47
* http://projects.dojo4.com/documents/10
Assignment:
* bring a piece of code that is re-usable you've written @dojo4. show and tell on tuesday.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment