Skip to content

Instantly share code, notes, and snippets.

View shingara's full-sized avatar

Cyril Mougel shingara

  • regate.io
  • Pau ( France )
View GitHub Profile
require 'spec_helper'
describe "Issue with default_scope and eager loading" do
class Post
include Mongoid::Document
belongs_to :blog
end
class Blog
include Mongoid::Document
require 'backports'
class Hello
def failed_with_backports
private_methods.grep(/(.+)_copy$/) { raise StandardError if $1 == nil }
end
end
Hello.new.failed_with_backports
@shingara
shingara / issue_1973_spec.rb
Created May 3, 2012 14:03
Issue 1973 from Mongoid
require 'spec_helper'
describe "Issue 1973" do
class Match
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :user1, :class_name => "User", :inverse_of => 'hosted_matches' belongs_to :user2, :class_name => "User", :inverse_of => 'invited_matches'
end
@shingara
shingara / import_attachment_basecamp.rb
Created April 19, 2012 13:01
Script to download all attachments from a basecamp project
require 'faraday'
require 'faraday_middleware'
url_project = 'https://ciblonet.basecamphq.com'
project_id = 3684800
user_name = 'shingara'
password = 'xxxx'
class Attachment
@shingara
shingara / gist:1977573
Created March 5, 2012 09:05
Plizzy problem :(
Hi,
I am shingara on twitter. And I have a little chat with you on
twitter. I have always issue on Plizy with youtube video.
After some investigation, I see my problem arrive in most of the time
on in my home where I have free as provider ( in France ). I know
there are some issue on Free and youtube peering. But I can see
youtube video on my Device ( Galaxy Tab 10.1 GT-P7510 ). I test on
Orange provider and some video are not available. But not at all.
require 'benchmark'
array = []
1_000.times do
x = []
100.times do
x << [1,10]
end
array << x
end
@shingara
shingara / mix_periods.rb
Created February 29, 2012 11:35
Method to compare if some periods define by start_date and end_date are mixed
def mix_periods
list_period = seasons.inject([]) do |acc, season|
season.periods.each do |period|
acc << (period.start_date..period.end_date)
end
acc
end
while !list_period.empty?
period_test = list_period.pop
source "https://rubygems.org"
gem 'mechanize'
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/vimbundle/bundle/vundle/
call vundle#rc()
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-git'
Bundle 'tpope/vim-haml'
Bundle 'pangloss/vim-javascript'
def self.dragonfly(config_file)
require 'oahu_models/image_magick_processor'
config_file = Pathname.new(config_file)
app = Dragonfly[:oahu]
app.configure_with(:imagemagick)
app.define_macro_on_include(Mongoid::Document, :image_accessor)
app.processor.register(Oahu::Models::ImageMagickProcessor)