Skip to content

Instantly share code, notes, and snippets.

View gravis's full-sized avatar

Philippe Lafoucrière gravis

View GitHub Profile
@gravis
gravis / test_helper.rb
Created February 10, 2010 15:58
Don't enqueue Jobs in test, redis will fail fetching non-existing objects
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
require 'authlogic/test_case'
class ActiveSupport::TestCase
[...]
end
module Resque
class UpdateConfirmedUserView < ActiveRecord::Migration
self.up
execute <<-EOF
CREATE OR REPLACE VIEW confirmed_user AS
SELECT * FROM users WHERE confirmed_at IS NOT NULL
AND disable IS FALSE;
EOF
end
@gravis
gravis / factory_girl_step_helpers.rb
Created September 10, 2012 08:04 — forked from danivovich/factory_girl_step_helpers.rb
Factory Girl steps for Turnip
module FactoryGirlStepHelpers
def convert_human_hash_to_attribute_hash(human_hash, associations = [])
HumanHashToAttributeHash.new(human_hash, associations).attributes
end
class HumanHashToAttributeHash
attr_reader :associations
def initialize(human_hash, associations)
@human_hash = human_hash
@gravis
gravis / collector_transaction.rb
Created August 6, 2012 08:06
A secure event tracking system for online betting in France
# Copyright © 2010-2011 Tech-Angels. All Rights Reserved.
# CollectorTransaction will be created each time the Collector needs
# to trace an activity.
#
# Attributes:
# * id [integer, primary, not null] - primary key
# * before_tr [binary] - associated model serialized before transaction
# * created_at [datetime] - creation time
# * model_id [integer] - belongs_to Model (polymorphic)
@gravis
gravis / Questions
Created August 9, 2011 08:23
Frozen Rails Give-away
Day job: CEO @ Tech-Angels.fr
Your Rails contributions (if any): a few bugs reporting/squashing
What's your Ruby/Rail experience?: Since 1.0, so a few years :)
How do you use GitHub?: Professionnaly to host our projects sources and configurations, personally to serve^h^h^h^h^hfork and protect^h^h^h^h^hhack
select orders.user_id,
email,
sum(stake) as mises_perdantes,
5.00 as bonus
from bets
join orders on orders.id = bets.order_id
join users on orders.user_id = users.id
join races on races.id = bets.race_id
where races.start_time::date BETWEEN '2011-04-29' AND '2011-04-30'
and bets.status = 'paid'
>> Event.find(123).participants.ascend_by_number
[works]
>> Event.find(123).participants.published.all(:order => :number)
[works]
>> Event.find(123).participants.published.ascend_by_number
[returns the whole table until memory is full and server crash]
SQL :
SELECT * FROM "events" WHERE ("events"."id" = 123)
rvm update --trace
--trace
rvm 1.0.15 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]
+__rvm_parse_args:416> [[ -z 4.3.9 ]]
+__rvm_parse_args:572> [[ -z update ]]
+__rvm_parse_args:574> [[ 0 -eq 1 || -n '' ]]
+__rvm_parse_args:15> [[ -n '' ]]
+__rvm_parse_args:578> [[ 0 -gt 0 ]]
@gravis
gravis / readme
Created September 26, 2010 17:26
tcp syslog logger for rails draft
tcp_syslog is now a gem :
https://github.com/tech-angels/tcp_syslog
@gravis
gravis / Dockerfile
Last active September 22, 2015 18:43
Docker Volume sharing
FROM docker:5000/wheezy-ruby
# install deps
RUN apt-get install -y qt4-qmake libqtwebkit-dev libcurl4-openssl-dev
RUN mkdir -p /bundle /rails
RUN apt-get install -y ssh
RUN mkdir -p /var/run/sshd