Not the best I've ever done, but I had to write something... A ruby implementation of the OAuth2 protocol for third party roles, enjoy!
http://goo.gl/UbHxI
Tech stuff around computer programming, basically for web development, especially opensource. Topics will go round Ruby on Rails (git gems etc.), Ubuntu (admin and basic shell) and work organization (agile philosophy)
Saturday, 12 January 2013
Saturday, 5 January 2013
extend vs include
I always make confusion, although I'm getting better, this should help:
module MainMod
module SubMod
def self.included(cls)
puts "#{self} included in #{cls}"
cls.extend ClassMethods
end
module ClassMethods
def ext
puts 'extended'
end
end
def inc
puts 'included'
end
end
end
class A
include MainMod::SubMod # => MainMod::SubMod included in A
end
A.new.inc
A.ext
module Mod1
inc MainMod::SubMod
end
class B
inc Mod1 # => MainMod::SubMod included in Mod1 !!!(Mod1)
end
B.new.inc
# B.ext # does not exists, `ext` was extended on Mod1
Tuesday, 25 September 2012
Browser Wars
Waiting for ie, at least 7, but ideally all of them, to die
Monday, 6 August 2012
The easiest, fastest and safest way to get your ip address
Tuesday, 31 July 2012
Change the db with migrations on the fly
What if you want to add a column though the console with one line of code? (and you exactly know what this implies)
ActiveRecord::Migration.new.add_column :payments, :card_verification, :string, limit: 8 ActiveRecord::Migration.new.execute "full sql here"
Saturday, 14 July 2012
Coffescript rendering
The correct way to render html inside your XHR response in Rails.
app.showFlashMessages('<%=j flash_messages %>')
$('.booking').replaceWith( '<%=j render @booking %>' )
app.myFunction( <%=raw array.map(&:to_json) %> ) # TODO: double check
Monday, 4 June 2012
backtrace_silencers to clean the development log from missing assets
# /config/initializers/backtrace_silencers.rb
Rails.backtrace_cleaner.add_silencer { |line| line =~ /lib\/action_dispatch\/middleware\/static.rb/ } if Rails.env.development?
This simple line will clean up your development log to something like this:
[FTL] ActionController::RoutingError (No route matches [GET] "/assets/ecoologic/rooms/room_tb.png"): actionpack (3.2.5) lib/action_dispatch/middleware/static.rb:62:in `call'
This is only in development (or test?) as you usually don't use the static middleware in staging or production.
Subscribe to:
Posts (Atom)