This document provides an overview of the Ruby programming language. It discusses Ruby's clean and meaningful syntax, everything being an object, dynamic typing and duck typing, open classes, blocks, mixins, testing, standard library, and gems. Ruby aims to be productive and fun to use.
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.
This is the Moose talk I gave at YAPC::NA 2012.
It included a practical example of a Moose objects code, a simple app called Comican. The code is not available online. If you want it, just email me (sawyer ATT cpan DOTT org).
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.
This is the Moose talk I gave at YAPC::NA 2012.
It included a practical example of a Moose objects code, a simple app called Comican. The code is not available online. If you want it, just email me (sawyer ATT cpan DOTT org).
Roles are an excellent object-oriented tool both for allomorphism and for
reuse.
Roles facilitate allomorphism by favoring "does this object do X" versus "is
this object a subclass of X". You often care more about capability than
inheritance. In a sense, roles encode types better than inheritance.
Roles also provide an excellent faculty for reuse. This effectively eliminates
multiple inheritance, which is often the only solution for sharing code between
unrelated classes.
Roles can combine with conflict detection. This eliminates accidental shadowing
of methods that is painful with multiple inheritance and mixins.
Parameterized roles (via MooseX::Role::Parameterized) improve the reusability
of roles by letting each consumer cater the role to its needs. This does
sacrifice some allomorphism, but there are ways to restore it.
Roles are an excellent object-oriented tool both for allomorphism and for
reuse.
Roles facilitate allomorphism by favoring "does this object do X" versus "is
this object a subclass of X". You often care more about capability than
inheritance. In a sense, roles encode types better than inheritance.
Roles also provide an excellent faculty for reuse. This effectively eliminates
multiple inheritance, which is often the only solution for sharing code between
unrelated classes.
Roles can combine with conflict detection. This eliminates accidental shadowing
of methods that is painful with multiple inheritance and mixins.
Parameterized roles (via MooseX::Role::Parameterized) improve the reusability
of roles by letting each consumer cater the role to its needs. This does
sacrifice some allomorphism, but there are ways to restore it.
How to Use HealthyCity.org for Grant Writing & ReportingHealthy City
These slides are from a webinar designed to demonstrate how to use HealthyCity.org to enhance your grant proposals and reports with visually impactful and relevant data, maps, and charts. Learn how to access data that highlights the needs and opportunities within your communities of interest and how to make the case that your program will make a difference.
In this training you will learn how to:
- Gather data for your particular area of interest by creating your own community boundaries.
- Create maps and charts that provide the visual evidence to demonstrate both the need and potential within your community.
- Report your results - make the case that your program or project has had a positive and measurable impact.
[Romans8:12-17; Ephesians 5:15-21] — Clearly the Bible teaches that the Holy Spiirit indwells, influences and leads the child of God. The question is how does the Bible, (the Holy Spirit’s revelation) tell us He does it. — AUDIO PART 1 / AUDIO PART 2 / PPT / KEYNOTE / PDF - 12/25/2016
HRD adviesbureau GITP laat organisaties en individuen beter functioneren in hun professionele en maatschappelijke omgeving. Dit doen wij door inzicht te bieden in talenten en kwaliteiten, en door ontwikkeling mogelijk te maken. Het resultaat is dat mensen sterker, bevlogen en geïnspireerd zijn en organisaties renderend, relevant en effectief.
The Danger of Procrastination - God presents us with opportunities to obey Him - The devil always strives to make certain that a convenient time to obey the Lord will never come!
Have you ever been discouraged and tired? Have you ever thought about slacking off your duties to the Lord? This lesson on zeal is a needed one and hopefully will benefit you and inspire you to keep on keeping on with enthusiastic work for the Master
Life is difficult sometimes - how do we face trials? Tragedy? Hardships? Can we face them with the faith and hope mentioned in one of the most popular hymns ever? Can we say - "It Is Well With My Soul?"
Attributes Unwrapped: Lessons under the surface of active record.toster
Ведущий разработчик Ruby on Rails (Rails Core member) Джон Лейтон не так давно работал над совершенствованием реализации работы с атрибутами в Active Record. Он расскажет о своем опыте работы над важной для производительности областью Rails, даст советы и расскажет о техниках, которые могут быть применены к собственным приложениям слушателей.
Говоря о будущем, Джон также расскажет о своих идеях по изменению API работы с атрибутами в лучшую сторону; эти изменения могут появиться в Rails 4.0.
Discussing language constructs with fellow developers in the context of solving a particular problem is something we do routinely. While most such conversations are productive and useful, a fair portion degenerate into angry brawls. A pattern we've observed in the latter situation is that a surprising number of times the argument is that "Why shouldn't I use language feature X to achieve objective Y- after all, the language supports X."
In this talk Aakash and Niranjan walk through a few features of the Ruby language which when used wisely allows programmers to solve problems elegantly but if they are used without caution can lead to bad code.
A few techniques for everyday Ruby hacking
Touching on the following topics:
DRY Assignment
Ternary operator
Bang bang
Conditional assignment
Parallel assignment
Multiple return
Implied begin
Exception lists
Symbol to Proc
MapReduce
Regex captures
tap
sprintf
case equality
Splat Array
Splat args
blank?
present?
presence
truncate
try
in?
Delegation
delegate
Memoization
memoize
alias_method_chain
class_attribute
HashWithIndifferentAccess
4. test_string = 'string for test'
puts 'matched' if test_string.match 'string'
files = Dir['*.txt']
for file in files
file_ref = open file
file_ref.each_line { |line| puts line.reverse.upcase }
end
5. Everything is an Object
10.times { puts “Hello World!” } “Hello World!”.methods
7. a_variable = 'a b c'.split(' ') #=> ['a','b','c']
a_variable = a_variable.join(' ') #=> 'a b c'
def a_function object_par
puts object_par.crazy_method
end
a_function [1,2,3] #=> error: undefined method 'crazy_method' for class Array
class Array
def crazy_method
return 'crazy method for an array'
end
end
a_function [1,2,3] #=> puts 'crazy method for an array'
8. a_variable = 'a b c'.split(' ') #=> ['a','b','c']
a_variable = a_variable.join(' ') #=> 'a b c'
def a_function object_par
puts object_par.crazy_method
end
a_function [1,2,3] #=> error: undefined method 'crazy_method' for class Array
class Array
def crazy_method
return 'crazy method for an array'
end
end
a_function [1,2,3] #=> puts 'crazy method for an array'
9. def a_function object_par
puts object_par.crazy_method
end
some_obj = SomeClass.new
a_function some_obj #=> error: undefined method 'crazy_method' for class SomeClass
def some_obj.crazy_method
return 'this is a crazy feature'
end
a_function some_obj #=> puts 'this is a crazy_feature'
10. def a_function object_par
puts object_par.crazy_method
end
some_obj = SomeClass.new
a_function some_obj #=> error: undefined method 'crazy_method' for class SomeClass
def some_obj.crazy_method
return 'this is a crazy feature'
end
a_function some_obj #=> puts 'this is a crazy_feature'
11. "if it walks like a duck and quacks like a
duck, then it is a duck”
13. def square an_array
return an_array.map { |e| e*e }
end
lines_of_a_doc.each_with_index do |line,i|
if i.even? then
puts 'even line: #{line}'
else
puts 'odd line: ' + line
end
end
17. class Books < Collection
def initialize
@books = SomeReader.new('some_file_with_books').get_books
end
include Enumerable
def each
@books.each { |book| yield(book) }
end
end
Class Books now have
map, select, inject, grep, find_all, include?
and more
19. require 'test/unit'
class TestHtmlParser < Test::Unit::TestCase
must “find all imgs” do
parser = HtmlParser.new '<div class='a'> <br/> <img src='img1.jpg'>n
<p><img src='img2.jpg'></body>'
assert_equal parser.parse_imgs, ['img1.jpg','img2.jpg']
end
end
class HtmlParser
def initialize html_doc
@content = html_doc
end
def parse_imgs
@content.scan(/imgs+src='(.+?)'/)
end
end