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
=begin | |
notice there is no space at the beginning of =begin | |
code or | |
#comment | |
. | |
. | |
. | |
=end | |
=begin |
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
#app/models/user.rb | |
class User < ActiveRecord::Base | |
has_many :authorizations, :dependent => :destroy | |
end | |
#app/models/authorization.rb | |
class Authorization < ActiveRecord::Base | |
belongs_to :user | |
validates_presence_of :user_id, :uid, :provider | |
validates_uniqueness_of :uid, :scope => :provider |
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
#/app/models/user.rb | |
class User < ActiveRecord::Base | |
has_many :authorizations, :dependent => :destroy | |
def self.create_from_hash(hash) | |
create(:username => hash['user_info']['name']) | |
end | |
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
var msie6 = $.browser == 'msie' && $.browser.version < 7; | |
if (!msie6) { | |
// 'bar' is the id of the box which needs to be fixed | |
var top = $('#bar').offset().top - parseFloat($('#bar').css('margin-top').replace(/auto/, 0)); | |
$(window).scroll(function (event) { | |
var y = $(this).scrollTop(); | |
if (y >= top) { | |
// if so, add the fixed class | |
$('#bar').addClass('fixed'); |
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
$('.default-value').each(function() { // '.default-value' is the class for your fields having default values | |
var default_value = this.value; | |
$(this).css('color', '#999'); // this could be in the style sheet instead | |
$(this).focus(function() { | |
if(this.value == default_value) { | |
this.value = ''; | |
$(this).css('color', '#333'); | |
} | |
}); | |
$(this).blur(function() { |
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
require 'open-uri' |
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
<form id="imagesearch" action="/modelname/imagesearch" method="post" > | |
Search for an image | |
<input type="text" name="query" class="floatleft" /> | |
<input type="submit" name="submit" value="submit"/> | |
</form> | |
<center> | |
<div id="imageresults"></div> | |
</center> |
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
searchd --pidfile --config config/development.sphinx.conf |