Ruby provides various ways to define and manipulate methods. Methods can be defined on classes, objects, and singleton classes. Singleton classes allow defining methods that are only available to a specific object. Ruby also supports currying methods to return procs that can later be called. Methods can be aliased, undefined, or dynamically defined/manipulated at runtime using techniques like eval, instance_eval, and reflection. Classes in Ruby are also objects that can have singleton classes and methods defined on them.
A tour of Python: slides from presentation given in 2012.
[Some slides are not properly rendered in SlideShare: the original is still available at http://www.aleksa.org/2015/04/python-presentation_7.html.]
I gave this presentation on January 14, 2010 to the Atlanta Scala user group. It covers Scala's implementation of operator overloading, as well as touching on implicit conversions.
Object Equality In Scala, means comparing two objects by their values and references.Generally, equality is ubiquitous in programming. It is also more tricky than it looks at first glance. This presentation looks at object equality in detail and gives some recommendations to consider when we design our own equality tests.
A tour of Python: slides from presentation given in 2012.
[Some slides are not properly rendered in SlideShare: the original is still available at http://www.aleksa.org/2015/04/python-presentation_7.html.]
I gave this presentation on January 14, 2010 to the Atlanta Scala user group. It covers Scala's implementation of operator overloading, as well as touching on implicit conversions.
Object Equality In Scala, means comparing two objects by their values and references.Generally, equality is ubiquitous in programming. It is also more tricky than it looks at first glance. This presentation looks at object equality in detail and gives some recommendations to consider when we design our own equality tests.
Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation. Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods. Subclasses of an abstract class in Python are not required to implement abstract methods of the parent class.
In this chapter we will explore strings. We are going to explain how they are implemented in Java and in what way we can process text content. Additionally, we will go through different methods for manipulating a text: we will learn how to compare strings, how to search for substrings, how to extract substrings upon previously settled parameters and last but not least how to split a string by separator chars. We will demonstrate how to correctly build strings with the StringBuilder class. We will provide a short but very useful information for the most commonly used regular expressions.
Monads, also known as Kleisli triples in Category Theory, are an (endo-)functor together with two natural transformations, which are surprisingly useful in pure languages like Haskell, but this talk will NOT reference monads. Ever. (Well, at least not in this talk.)
Instead what I intend to impress upon an audience of newcomers to Haskell is the wide array of freely available libraries most of which are liberally licensed open source software, intuitive package management, practical build tools, reasonable documentation (when you know how to read it and where to find it), interactive shell (or REPL), mature compiler, stable runtime, testing tools that will blow your mind away, and a small but collaborative and knowledgeable community of developers. Oh, and some special features of Haskell - the language - too!
Inspired by Josh Bloch's Java Puzzlers, we put together our own Python Puzzlers. This slide deck brings you a set of 10 python puzzlers, that are fun and educational. Each puzzler will show you a piece of python code. Your task if to figure out what happens when the code is run. Whether you're a python beginner or a passionate python veteran, we hope that there's something to learn for everybody.
This slide deck was first presented at shopkick. Nandan Sawant and Ryan Rueth are engineers at shopkick. Keeping the audience in mind, most of the puzzlers are based on python 2.x.
A class is a code template for creating objects. Objects have member variables and have behaviour associated with them. In python a class is created by the keyword class.
An object is created using the constructor of the class. This object will then be called the instance of the class.
Slides from my PyCon 2011 talk, "Exhibition of Atrocity," a confessional of my sins against the Python programming language.
Abstract: http://us.pycon.org/2011/schedule/presentations/138/
Video: http://www.pycon.tv/#/video/49
In functional programming, words from Category Theory are thrown around, but how useful are they really?
This session looks at applications of monoids specifically and how using their algebraic properties offers a solid foundation of reasoning in many types of business domains and reduces developer error as computational context complexity increases.
This will provide a tiny peak at Category Theory's practical uses in software development and modeling. Code examples will be in Haskell and Scala, but monoids could be constructed in almost any language by software craftsmen and women utilizing higher orders of reasoning to their code.
Slides from Advaned Python lectures I gave recently in Haifa Linux club
Advanced python, Part 1:
- Decorators
- Descriptors
- Metaclasses
- Multiple inheritance
We <3> true
But - still .rb < perfect # => true
Though Ruby was allegedly "engineered to maximize programmer happiness", in part by adhering to the "principle of least surprise", Ruby still has some surprising and annoying gotchas. This presention contains an Array, er, a bunch of them, from programming-newbie gotchas to ones that still "get" grizzled veteran Rubyists. The talk these are from, approximately 45 minutes, may save you many hours of frustrated head-scratching (and bashing against the desk) later!
Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation. Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods. Subclasses of an abstract class in Python are not required to implement abstract methods of the parent class.
In this chapter we will explore strings. We are going to explain how they are implemented in Java and in what way we can process text content. Additionally, we will go through different methods for manipulating a text: we will learn how to compare strings, how to search for substrings, how to extract substrings upon previously settled parameters and last but not least how to split a string by separator chars. We will demonstrate how to correctly build strings with the StringBuilder class. We will provide a short but very useful information for the most commonly used regular expressions.
Monads, also known as Kleisli triples in Category Theory, are an (endo-)functor together with two natural transformations, which are surprisingly useful in pure languages like Haskell, but this talk will NOT reference monads. Ever. (Well, at least not in this talk.)
Instead what I intend to impress upon an audience of newcomers to Haskell is the wide array of freely available libraries most of which are liberally licensed open source software, intuitive package management, practical build tools, reasonable documentation (when you know how to read it and where to find it), interactive shell (or REPL), mature compiler, stable runtime, testing tools that will blow your mind away, and a small but collaborative and knowledgeable community of developers. Oh, and some special features of Haskell - the language - too!
Inspired by Josh Bloch's Java Puzzlers, we put together our own Python Puzzlers. This slide deck brings you a set of 10 python puzzlers, that are fun and educational. Each puzzler will show you a piece of python code. Your task if to figure out what happens when the code is run. Whether you're a python beginner or a passionate python veteran, we hope that there's something to learn for everybody.
This slide deck was first presented at shopkick. Nandan Sawant and Ryan Rueth are engineers at shopkick. Keeping the audience in mind, most of the puzzlers are based on python 2.x.
A class is a code template for creating objects. Objects have member variables and have behaviour associated with them. In python a class is created by the keyword class.
An object is created using the constructor of the class. This object will then be called the instance of the class.
Slides from my PyCon 2011 talk, "Exhibition of Atrocity," a confessional of my sins against the Python programming language.
Abstract: http://us.pycon.org/2011/schedule/presentations/138/
Video: http://www.pycon.tv/#/video/49
In functional programming, words from Category Theory are thrown around, but how useful are they really?
This session looks at applications of monoids specifically and how using their algebraic properties offers a solid foundation of reasoning in many types of business domains and reduces developer error as computational context complexity increases.
This will provide a tiny peak at Category Theory's practical uses in software development and modeling. Code examples will be in Haskell and Scala, but monoids could be constructed in almost any language by software craftsmen and women utilizing higher orders of reasoning to their code.
Slides from Advaned Python lectures I gave recently in Haifa Linux club
Advanced python, Part 1:
- Decorators
- Descriptors
- Metaclasses
- Multiple inheritance
We <3> true
But - still .rb < perfect # => true
Though Ruby was allegedly "engineered to maximize programmer happiness", in part by adhering to the "principle of least surprise", Ruby still has some surprising and annoying gotchas. This presention contains an Array, er, a bunch of them, from programming-newbie gotchas to ones that still "get" grizzled veteran Rubyists. The talk these are from, approximately 45 minutes, may save you many hours of frustrated head-scratching (and bashing against the desk) later!
Slides from talk given at Ithaca Web Group and GORGES on CoffeeScript.
The focus is on explaining to people who haven't tried it yet that it's more than syntactic sugar. There are several real life code examples but they were explained verbally so they may not be super helpful if you don't know CoffeeScript yet.
It's an overview, not a tutorial.
We <3 .rb
but - still .rb < perfect
This presentation shows some of the ways that this language, engineered for maximum programmer happiness and least surprise, can still have some nasty gotchas.
A linguagem de programação Ruby - Robson "Duda" Sejan Soares DornellesTchelinux
Sobre o palestrante: Formado na UFPel no início do ano corrente, trabalhou com desenvolvimento de hardware para TV digital durante a graduação. Entretanto, sempre foi apaixonado por belas linguagens de programação, e destas, Ruby é a que mais se destaca. Atualmente aguarda o mês de junho, quando começa a trabalhar na ThoughtWorks, em Porto Alegre.
Introduction to Ruby and Introduction to Ruby on Rails basic concepts for beginners. The google presentation is even better in full screen https://docs.google.com/presentation/d/1EE0VuB_PkD2-8j5JNs6CUQHb4J9ToIgC7-IxYTojiS0/pub?start=false&loop=false&delayms=3000#slide=id.p
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...Amil Baba Dawood bangali
Contact with Dawood Bhai Just call on +92322-6382012 and we'll help you. We'll solve all your problems within 12 to 24 hours and with 101% guarantee and with astrology systematic. If you want to take any personal or professional advice then also you can call us on +92322-6382012 , ONLINE LOVE PROBLEM & Other all types of Daily Life Problem's.Then CALL or WHATSAPP us on +92322-6382012 and Get all these problems solutions here by Amil Baba DAWOOD BANGALI
#vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore#blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #blackmagicforlove #blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #Amilbabainuk #amilbabainspain #amilbabaindubai #Amilbabainnorway #amilbabainkrachi #amilbabainlahore #amilbabaingujranwalan #amilbabainislamabad
Vaccine management system project report documentation..pdfKamal Acharya
The Division of Vaccine and Immunization is facing increasing difficulty monitoring vaccines and other commodities distribution once they have been distributed from the national stores. With the introduction of new vaccines, more challenges have been anticipated with this additions posing serious threat to the already over strained vaccine supply chain system in Kenya.
Saudi Arabia stands as a titan in the global energy landscape, renowned for its abundant oil and gas resources. It's the largest exporter of petroleum and holds some of the world's most significant reserves. Let's delve into the top 10 oil and gas projects shaping Saudi Arabia's energy future in 2024.
Event Management System Vb Net Project Report.pdfKamal Acharya
In present era, the scopes of information technology growing with a very fast .We do not see any are untouched from this industry. The scope of information technology has become wider includes: Business and industry. Household Business, Communication, Education, Entertainment, Science, Medicine, Engineering, Distance Learning, Weather Forecasting. Carrier Searching and so on.
My project named “Event Management System” is software that store and maintained all events coordinated in college. It also helpful to print related reports. My project will help to record the events coordinated by faculties with their Name, Event subject, date & details in an efficient & effective ways.
In my system we have to make a system by which a user can record all events coordinated by a particular faculty. In our proposed system some more featured are added which differs it from the existing system such as security.
Courier management system project report.pdfKamal Acharya
It is now-a-days very important for the people to send or receive articles like imported furniture, electronic items, gifts, business goods and the like. People depend vastly on different transport systems which mostly use the manual way of receiving and delivering the articles. There is no way to track the articles till they are received and there is no way to let the customer know what happened in transit, once he booked some articles. In such a situation, we need a system which completely computerizes the cargo activities including time to time tracking of the articles sent. This need is fulfilled by Courier Management System software which is online software for the cargo management people that enables them to receive the goods from a source and send them to a required destination and track their status from time to time.
Forklift Classes Overview by Intella PartsIntella Parts
Discover the different forklift classes and their specific applications. Learn how to choose the right forklift for your needs to ensure safety, efficiency, and compliance in your operations.
For more technical information, visit our website https://intellaparts.com
Automobile Management System Project Report.pdfKamal Acharya
The proposed project is developed to manage the automobile in the automobile dealer company. The main module in this project is login, automobile management, customer management, sales, complaints and reports. The first module is the login. The automobile showroom owner should login to the project for usage. The username and password are verified and if it is correct, next form opens. If the username and password are not correct, it shows the error message.
When a customer search for a automobile, if the automobile is available, they will be taken to a page that shows the details of the automobile including automobile name, automobile ID, quantity, price etc. “Automobile Management System” is useful for maintaining automobiles, customers effectively and hence helps for establishing good relation between customer and automobile organization. It contains various customized modules for effectively maintaining automobiles and stock information accurately and safely.
When the automobile is sold to the customer, stock will be reduced automatically. When a new purchase is made, stock will be increased automatically. While selecting automobiles for sale, the proposed software will automatically check for total number of available stock of that particular item, if the total stock of that particular item is less than 5, software will notify the user to purchase the particular item.
Also when the user tries to sale items which are not in stock, the system will prompt the user that the stock is not enough. Customers of this system can search for a automobile; can purchase a automobile easily by selecting fast. On the other hand the stock of automobiles can be maintained perfectly by the automobile shop manager overcoming the drawbacks of existing system.
Explore the innovative world of trenchless pipe repair with our comprehensive guide, "The Benefits and Techniques of Trenchless Pipe Repair." This document delves into the modern methods of repairing underground pipes without the need for extensive excavation, highlighting the numerous advantages and the latest techniques used in the industry.
Learn about the cost savings, reduced environmental impact, and minimal disruption associated with trenchless technology. Discover detailed explanations of popular techniques such as pipe bursting, cured-in-place pipe (CIPP) lining, and directional drilling. Understand how these methods can be applied to various types of infrastructure, from residential plumbing to large-scale municipal systems.
Ideal for homeowners, contractors, engineers, and anyone interested in modern plumbing solutions, this guide provides valuable insights into why trenchless pipe repair is becoming the preferred choice for pipe rehabilitation. Stay informed about the latest advancements and best practices in the field.
Welcome to WIPAC Monthly the magazine brought to you by the LinkedIn Group Water Industry Process Automation & Control.
In this month's edition, along with this month's industry news to celebrate the 13 years since the group was created we have articles including
A case study of the used of Advanced Process Control at the Wastewater Treatment works at Lleida in Spain
A look back on an article on smart wastewater networks in order to see how the industry has measured up in the interim around the adoption of Digital Transformation in the Water Industry.
12. a <=> b :=
if a < b then return -1
if a = b then return 0
if a > b then return 1
if a and b are not comparable then return
nil
13. [1,3,2] <=> [2,2,2]
- Ruby will start comparing each element of
both array from left hand side.
- 1 of left array is smaller than 2 of right
array.
- Hence left array is smaller than right array.
Output will be -1.
15. - "If I have a drawer labelled a would it
make sense to put b in that drawer?"
- The main usage for the === operator is in
case expressions
a === b
17. Diff between a == b and a === b
- (a == b) and (b == a) is always the same
- (a === b) and (b === a) is not always the
same
Integer === 2 #true
2 === Integer #false
26. We just used double splat to capture all
keyword arguments
27. def join_array(arr, elements: , by_char: ‘,’)
arr.take(elements).join(by_char)
end
a = [20, 30, 10, 40]
# optional if there is default set in parameters, in this case it is by_char
p join_array(a, elements: 3)
p join_array(a, elements: 2, by_char: ‘-’)
# order not important
p join_array(a, by_char: ‘-’, elements: 3)
30. def parrot(&what_human_said)
puts “Hey, I’m gonna say what you said”
what_human_said.call
puts “Thank you. Have a nice day”
end
parrot do
puts “I’m not Siri”
puts “I’m green, eeee”
end
32. Sorta like a magic :)
Ruby also lets us do it implicitly
33. def parrot
puts “Hey, I’m gonna say what you said”
yield
puts “Thank you. Have a nice day”
end
parrot do
puts “I’m not Siri”
puts “I’m green, eeee”
end
34. yield
- is not a method but a type.
- yield executes the block.
- faster than previous eg.
36. But, what is proc?
- an object
- with blocks of code
- bound to a set of local variables
37.
38. lambda is just like proc but strict and nice
- lambda checks parameters passed to it
- lambda is not like that adamant child that
forces you out of the movie just because
he didn’t like it.
52. - A curried proc receives some arguments.
- If a sufficient number of arguments are
supplied, it passes the supplied arguments
to the original proc and returns the result.
53. multiple = proc { |x, y| x * y }
multiple.call(2, 3) #=> 6
# here x = 2, y = 3
curry_multiple = multiple.curry
#=> curried the multiple proc
54. multiple_of_2 = curry_multiple.call(2)
# here x is 2, y is not yet passed
# when y is passed, the proc will
# get executed
multiple_of_2.call(3) #=> 6
# here x is 2, y is 3
71. class Politics
def free_scheme
puts “Yo. Get lots of free stuff.”
end
alias_method :money_time, :free_scheme
end
Politics.new.free_scheme # what you see :P
Politics.new.money_time # what they see :P
81. module Watson
refine String do
def palindrome?
self.reverse == self
end
end
end
“Ruby”.palindrome?
#=> NoMethodError: undefined method `palindrome?' for "Ruby":String
#Not available outside the namespace
111. the class to hold the class specific methods
So, actually ruby is making a singleton class for
just like it does for object because class is
also object?
112.
113. invisible to the programmer.
AH! Yes! And The singleton class is typically
But you sorta see in one syntax, which is
115. class << self is like class Singleton(self)
- You want to add a method just to a specific
object. (note: even class is an object)
- But you can’t write method to a object.
- So, you write method to object’s singleton
class like this.
116. class Human;end
matz = Human.new
class << matz
def write
puts “Writing the epic: Ruby”
end
end
matz.write
132. class PA
extend Forwardable
def_delegators :@ceo, :availability, :phone_call, :office_mails
def initialize(ceo)
@ceo = ceo
end
def check_my_mail(mail)
office_mails.include? (mail)
end
end
133. jack_ma = CEO.new(“Jack Ma”)
jack_ma_pa = PA.new(jack_ma)
jack_ma_pa.phone_call do
puts “Hello, mr.jack ma.”
end
jack_ma_pa.check_my_mail(1234)
134. Also look for other awesome classes
- Queue
- Stack
- Thread
- StringScanner
136. class A
def initialize(foo)
@foo = foo
end
end
a = A.new (“cool”)
a.instance_variable_get “foo”
a.instance_variable_set :@foo, “hotl”
a.instance_variables
137. class A
@@b = 10
end
A.class_variable_get “b”
A.class_variables
138. const_get
class A
PI = 3.14
end
A.const_get “PI” # also there is const_set
#only works with the classes not with objects
143. # earlier we saw this code
class Human;end
matz = Human.new
class << matz
def write
puts “Writing the epic: Ruby”
end
end
matz.write
144. # Can also be written as
class Human;end
matz = Human.new
matz.instance_eval do
def write
puts “Writing the epic: Ruby”
end
end
matz.write
145. Since class is also an object
we can use instance_eval on it.
146. # we earlier saw this
class RubyLang; end
RubyLang.define_singleton_method(:minaswan) do
puts “Matz is nice and so we are nice”
end
RubyLang.minaswan
147. # Also can be written as
class RubyLang; end
RubyLang.instance_eval do
puts “Matz is nice and so we are nice”
end
RubyLang.minaswan
149. class Person; end
Person.new.name #=> ERROR
Person.class_eval do
attr_accessor :name
def trumpet
puts “Me..me...me… #{name}”
end
end
person = Person.new
person.name = “Narcissis”
person.trumpet
151. module Mod
CONST = 1
def math
# ...
end
end
Mod.class #=> Module
Mod.constants #=> [:CONST]
Mod.instance_methods #=> [:math]
152. that you can use across multiple classes
Modules are about providing methods
153. - extend
- include
- prepend
- using (refinements)
We already saw about ‘using’
154. module Hipster
def flame_wars
puts “Yo, this lang is better, that lang is worse”
end
end
class Programmer
end
me = Programmer.new
me.extend Hipster
me.flame_wars
155. Can you guess where the
module methods were inserted for object?
156. extend just did that for us :)
To the singleton class of the object.
157. module Hipster
def flame_wars
puts “Yo, this lang is better, that lang is worse”
end
end
class HipsterProgrammer
extend Hipster
end
HipsterProgrammer.flame_wars
158. Yes. We inserted module methods to
the singleton class of class by using extend
159. What if we want to just insert
module methods to the class?
160. module Hipster
def flame_wars
puts “Yo, this lang is better, that lang is worse”
end
end
class HipsterProgrammer
include Hipster
end
me = HipsterProgrammer.new
me.flame_wars
164. prepend is just like include
But prepends itself first in the ancestors chain
165. module Friend
def opinion
puts "This would be best for you :) .."
end
end
class NormalPerson
include Friend
def opinion
puts "I think this would be best for me"
end
end
167. - Though “opinion” method exists in both
classes
- it would start from the first of the ancestors
- i.e NormalPerson in our case
168. module Friend
def opinion
puts "This would be best for you :) .."
end
end
class BFF
prepend Friend
def opinion
puts "I think this would be best for me"
end
end
169. BFF.ancestors
#=> [Friend, BFF, ...]
# This is the order of method look up
BFF.new.opinion
#=> “This would be best for you :) ..”
175. class Errand
def send
puts “Buy stuff”
end
def check
puts “checking…”
end
end
Errand.new.__send__(“check”)
use __send__ if the name send clashes with an existing method in obj
176. Also there are
__ENCODING__ (keyword)
__LINE__ (keyword)
__getobj__ (SimpleDelegator)
__setobj__ (SimpleDelegator)
177. Things we missed
- Operators like &&=, ||=, =~
- File operations
- System calls
- Enumerator methods
- threads
- exceptions, backtraces, benchmarking
- and many more, do check it out