This file contains hidden or 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
| - @artworks.each do |artwork| | |
| %li.to-masonify | |
| .burst | |
| = link_to artwork do | |
| .image | |
| = image_tag(artwork.image.url(:medium), :size => artwork.image.image_size(:medium)) | |
| .burst-actions | |
| .burst-like | |
| %a.btn.btn-small(href="#") | |
| %i.icon-heart |
This file contains hidden or 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
| image = Magick::Image.read("https://s3.amazonaws.com/artburst-dev/artworks/medium/1/bubblegun.jpg").first | |
| hist = image.quantize(8).color_histogram | |
| pixels_array = [] | |
| pixels = hist.keys.sort_by {|pixel| hist[pixel]} | |
| pixels.each { |pixel| pixels_array << [ pixel.to_color(Magick::AllCompliance,false,8), hist[pixel] ] } | |
| pixels_array.reverse! | |
| pixels_array[0] # ["#34689A", 42766] |
This file contains hidden or 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 'rmagick' | |
| colors = ["#660000", "#990000", "#cc0000", "#cc3333", "#ea4c88", | |
| "#993399", "#663399", "#333399", "#0066cc", "#0099cc", "#66cccc", | |
| "#77cc33", "#669900", "#336600", "#666600", "#999900", "#cccc33", | |
| "#ffff00", "#ffcc33", "#ff9900", "#ff6600", "#cc6633", "#996633", | |
| "#663300", "#000000", "#999999", "#cccccc", "#ffffff"]; | |
| def convert_rgb_to_xyz(r, g, b) | |
| var_R = ( r / 255.0 ) # RGB from 0 to 255 |
This file contains hidden or 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 'rmagick' | |
| def convert_rgb_to_xyz(r, g, b) | |
| var_R = ( r / 255.0 ) # RGB from 0 to 255 | |
| var_G = ( g / 255.0 ) | |
| var_B = ( b / 255.0 ) | |
| if ( var_R > 0.04045 ) | |
| var_R = ( ( var_R + 0.055 ) / 1.055 ) ** 2.4 | |
| else |
This file contains hidden or 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
| colors = ArtworkColor.select("DISTINCT ON (artwork_id) artwork_id, original_color, frequency").where(:reference_color=>"#0099CC") | |
| ArtworkColor Load (0.8ms) SELECT DISTINCT ON (artwork_id) artwork_id, original_color, frequency FROM "artwork_colors" WHERE "artwork_colors"."reference_color" = '#0099CC' | |
| => [#<ArtworkColor artwork_id: 1, original_color: "#34689A", frequency: 81.4>, | |
| #<ArtworkColor artwork_id: 2, original_color: "#00ACED", frequency: 82.4>, | |
| #<ArtworkColor artwork_id: 5, original_color: "#3D6192", frequency: 24.9>, | |
| #<ArtworkColor artwork_id: 8, original_color: "#6691AF", frequency: 16.5>, | |
| #<ArtworkColor artwork_id: 13, original_color: "#287583", frequency: 21.5>] |
This file contains hidden or 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
| # Use CMC(2:1) | |
| l = 2 | |
| c = 1 | |
| c1 = sqrt( (a1 ** 2) + (b1 ** 2) ) | |
| c2 = sqrt( (a2 ** 2) + (b2 ** 2) ) | |
| delta_l = l1 - l2 | |
| delta_a = a1 - a2 | |
| delta_b = b1 - b2 |
This file contains hidden or 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
| = link_to(comment_create_comment_vote_path(@comment, :comment_vote => { :comment_id => @comment.id, :user_id => current_user.id, :vote_flag => true }), {:method => :post, :remote => true, :class => 'like-comment'}) do | |
| %i.icon-thumbs-up | |
| %span.helpful-text Mark helpful |
This file contains hidden or 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
| Completed 500 Internal Server Error in 4ms | |
| ActiveModel::MassAssignmentSecurity::Error (Can't mass-assign protected attributes: tag): | |
| activemodel (3.2.8) lib/active_model/mass_assignment_security/sanitizer.rb:48:in `process_removed_attributes' | |
| activemodel (3.2.8) lib/active_model/mass_assignment_security/sanitizer.rb:20:in `debug_protected_attribute_removal' | |
| activemodel (3.2.8) lib/active_model/mass_assignment_security/sanitizer.rb:12:in `sanitize' | |
| activemodel (3.2.8) lib/active_model/mass_assignment_security.rb:230:in `sanitize_for_mass_assignment' | |
| activerecord (3.2.8) lib/active_record/attribute_assignment.rb:75:in `assign_attributes' | |
| activerecord (3.2.8) lib/active_record/base.rb:498:in `initialize' | |
| cancan (1.6.8) lib/cancan/controller_resource.rb:85:in `new' |
This file contains hidden or 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_for(:artwork_tag, :url => "/artworks/#{@artwork.id}/tags/create", :html => { :method => :create, :class => 'form-horizontal' }, :remote => true) do |f| | |
| .control-group | |
| = f.hidden_field :artwork_id, :value => @artwork.id | |
| = f.hidden_field :user_id, :value => current_user.id | |
| = f.text_field :tag, :class => "input-medium" | |
| = f.submit "Add Tag", :class => "btn btn-small btn-primary" |
This file contains hidden or 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 Ability | |
| include CanCan::Ability | |
| def initialize(user) | |
| user ||= User.new # guest user (not logged in) | |
| can :manage, User, :id => user.id | |
| can :manage, Comment, :user_id => user.id | |
| can :manage, CommentVote, :user_id => user.id | |
| can :read, :all |