Skip to content

Instantly share code, notes, and snippets.

You good?

Jean-Denis Vauguet chikamichi

You good?
View GitHub Profile
chikamichi / init.rb
Created July 27, 2009 01:18
Marshalization plugin: how to override an instance private method from ActiveRecord::Dirty
View init.rb
# rails/init.rb
require 'marshalize'
ActiveRecord::Base.send(:include, Marshalization::Base)
ActiveRecord::Base.send(:include, Marshalization::AttributeMethods)
ActiveRecord::Base.send(:include, Marshalization::Dirty)
View I'd like to...
- use respond_to (or something else?) in send_data to externalize the .js processing, in the same fashion one would use a .rjs file.
- be able to use :method => "get" without triggering the show action.
chikamichi / hello
Created December 28, 2009 14:20
rackcodehighlighter, ultraviolet and maruku
View hello
actually it's views/, but gist would trigger Markdown highlighting
# Fibonacci numbers in Ruby
def fib(n)
if n < 2
fib(n-2) + fib(n-1)
chikamichi / Gemfile
Created March 10, 2010 00:58
rails3 + cucumber ok
View Gemfile
source ''
gem "rails", "3.0.0.beta"
gem "sqlite3-ruby", :require => "sqlite3"
gem "test-unit"
gem "rspec-rails", ">= 2.0.0.beta.1"
gem 'capybara'
gem 'database_cleaner'
chikamichi / gem list
Created March 10, 2010 01:44
rails3 + cucumber fail
View gem list
$ gem list
*** LOCAL GEMS ***
abstract (1.0.0)
actionmailer (3.0.0.beta)
actionpack (3.0.0.beta)
activemodel (3.0.0.beta)
activerecord (3.0.0.beta)
activeresource (3.0.0.beta)
View log nested
# no explicit reference to web_steps
# that is, features/authentication/step_definitions/authentication_steps.rb contains:
Given /^I am not authenticated$/ do
# do nothing
$ cucumber features/authentication/authentication.feature
Using the default profile...
Feature: User authentication
To ensure the safety of the application
chikamichi / base.rb
Created March 21, 2010 02:12
plugins system: nested
View base.rb
# ./base.rb
require 'base/plugins'
module Base
class Server
include Plugins
def say(what)
p "say: #{what}"
chikamichi / plugins_standalone.rb
Created March 21, 2010 02:07
plugins system: standalone
View plugins_standalone.rb
module Base
class Server
def blabla(argument)
@config ||= "default"
if @config == "default"
p "Server says: #{argument}"
puts "config: #{@config}"
View plugins.rb
module Base
module Plugins
def self.plugins
@plugins ||= []
def self.activate plugin_name
plugin = Base::Plugins.const_get(plugin_name.capitalize)
chikamichi / do.rb
Created March 26, 2010 13:57
dynamic instances extending mechanism for Metamorphosis
View do.rb
require 'facets/kernel/constant'
require 'active_support/core_ext/module/attribute_accessors'
module Metamorphosis
module Injector
@@receiver = "Foo"
def clutch cst_path, *directives, &blk
raise ArgumentError unless cst = Object.constant([@@receiver, cst_path].join("::"))
raise ArgumentError unless cst.is_a? Class or cst.is_a? Module