Skip to content

Instantly share code, notes, and snippets.

Avatar
🐱

Jeremy Le Massu elentras

🐱
  • Effy - Pacte Énergie Solidarité
  • Paris, France
View GitHub Profile
View issue.rb
class Issue < ActiveRecord::Base
has_many :line_items, :as => :itemable
has_many :orders, :through => :line_items
end
@elentras
elentras / streaming.rb
Created Nov 6, 2012
My comments usage uppon method Comments example
View streaming.rb
# This module generate methods to generate video's fluxes
# before signing it and request it.
module DMCloud
class Streaming
# Get media url for direct link to the file on DailyMotion Cloud
# Params :
# media_id: this is the id of the media (eg: 4c922386dede830447000009)
# asset_name: the name of the asset you want to stream (eg: mp4_h264_aac)
@elentras
elentras / my_stats.rb
Created Nov 12, 2012
Looking for the best way to request sql stats over years for each sellers from my db
View my_stats.rb
@top_sellers = Turnover.
joins(:seller).
select('SUM(turnovers.amount) AS total_current_year, SUM(turnovers.amount) AS total_last_year, sellers.*').
where('turnovers.year = ?', 2013).
group('turnovers.seller_id').
order('total_current_year DESC').
limit(5)
@worst_sellers = Turnover.
joins(:seller).
@elentras
elentras / _article.html.erb
Created Nov 14, 2012
My index file : Triing to apply simplify render in views (best practice)
View _article.html.erb
<div class="article" data-ref="<%= article.id %>" data-text="<%= article.synopsis? %>" data-video="<%= article.video? %>">
<div class="img">
<%= image_tag(article.image.url(:panorama), :class => 'color') %>
</div>
</div>
@elentras
elentras / error_returned
Created Nov 20, 2012
Problemns with module classes for rspec testing
View error_returned
~/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -S rspec spec/dm_cloud/media_spec.rb spec/dm_cloud/streaming_spec.rb spec/dm_cloud_spec.rb
~/Projects/dm_cloud/spec/dm_cloud/media_spec.rb:4:in `<top (required)>': uninitialized constant DMCloud (NameError)
@elentras
elentras / application_controller.rb
Created Dec 11, 2012
Getting troubles with routes and locales, getting an exception on one route, sound strange...
View application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
@language = I18n.locale
end
end
View dabblet.css
.grey_next_button {
float: left;
position: relative;
min-height: 30px;
line-height: 30px;
min-width: 20px;
border: solid 1px #ccc;
border-right: none;
background: #eee linear-gradient(white, #f1f1f1 37%, #e1e1e1 57%, #f6f6f6);
cursor: pointer;
@elentras
elentras / unicorn.log
Created May 1, 2013
unicorn error in logs about mongo gem not found ?!
View unicorn.log
/data/www/firefly/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:317:in `rescue in depend_on'/data/www/firefly/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:317:in `rescue in depend_on': No such file to load -- mongo (LoadError)
from /data/www/firefly/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:312:in `depend_on'
from /data/www/firefly/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:225:in `require_dependency'
from /data/www/firefly/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
from /data/www/firefly/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:438:in `each'
from /data/www/firefly/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:438:in `block in eager_load!'
from /data/www/firefly/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:436
@elentras
elentras / gist:6f52ccb9a1f22d7aee7d
Created Nov 28, 2014
Verifying that +elentras is my openname (Bitcoin username). https://onename.io/elentras
View gist:6f52ccb9a1f22d7aee7d
Verifying that +elentras is my openname (Bitcoin username). https://onename.io/elentras