Archive for the 'Altres' Category

Receptes en Ruby: extendre metodes sense perdre el codi d

The 2018 World Cup is fast approaching, with national sides making their final preparations ahead of this summer’s tournament.

We now know the groups after December’s draw. England have been put together with Belgium, Tunisia and Panama in Group G.

Gareth Southgate’s side were not among the top seeds, meaning they featured in pot two during the proceedings.

And with England’s route now mapped out, Southgate will be able to ramp up preparations for the 2018 tournament. 2018 World cup, football News ,Gaming ,Betscore ,Casino …..Sports.vin

Ruby recipie: extending methods without loose the original code

Supose you want to extend the method of a class called Attachment.

# original_file.rb

class Attachment
  def method_to_extend
    puts "The original code"
  end
end

If we try to rewrite the method, older code gets lost, but instead we want it to be executed with our code extension

We want to achieve something like the following:

class Attachment
  def method_to_extend
    puts "The original code"
    puts "My extension code!"
  end
end

But the original code is part of a library we cannot change directly.

The best way I found is to write an alias_method with the original method code and rewrite the method adding the desired code

# extension_file.rb

require 'original_file'
class Attachment
  alias_method :source_method_to_extend, :method_to_extend
  def method_to_extend
    source_method_to_extend
    puts "My extension code!"
  end
end

Com cercar text amb el Safari de l'iphone?

Doncs és molt senzill però poc intuitiu.

Principalment has de fer com si cerquessis a google amb el requadre del costat de la barra d'adreces.

Escrius la paraula a cercar i et mostrarà les ocurrències dins la pàgina.

Tires cap avall i la última opció és cercar dins la pàgina.

Salta cap a les diferents ocurrències del text.