Skip to content

Instantly share code, notes, and snippets.

View alxlion's full-sized avatar
🏗️
Building

Alexandre Lion alxlion

🏗️
Building
View GitHub Profile
@alxlion
alxlion / respond_to_meta_ex_2.rb
Created August 21, 2020 19:57
Respond_to Metaprogramming example 2
s = Shipment.new
if s.respond_to?(:cancel_shipping)
s.cancel_shipping
else
puts "Oh no ! Shipment cannot be cancel."
end
@alxlion
alxlion / send_meta_ex.rb
Created August 21, 2020 19:59
Send Metapramming Example
s = Shipment.new
if s.respond_to?(:tracking_code)
s.send(:tracking_code, '123ABC') # or s.send('cancel_shipping', '123ABC')
else
puts "Tracking code is not available."
end
@alxlion
alxlion / define_method_meta_ex.rb
Created August 21, 2020 20:01
Define_method Metaprogramming example
class Shipment
define_method :cancel do |reason|
@cancelled = true
puts reason
end
end
@alxlion
alxlion / metaprogramming_ruby_ex.rb
Last active August 21, 2020 20:04
Metaprogramming ruby example
# We create a container class. We only store the product's name at instantiation
class Container
attr :product_name
def initialize(name)
@product_name = name
end
end
@alxlion
alxlion / ips.txt
Created January 29, 2024 09:58
ip_block_weytop
1.12.14.0/23
1.12.32.0/23
1.14.0.0/15
1.44.96.0/24
1.116.0.0/15
1.178.32.0/19
1.247.4.0/24
1.255.30.0/24
2.56.8.0/23
2.56.16.0/22