Skip to content

Instantly share code, notes, and snippets.

Avatar
🙈
Meh, can't see me

Jean-Denis Vauguet chikamichi

🙈
Meh, can't see me
View GitHub Profile
@chikamichi
chikamichi / init.rb
Created Jul 27, 2009
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
chikamichi / hello
Created Dec 28, 2009
rackcodehighlighter, ultraviolet and maruku
View hello
actually it's views/hello.md, but gist would trigger Markdown highlighting
# Fibonacci numbers in Ruby
:::ruby
def fib(n)
if n < 2
1
else
fib(n-2) + fib(n-1)
@chikamichi
chikamichi / Gemfile
Created Mar 10, 2010
rails3 + cucumber ok
View Gemfile
source 'http://gemcutter.org'
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
chikamichi / gem list
Created Mar 10, 2010
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
end
$ cucumber features/authentication/authentication.feature
Using the default profile...
Feature: User authentication
To ensure the safety of the application
@chikamichi
chikamichi / plugins_standalone.rb
Created Mar 21, 2010
plugins system: standalone
View plugins_standalone.rb
module Base
class Server
def blabla(argument)
@config ||= "default"
if @config == "default"
p "Server says: #{argument}"
end
puts "config: #{@config}"
@chikamichi
chikamichi / base.rb
Created Mar 21, 2010
plugins system: nested
View base.rb
# ./base.rb
require 'base/plugins'
module Base
class Server
include Plugins
def say(what)
p "say: #{what}"
View plugins.rb
module Base
module Plugins
def self.plugins
@plugins ||= []
end
def self.activate plugin_name
begin
plugin = Base::Plugins.const_get(plugin_name.capitalize)
rescue
@chikamichi
chikamichi / do.rb
Created Mar 26, 2010
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