Skip to content

Instantly share code, notes, and snippets.

View elentras's full-sized avatar
🐱

Jeremy Le Massu elentras

🐱
View GitHub Profile
class Issue < ActiveRecord::Base
has_many :line_items, :as => :itemable
has_many :orders, :through => :line_items
end
@elentras
elentras / streaming.rb
Created November 6, 2012 10:23
My comments usage uppon method Comments example
# 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 November 12, 2012 14:31
Looking for the best way to request sql stats over years for each sellers from my db
@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 November 14, 2012 09:18
My index file : Triing to apply simplify render in views (best practice)
<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 November 20, 2012 17:13
Problemns with module classes for rspec testing
~/.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 December 11, 2012 09:16
Getting troubles with routes and locales, getting an exception on one route, sound strange...
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
@elentras
elentras / dabblet.css
Last active December 15, 2015 18:09
Untitled
.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 12:04
unicorn error in logs about mongo gem not found ?!
/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 November 28, 2014 08:38
Verifying that +elentras is my openname (Bitcoin username). https://onename.io/elentras
Verifying that +elentras is my openname (Bitcoin username). https://onename.io/elentras