My talk from Ruby Hoedown MMX. We talked about the Ruby standard library and how sometimes we reinvent things when we have perfectly good tools waiting for us to use them.
Intro talks never let you learn about the things that make a language truly cool. In this talk we'll discover how advanced features of Ruby help us write cleaner more modular code.
If you've ever looked into how to create Gems, you've probably seen a bunch of ways to do that. Project generators like Hoe, Jeweler, and the like offer some nice ways to get started, but they may often be overkill for many projects. If you're just starting out, why not learn to do it from scratch?
In this talk, we'll create our own gem from scratch, using only things that are provided by Ruby, its standard library, and RubyGems to craft a simple gem.
You'll learn how to set up a project, how to write and run tests, how to use Rake to quickly build the gem, and even how to create a gem that installs an executable command-line program.
Slides about "How we build Vox" in Six Apart, presented by Benjamin Trott, the CTO and co-founder of the company in <a href="http://tokyo2007.yapcasia.org/">YAPC::Asia 2007 in Tokyo</a>. The talk was done in English and interpreted by Tatsuhiko Miyagawa into Japanese.
Intro talks never let you learn about the things that make a language truly cool. In this talk we'll discover how advanced features of Ruby help us write cleaner more modular code.
If you've ever looked into how to create Gems, you've probably seen a bunch of ways to do that. Project generators like Hoe, Jeweler, and the like offer some nice ways to get started, but they may often be overkill for many projects. If you're just starting out, why not learn to do it from scratch?
In this talk, we'll create our own gem from scratch, using only things that are provided by Ruby, its standard library, and RubyGems to craft a simple gem.
You'll learn how to set up a project, how to write and run tests, how to use Rake to quickly build the gem, and even how to create a gem that installs an executable command-line program.
Slides about "How we build Vox" in Six Apart, presented by Benjamin Trott, the CTO and co-founder of the company in <a href="http://tokyo2007.yapcasia.org/">YAPC::Asia 2007 in Tokyo</a>. The talk was done in English and interpreted by Tatsuhiko Miyagawa into Japanese.
Many of the recent big data systems, like Hadoop, Spark, and Kafka, are written primarily in JVM languages. At the same time, there is a wealth of tools for data science and data analytics that exist outside of the JVM. Holden Karau and Rachel Warren explore the state of the current big data ecosystem and explain how to best work with it in non-JVM languages. While much of the focus will be on Python + Spark, the talk will also include interesting anecdotes about how these lessons apply to other systems (including Kafka).
Holden and Rachel detail how to bridge the gap using PySpark and discuss other solutions like Kafka Streams as well. They also outline the challenges of pure Python solutions like dask. Holden and Rachel start with the current architecture of PySpark and its evolution. They then turn to the future, covering Arrow-accelerated interchange for Python functions, how to expose Python machine learning models into Spark, and how to use systems like Spark to accelerate training of traditional Python models. They also dive into what other similar systems are doing as well as what the options are for (almost) completely ignoring the JVM in the big data space.
Python users will learn how to more effectively use systems like Spark and understand how the design is changing. JVM developers will gain an understanding of how to Python code from data scientist and Python developers while avoiding the traditional trap of needing to rewrite everything.
Introduction to Selenium e Scrapy by Arcangelo Saracino
Web UI testing with Selenium, check actions, text and submit form.
Scrapy to crawl info from a website combined with selenium.
This report analyzes the worldwide markets for Ceramic Tiles in Millions of Square Feet. The report provides separate comprehensive analytics for the US, Canada, Japan, Europe, Asia-Pacific, Middle East, and Latin America. Annual estimates and forecasts are provided for each region for the period 2007 through 2015. Also, a seven-year historic analysis is provided for these markets. The report profiles 164 companies including many key and niche players such as Boral Ltd., Canteras Cerro Negro SA, Cecrisa S.A, Ceramica Lima S.A., Ceramiche Atlas Concorde S.p.A., Ceramika Tubadzin II Sp. z o.o, Ceramicas Malpesa S.A., Cerypsa Ceramicas S.A., Cristal Cer
What do your listeners think about you when they're NOT listening to the radio? And attendees were taught why that question is perhaps more critical than what they think about you when they ARE listening. Tripp illustrated how the 31 times consumers turn on the radio each week are "Moments Of Truth" for your brand, and indicated what you can do to strengthen their loyalty.
Many of the recent big data systems, like Hadoop, Spark, and Kafka, are written primarily in JVM languages. At the same time, there is a wealth of tools for data science and data analytics that exist outside of the JVM. Holden Karau and Rachel Warren explore the state of the current big data ecosystem and explain how to best work with it in non-JVM languages. While much of the focus will be on Python + Spark, the talk will also include interesting anecdotes about how these lessons apply to other systems (including Kafka).
Holden and Rachel detail how to bridge the gap using PySpark and discuss other solutions like Kafka Streams as well. They also outline the challenges of pure Python solutions like dask. Holden and Rachel start with the current architecture of PySpark and its evolution. They then turn to the future, covering Arrow-accelerated interchange for Python functions, how to expose Python machine learning models into Spark, and how to use systems like Spark to accelerate training of traditional Python models. They also dive into what other similar systems are doing as well as what the options are for (almost) completely ignoring the JVM in the big data space.
Python users will learn how to more effectively use systems like Spark and understand how the design is changing. JVM developers will gain an understanding of how to Python code from data scientist and Python developers while avoiding the traditional trap of needing to rewrite everything.
Introduction to Selenium e Scrapy by Arcangelo Saracino
Web UI testing with Selenium, check actions, text and submit form.
Scrapy to crawl info from a website combined with selenium.
This report analyzes the worldwide markets for Ceramic Tiles in Millions of Square Feet. The report provides separate comprehensive analytics for the US, Canada, Japan, Europe, Asia-Pacific, Middle East, and Latin America. Annual estimates and forecasts are provided for each region for the period 2007 through 2015. Also, a seven-year historic analysis is provided for these markets. The report profiles 164 companies including many key and niche players such as Boral Ltd., Canteras Cerro Negro SA, Cecrisa S.A, Ceramica Lima S.A., Ceramiche Atlas Concorde S.p.A., Ceramika Tubadzin II Sp. z o.o, Ceramicas Malpesa S.A., Cerypsa Ceramicas S.A., Cristal Cer
What do your listeners think about you when they're NOT listening to the radio? And attendees were taught why that question is perhaps more critical than what they think about you when they ARE listening. Tripp illustrated how the 31 times consumers turn on the radio each week are "Moments Of Truth" for your brand, and indicated what you can do to strengthen their loyalty.
Datazone Systems LLC is one of the most enterprising multi-disciplinary ELV companies in Dubai UAE. Get ELV companies in Dubai, UAE at www.datazoneme.com.
Productos para el cuidado personal de origen vegetal. Hechos a partir de investigaciones biológicas realizadas en los laboratorios Yves Rocher, localizados en diferentes partes del mundo y en los cultivos de La Gacilly, Francia.
Sprockets is an easy solution to managing large JavaScript codebases by letting you structure it, bundle it with related assets, and consolidate it as one single file, with pre-baked command-line tooling, CGI front and Rails plugin. It's a framework-agnostic open-source solution that makes for great serving performance while helping you structure and manage your codebase better.
Fulfilling the Hypermedia Constraint via HTTP OPTIONS, The HTTP Vocabulary In...ruyalarcon
WS-REST 2011.
Second International Workshop on RESTful Design.
Chairs: Cesare Pautasso, Erik Wilde, Rosa Alarcon.
<br>
Hypermedia and Model-Driven Development Session. Tomas Steiner and Jan Algermissen
Puppet getting started will show the different components used in puppet environments, starting with facter and puppet to different webinterfaces like puppet enterprise console and foreman. It will also cover an exemplary design for scaling the puppet master and for development livecycle of modules. Furthermore an example for design of modules will be given.
It's possible to make a structured, consistent, API that can handle changes to logic and the schema. Sure, it seems like a good plan to dump everything out of the database today, but what are you going to do when something changes down the road? Let's have a talk about some SOLID ways to structure our APIs and keep them from breaking down the road.
PlayNode Conference 2012 (NodeConf 2012 in Korea) 에서 발표한 node.js 기반의 정적 페이지 블로그 엔진 하루프레스
하루프레스의 기능적인 특징, 철학 그리고 기술적인 특징을 통해 알아보는 개발 노하우에 대한 내용을 닮고 있습니다.
Building Google-in-a-box: using Apache SolrCloud and Bigtop to index your big...rhatr
You’ve got your Hadoop cluster, you’ve got your petabytes of unstructured data, you run mapreduce jobs and SQL-on-Hadoop queries. Something is still missing though. After all, we are not expected to enter SQL queries while looking for information on the web. Altavista and Google solved it for us ages ago. Why are we still requiring SQL or Java certification from our enterprise bigdata users? In this talk, we will look into how integration of SolrCloud into Apache Bigtop is now enabling building bigdata indexing solutions and ingest pipelines. We will dive into the details of integrating full-text search into the lifecycle of your bigdata management applications and exposing the power of Google-in-a-box to all enterprise users, not just a chosen few data scientists.
TypePad Motion is a Django web application for creating community microblogging sites. It uses the TypePad API as a backend data store, so you don't have to worry about scaling, backups, or any related infrastructure. All you need is a web server.
WordCamp Bournemouth 2014 - Designing with data in WordPressJonny Allbut
My Presentation from WordCamp Bournemouth 2014 on designing with data in WordPress. Covers structuring your data, the different data storage/attachment options available to you and some food for thought on how to use this data to deliver flexible WordPress websites.
Everything you wanted to know about writing async, concurrent http apps in java Baruch Sadogursky
As presented at CodeMotion Tel Aviv:
Facing tens of millions of clients continuously downloading binaries from its repositories, JFrog decided to offer an OSS client that natively supports these downloads. This session shares the main challenges of developing a highly concurrent, resumable, async download library on top of an Apache HTTP client. It also covers other libraries JFrog tested and why it decided to reinvent the wheel. Consider yourself forewarned: lots of HTTP internals, NIO, and concurrency ahead!
"Puppet at Pinterest", by Ryan Park, Operations Engineer at Pinterest. Talk from PuppetConf 2012.
Video of "Puppet at Pinterest": http://youtu.be/aU-bCbBq8zs
Learn more about Puppet: http://bit.ly/QQoAP1
Abstract: A case study of how Pinterest uses Puppet to manage its infrastructure. Pinterest has hundreds of Amazon EC2 virtual servers and uses Puppet Dashboard as the “source of truth” about its server inventory. Pinterest built a REST API for this database, which powers tools and automated scripts that integrate Puppet with internal systems and with Amazon Web Services.
Speaker Bio: Ryan Park leads operations and infrastructure at Pinterest, one of 2012’s fastest growing web sites. Pinterest’s entire infrastructure is in the cloud, built atop hundreds of Amazon EC2 virtual server instances. Ryan introduced Puppet to their infrastructure as soon as he joined the company, and they now use Puppet as the primary tool for managing their infrastructure. Prior to joining Pinterest, Ryan was the Head of Operations at PBworks, an online team collaboration service.
Similar to Stop Reinventing The Wheel - The Ruby Standard Library (20)
Creating and Deploying Static Sites with HugoBrian Hogan
Most web sites don’t have data that changes, so why power them with a database and take the performance hit? In this talk we’ll explore static site generation using Hugo, an open-source static site generator. You’ll learn how to make a master layout for all pages, and how to use Markdown to create your content pages quickly.
Then we’ll explore how to deploy the site we made to production. We’ll automate the entire process. When you’re done, you’ll be able to build and deploy static web sites quickly with minimal tooling.
Automating the Cloud with Terraform, and AnsibleBrian Hogan
Need a web server? So did I. But setting everything up by hand is tedious. In this talk, you'll see how to build a load-balanced web server using Ansible, Terraform, and DigitalOcean, a cloud provider aimed at developers. First, you'll see how to build out the servers and load balancer, and then you'll see how to use Ansible Playbooks to install and upload the web site. When we're done, you'll have scripts you can run to set up your own environment.
Create Development and Production Environments with VagrantBrian Hogan
Need a Linux box to test a Wordpress site or a Windows VM to test a web site on IE 10? Creating a virtual machine to test or deploy your software doesn’t have to be a manual process. Bring one up in seconds with Vagrant, software for creating and managing virtual machines. With Vagrant, you can bring up a new virtual machine with the software you need, share directories, copy files, and configure networking using a friendly DSL. You can even use shell scripts or more powerful provisioning tools to set up your software and install your apps. Whether you need a Windows machine for testing an app, or a full-blown production environment for your apps, Vagrant has you covered.
In this talk you’ll learn to script the creation of multiple local virtual machines. Then you’ll use the same strategy to provision production servers in the cloud.
I work with Vagrant, Terraform, Docker, and other provisioning systems daily and am excited to show others how to bring this into their own workflows.
Docker is an amazing tool, but unless you work with it every day, you're probably left with a ton of questions. What's a container? What's an image? What's the difference between Docker, Machine, Compose, and Swarm? Why the heck should I care? Well, Docker makes it easier than ever to deploy and scale your applications and services. In addition, it lets you simulate your production environment on your local machine without heavy virtual machines. In this talk, we'll explore the basics of Docker, create a custom image for a web application, create a group of containers, and look at how you can put your apps into production on various cloud providers. At the end of the talk, you'll have the knowledge you need to put this to use with your own applications.
Come explore Elm, a functional programming language for making web things. Elm aims to solve some of the same problems that Ember, React, and Angular 2 solve, but in a radically different way. Strong and static typing ensures that data you pass around in your apps really is what you think it is. A simple and tried-and-true architecture makes it easy to understand, and great tooling makes it fun to use.
Web Development With Ruby - From Simple To ComplexBrian Hogan
Beyond the massive hype of Ruby on Rails, there's an amazing world of frameworks, DSLs, and libraries that make the Ruby language a compelling choice when working on the web. In this talk, you'll get a chance to see how to use Ruby to quickly build a static web site, create complex stylesheets with ease, build a simple web service, crete a simple Websocket server, and test your existing applications. Finally, you'll see a few of the ways Rails really can make developing complex applications easier, from advanced database querying to rendering views in multiple formats.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
3. What about this
design?
describe "the user" do
it "gets an email when their account is activated" do
# some stuff
end
end
Twitter: @bphogan
Web: http://www.napcs.com/
4. Sometimes ideas
evolve for the better.
Twitter: @bphogan
Web: http://www.napcs.com/
5. Other times not so
much.
Twitter: @bphogan
Web: http://www.napcs.com/
6. In software we
reinvent
Twitter: @bphogan
Web: http://www.napcs.com/
7. How often is
“better”
really just opinion?
Twitter: @bphogan
Web: http://www.napcs.com/
8. So, we’re not talking
about always using
what exists...
Twitter: @bphogan
Web: http://www.napcs.com/
9. We’re talking about
reinventing because
of ignorance, hubris,
or ego.
Twitter: @bphogan
Web: http://www.napcs.com/
10. Ruby Standard Library
http://ruby-doc.org/stdlib/
Twitter: @bphogan
Web: http://www.napcs.com/
12. Working With The File
System
system("mkdir -p tmp/files")
system("touch tmp/files/lockfile.lock")
system("rm -rf tmp/files")
Twitter: @bphogan
Web: http://www.napcs.com/
13. Make it platform-
independent!
require 'fileutils'
FileUtils.mkdir_p("tmp/files")
FileUtils.touch("tmp/files/lockfile.lock")
FileUtils.rm_rf("tmp/files")
Twitter: @bphogan
Web: http://www.napcs.com/
14. FileUtils
Namespace for several file utility methods
for copying, moving, removing, etc.
Twitter: @bphogan
Web: http://www.napcs.com/
15. Where it’s used
•Rake
•Capistrano stuff
•Sinatra Reloader gem
•Compass
Twitter: @bphogan
Web: http://www.napcs.com/
16. Where does it fall
short?
Twitter: @bphogan
Web: http://www.napcs.com/
17. Delegating Methods
Calling methods on one class through another.
User Profile
name name
Twitter: @bphogan
Web: http://www.napcs.com/
18. Here’s how Rails
does it
def delegate(*methods)
options = methods.pop
unless options.is_a?(Hash) && to = options[:to]
raise ArgumentError, "Delegation needs a target.
Supply an options hash with a :to key as the last argument
(e.g. delegate :hello, :to => :greeter)."
end
methods.each do |method|
module_eval("def #{method}(*args, &block)
n#{to}.__send__(#{method.inspect},
*args, &block)nendn", "(__DELEGATION__)", 1)
end
end
Twitter: @bphogan
Web: http://www.napcs.com/
19. Here’s how Rails
does it
class User < ActiveRecord::Base
has_one :profile
delegate :name, :to => :profile
end
Twitter: @bphogan
Web: http://www.napcs.com/
20. Here’s how we could
do it.
require 'forwardable'
class User < ActiveRecord::Base
has_one :profile
extend Forwardable
def_delegator :profile, :bio, :bio
end
Twitter: @bphogan
Web: http://www.napcs.com/
21. Forwardable
This library allows you
delegate method calls to
an object, on a method by
method basis.
Twitter: @bphogan
Web: http://www.napcs.com/
22. Where it’s used
•MongoMapper
•Rack::Client
Twitter: @bphogan
Web: http://www.napcs.com/
23. Where does it fall
short?
Twitter: @bphogan
Web: http://www.napcs.com/
25. Seen in tons of Rails
apps...
file = File.join(RAILS_ROOT, "config", "database.yml")
config = YAML.load(File.read(file))
Twitter: @bphogan
Web: http://www.napcs.com/
26. A better way
file = Rails.root.join("config", "database.yml")
config = YAML.load(file.read)
Rails.root.class
=> Pathname
http://litanyagainstfear.com/blog/2010/02/03/the-rails-module/
Twitter: @bphogan
Web: http://www.napcs.com/
27. Pathname
Library to simplify working
with files and paths.
Represents a pathname which locates a file
in a filesystem. The pathname depends on
OS: Unix, Windows, etc.
Twitter: @bphogan
Web: http://www.napcs.com/
28. Neat stuff
require 'pathname'
p = Pathname.new("/usr/bin/ruby")
size = p.size # 27662
isdir = p.directory? # false
dir = p.dirname # Pathname:/usr/bin
base = p.basename # Pathname:ruby
dir, base = p.split # [Pathname:/usr/bin, Pathname:ruby]
Twitter: @bphogan
Web: http://www.napcs.com/
29. Where it’s used
•Rails
•DataMapper
•Warehouse
•Webistrano
•many many more
Twitter: @bphogan
Web: http://www.napcs.com/
38. The hard way
path = "http://pastie.org/1131498.txt?key=zst64zkddsxafra0jz678g"
`curl #{path} > /tmp/template.html`
s = File.read("/tmp/template.html")
puts s
Twitter: @bphogan
Web: http://www.napcs.com/
49. def initialize
super
observed_descendants.each { |klass| add_observer!(klass) }
end
def self.method_added(method)
method = method.to_sym
if ActiveRecord::Callbacks::CALLBACKS.include?(method)
self.observed_methods += [method]
self.observed_methods.freeze
end
end
protected
def observed_descendants
observed_classes.sum([]) { |klass| klass.descendants }
end
def observe_callbacks?
self.class.observed_methods.any?
end
def add_observer!(klass)
super
define_callbacks klass if observe_callbacks?
end
def define_callbacks(klass)
existing_methods = klass.instance_methods.map { |m| m.to_sym }
observer = self
observer_name = observer.class.name.underscore.gsub('/', '__')
self.class.observed_methods.each do |method|
callback = :"_notify_#{observer_name}_for_#{method}"
unless existing_methods.include? callback
klass.send(:define_method, callback) do # def _notify_user_observer_for_before_save
observer.update(method, self) # observer.update(:before_save, self)
end # end
klass.send(method, callback) # before_save :_notify_user_observer_for_before_save
end
end
end
end
end
Twitter: @bphogan
Web: http://www.napcs.com/
50. Observer
Provides a simple
mechanism for one
object to inform a set of
interested third-party
objects when its state
changes.
Twitter: @bphogan
Web: http://www.napcs.com/
51. How we do it
require 'observer'
class ConfirmationEmailer
def update(account)
puts "Sending confirmation mail to: '#{account.email}'"
# send the email mechanism
end
end
Twitter: @bphogan
Web: http://www.napcs.com/
52. class Account
include Observable
attr_accessor :email, :active
def initialize(email)
self.email = email
self.active = false
add_observer ConfirmationEmailer.new
end
def activate_account!
self.active = true
changed # <- This is important
notify_observers self
end
end
Twitter: @bphogan
Web: http://www.napcs.com/
53. Where does it fall
short?
Twitter: @bphogan
Web: http://www.napcs.com/
64. PStore
Persistent, transactional
storage. Baked right in to
Ruby’s standard library.
Twitter: @bphogan
Web: http://www.napcs.com/
65. We can store stuff...
require 'pstore'
store = PStore.new('links')
links = %W{http://www.github.com
http://heroku.com
http://ruby-lang.org}
store.transaction do
store[:links] ||= []
links.each{|link| store[:links] << link}
store[:last_modified] = Time.now
end
Twitter: @bphogan
Web: http://www.napcs.com/
66. and we can get it
back.
store = PStore.new("links")
store.transaction do
links = store[:links]
end
puts links.join("n")
Twitter: @bphogan
Web: http://www.napcs.com/
67. Where it’s used
•Rails 1.x
Twitter: @bphogan
Web: http://www.napcs.com/
68. Where does it
fall short?
Twitter: @bphogan
Web: http://www.napcs.com/
74. How we do it
today = DateTime.now
birthday = Date.new(2010, 10, 5)
days_to_go = birthday - today
time_until = birthday - today
hours,minutes,seconds,frac =
Date.day_fraction_to_time(time_until)
http://www.techotopia.com/index.php/Working_with_Dates_and_Times_in_Ruby
Twitter: @bphogan
Web: http://www.napcs.com/
75. home_run
home_run is an implementation of rubyʼs Date/
DateTime classes in C, with much better
performance (20-200x) than the version in the
standard library, while being almost completely
compatible.
http://github.com/jeremyevans/home_run
Twitter: @bphogan
Web: http://www.napcs.com/
76. REXML
Built-in library for
parsing and creating XML.
Twitter: @bphogan
Web: http://www.napcs.com/
77. How about
HPricot, libxml-
ruby, or
Nokogiri.
http://www.rubyinside.com/ruby-xml-performance-benchmarks-1641.html
Twitter: @bphogan
Web: http://www.napcs.com/
78. ERb
Templating language as part of the Standard Library.
Twitter: @bphogan
Web: http://www.napcs.com/
80. Templating language
!=
View language!!!
Twitter: @bphogan
Web: http://www.napcs.com/
81. What can it do?
•Generate JavaScript
•Generate YAML
•Generate ERb
•Any type of proprietary data export
Twitter: @bphogan
Web: http://www.napcs.com/
82. Where does it fall
short?
Twitter: @bphogan
Web: http://www.napcs.com/