This document discusses method shelters, a new module system for Ruby that aims to resolve conflicts caused by open classes. Method shelters allow defining methods locally within a scope and importing other shelters while preventing conflicts. Key aspects include hidden chambers to protect internally used methods, and a lookup algorithm that prioritizes local shelters over global methods. The implementation adds method shelters as implicit arguments and uses caching to optimize performance. Method shelters can help optimize applications, mimic private variables, and resolve conflicts from open class extensions.
Qcon2011 functions rockpresentation_scalaMichael Stal
This is the part I of the tutorial I planned to give at QCon 2011 on Functional Programming with Scala. It also includes Scala 2.8 as well as upcoming features
Latest C Interview Questions and AnswersDaisyWatson5
3. What is a register variable?
Register variables are stored in the CPU registers. Its default value is a garbage value. Scope of a register variable is local to the block in which it is defined. Lifetime is till control remains within the block in which the register variable is defined. Variable stored in a CPU register can always be accessed faster than the one that is stored in memory. Therefore, if a variable is used at many places in a program, it is better to declare its storage class as register
Example: register int x=5;
Variables for loop counters can be declared as register. Note that register keyword may be ignored by some compilers.
4. Where is an auto variables stored?
Main memory and CPU registers are the two memory locations where auto variables are stored. Auto variables are defined under automatic storage class. They are stored in main memory. Memory is allocated to an automatic variable when the block which contains it is called and it is de-allocated at the completion of its block
execution.
Auto variables:
Storage
:
main memory.
Default value
:
garbage value.
Scope
:
local to the block in which the variable is defined.
Lifetime
:
till the control remains within the block in which the variable is defined.
5. What is scope & storage allocation of extern and global variables?
Extern variables: belong to the External storage class and are stored in the main memory. extern is used when we have to refer a function or variable that is implemented in another file in the same project. The scope of the extern variables is Global.
Generic programming is a style of computer programming in which algorithms are written in terms of types to-be-specified-later that are then instantiated when needed for specific types provided as parameters.
Generics are a facility of generic programming that were added to the Java programming language in 2004 within version J2SE 5.0. They were designed to extend Java's type system to allow “a type or method to operate on objects of various types while providing compile-time type safety”
The Java collections framework supports generics to specify the type of objects stored in a collection instance.
This presentation introduces the main features of Scala, an object oriented and functional programming language. The main focus of the slides is to show how the language implements natively some of the patterns and best practices that are no present in other programming languages, such as Java, C++ and so on.
In detail, the presentation spans these concepts:
- Language's main syntax
- Classes, abstract classes, objects and traits (mixin)
- The Option class
- An introduction to generics
- Implicit classes
- Functions
- Recursion (simple and tail)
- Currying
- Call by value / name
The presentation is took from the Software Engineering course I run in the bachelor-level informatics curriculum at the University of Padova.
Qcon2011 functions rockpresentation_scalaMichael Stal
This is the part I of the tutorial I planned to give at QCon 2011 on Functional Programming with Scala. It also includes Scala 2.8 as well as upcoming features
Latest C Interview Questions and AnswersDaisyWatson5
3. What is a register variable?
Register variables are stored in the CPU registers. Its default value is a garbage value. Scope of a register variable is local to the block in which it is defined. Lifetime is till control remains within the block in which the register variable is defined. Variable stored in a CPU register can always be accessed faster than the one that is stored in memory. Therefore, if a variable is used at many places in a program, it is better to declare its storage class as register
Example: register int x=5;
Variables for loop counters can be declared as register. Note that register keyword may be ignored by some compilers.
4. Where is an auto variables stored?
Main memory and CPU registers are the two memory locations where auto variables are stored. Auto variables are defined under automatic storage class. They are stored in main memory. Memory is allocated to an automatic variable when the block which contains it is called and it is de-allocated at the completion of its block
execution.
Auto variables:
Storage
:
main memory.
Default value
:
garbage value.
Scope
:
local to the block in which the variable is defined.
Lifetime
:
till the control remains within the block in which the variable is defined.
5. What is scope & storage allocation of extern and global variables?
Extern variables: belong to the External storage class and are stored in the main memory. extern is used when we have to refer a function or variable that is implemented in another file in the same project. The scope of the extern variables is Global.
Generic programming is a style of computer programming in which algorithms are written in terms of types to-be-specified-later that are then instantiated when needed for specific types provided as parameters.
Generics are a facility of generic programming that were added to the Java programming language in 2004 within version J2SE 5.0. They were designed to extend Java's type system to allow “a type or method to operate on objects of various types while providing compile-time type safety”
The Java collections framework supports generics to specify the type of objects stored in a collection instance.
This presentation introduces the main features of Scala, an object oriented and functional programming language. The main focus of the slides is to show how the language implements natively some of the patterns and best practices that are no present in other programming languages, such as Java, C++ and so on.
In detail, the presentation spans these concepts:
- Language's main syntax
- Classes, abstract classes, objects and traits (mixin)
- The Option class
- An introduction to generics
- Implicit classes
- Functions
- Recursion (simple and tail)
- Currying
- Call by value / name
The presentation is took from the Software Engineering course I run in the bachelor-level informatics curriculum at the University of Padova.
The Bundle system is one of the greatest and most powerful features of Symfony2. Bundles contain all the files related to a single feature of your application: controllers, entities, event listeners, form types, Twig templates, etc. But how much of that actually needs to be inside a bundle?
In this talk we’ll take a bundle, containing all those different types of classes, configuration files and templates, and strip it down to the bare necessities. And I promise that after moving many files out of the bundle, everything still works.
While looking for ways to move things out of the bundle, I will discuss some of the more advanced features of bundle design, like prepending configuration, compiler passes and Doctrine mapping drivers. We will end with a very lean bundle, surrounded by a few highly reusable, maximally decoupled libraries.
"Groovy 2.0 and beyond" presentation given at the Groovy/Grails eXchange conference.
Video can be seen here:
http://skillsmatter.com/podcast/groovy-grails/keynote-speech
The Bundle system is one of the greatest and most powerful features of Symfony2. Bundles contain all the files related to a single feature of your application: controllers, entities, event listeners, form types, Twig templates, etc. But how much of that actually needs to be inside a bundle?
In this talk we’ll take a bundle, containing all those different types of classes, configuration files and templates, and strip it down to the bare necessities. And I promise that after moving many files out of the bundle, everything still works.
While looking for ways to move things out of the bundle, I will discuss some of the more advanced features of bundle design, like prepending configuration, compiler passes and Doctrine mapping drivers. We will end with a very lean bundle, surrounded by a few highly reusable, maximally decoupled libraries.
The Bundle system is one of the greatest and most powerful features of Symfony2. Bundles contain all the files related to a single feature of your application: controllers, entities, event listeners, form types, Twig templates, etc. But how much of that actually needs to be inside a bundle?
In this talk we’ll take a bundle, containing all those different types of classes, configuration files and templates, and strip it down to the bare necessities. And I promise that after moving many files out of the bundle, everything still works.
While looking for ways to move things out of the bundle, I will discuss some of the more advanced features of bundle design, like prepending configuration, compiler passes and Doctrine mapping drivers. We will end with a very lean bundle, surrounded by a few highly reusable, maximally decoupled libraries.
1.2 Develop code that declares an interface. Develop code
that implements or extends one or more interfaces. Develop
code that extends an abstract class.
1.4 Develop code that declares both static and non-static
methods, and - if appropriate - use method names that
adhere to the JavaBeans naming standards. Also develop
code that declares and uses a variable-length argument list.
5.3 Explain the effect of modifiers on inheritance with
respect to constructors, instance or static variables, and
instance or static methods.
7.1 Given a code example and a scenario, write code
that uses the appropriate access modifiers, package
declarations, and import statements to interact with
(through access or inheritance) the code in the example.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Welocme to ViralQR, your best QR code generator.ViralQR
Welcome to ViralQR, your best QR code generator available on the market!
At ViralQR, we design static and dynamic QR codes. Our mission is to make business operations easier and customer engagement more powerful through the use of QR technology. Be it a small-scale business or a huge enterprise, our easy-to-use platform provides multiple choices that can be tailored according to your company's branding and marketing strategies.
Our Vision
We are here to make the process of creating QR codes easy and smooth, thus enhancing customer interaction and making business more fluid. We very strongly believe in the ability of QR codes to change the world for businesses in their interaction with customers and are set on making that technology accessible and usable far and wide.
Our Achievements
Ever since its inception, we have successfully served many clients by offering QR codes in their marketing, service delivery, and collection of feedback across various industries. Our platform has been recognized for its ease of use and amazing features, which helped a business to make QR codes.
Our Services
At ViralQR, here is a comprehensive suite of services that caters to your very needs:
Static QR Codes: Create free static QR codes. These QR codes are able to store significant information such as URLs, vCards, plain text, emails and SMS, Wi-Fi credentials, and Bitcoin addresses.
Dynamic QR codes: These also have all the advanced features but are subscription-based. They can directly link to PDF files, images, micro-landing pages, social accounts, review forms, business pages, and applications. In addition, they can be branded with CTAs, frames, patterns, colors, and logos to enhance your branding.
Pricing and Packages
Additionally, there is a 14-day free offer to ViralQR, which is an exceptional opportunity for new users to take a feel of this platform. One can easily subscribe from there and experience the full dynamic of using QR codes. The subscription plans are not only meant for business; they are priced very flexibly so that literally every business could afford to benefit from our service.
Why choose us?
ViralQR will provide services for marketing, advertising, catering, retail, and the like. The QR codes can be posted on fliers, packaging, merchandise, and banners, as well as to substitute for cash and cards in a restaurant or coffee shop. With QR codes integrated into your business, improve customer engagement and streamline operations.
Comprehensive Analytics
Subscribers of ViralQR receive detailed analytics and tracking tools in light of having a view of the core values of QR code performance. Our analytics dashboard shows aggregate views and unique views, as well as detailed information about each impression, including time, device, browser, and estimated location by city and country.
So, thank you for choosing ViralQR; we have an offer of nothing but the best in terms of QR code services to meet business diversity!
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.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
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/
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfPeter Spielvogel
Building better applications for business users with SAP Fiori.
• What is SAP Fiori and why it matters to you
• How a better user experience drives measurable business benefits
• How to get started with SAP Fiori today
• How SAP Fiori elements accelerates application development
• How SAP Build Code includes SAP Fiori tools and other generative artificial intelligence capabilities
• How SAP Fiori paves the way for using AI in SAP apps
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
Method Shelters : Another Way to Resolve Class Extension Conflicts
1. Method Shelters :
Another Way to Resolve Class
Extension Conflicts
Classboxes でも Refinements でもない別のやり方
Shumpei Akai / 赤井駿平
@flexfrank
2. What I talk about today
Open Class causes conflicts
of methods
Method Shelters resolve it!
3. % whoami
Shumpei Akai / 赤井駿平
@flexfrank
Ph.D. Student / 学生(博士課程)
◦ 東工大の千葉研
◦ Programming Languages and Moduralization
◦ プログラミング言語とモジュール化
Today’s topic is my current research
4. Open Class
Ruby’s one of the important features
You can (re)define methods in existing
classes
◦ including Object, Integer, Array, …
Frequently used in Ruby world
5. in open-uri
open-uri redefines “open” method
◦ It accepts URI
open("http://penguindrum.jp/"){|f|f.read}
# => Errno::ENOENT: No such file or directory
require "open-uri”
open("http://penguindrum.jp/"){|f|f.read}
# => "<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd”…”
6. in Ruby on Rails
ActiveSupport adds various convenient
methods to core classes
◦ e.g.
10.megabytes # => 10485760
1.day.ago # => Sat Jul 16 16:15:00 +0900 2011
"survival strategy".pluralize #=> "survival strategies"
8. Problem of Open Class
Methods may conflict
When One library adds a method
◦ and another library adds a method with the
same name in the same class
The method defined first is vanished!
◦ depends on the order of “require”
◦ Confusing!
9. Method conflicts
I encountered about five years ago
◦ Ruby on Rails and flvtool added a method to
String
◦ they used String as binary/array of int
Difficult to collaborate these two libraries
◦ I separated processes
◦ communicating via dRuby
10. Another example of conflicts
“mathn” redefines the “Integer#/”
◦ returns a Rational object
◦ Ordinary code expects “/” returns a integer
Programs get broken
11. Existing Solutions
Several module systems are proposed to
resolve conflicts
◦ Selector namespaces (for Smalltalk)
◦ Classboxes (for Smalltalk and Java)
◦ Refinements (for Ruby)
◦ …
12. Refinements
Proposed by Shugo Maeda [ruby-core:33322]
class Foo
module MathN using MathN
refine Fixnum do def foo
def /(other) p1/2
quo(other) end
end end
end
end f = Foo.new
f.foo #=> (1/2)
p1/2
13. Refinements (cont.)
Refinements changes behavior of
methods in a lexical scope
◦ methods defined by Refinements are not
enabled in indirectly called methods
◦ No local rebinding
I need local rebinding
◦ e.g. scoped monkey patching
14. Classboxes
You might have known via matz’s diary
15. Classboxes
A classbox restrict the scope of methods
A classbox can import a class in another
classbox
◦ You can use an imported class
◦ You can add/redefine methods to the
imported class
◦ A redefined method can be called from the
imported class
Local rebinding property
17. The Problem in Classboxes
Importing overwrites internally used
classes
◦ Importing causes another conflict
18. The Problem in
Classboxes
Redefines Original
Integer#div Integer
Uses redefined Use original
Integer#div Integer
returns rational
Oops!
returns integer
19. I need another module system
A new module should:
◦ have local rebinding
◦ provide a way to resolve conflicts cause by
importing
◦ not depends on the order of load
22. What is a method shelter
A method shelter is a module which
provides a scope of methods
◦ define methods in a method shelter
◦ import other method shelters
You can call methods in the imported shelter
You can call methods in the shelter which is
importing the current shelter
for local rebinding
call importee
call
importer
23. A Code with Method Shelters
shelter :MathN do
class Fixnum # fixed size integer in Ruby
def /(x)
Rational(self,x)
end
end
end
shelter :Average do
class Array
def avg
sum = self.inject(0){|r,i|r+i}
sum / self.size
end
end
hide
import :MathN
end
24. What conforms a method shelter
A method shelter is separated into tow
parts
◦ An exposed chamber and a hidden chamber
◦ in order to protect internally used methods
◦ Each chamber can define methods and import
- Exposed - Hidden
25. Exposed Chambers S0
- Obj#m0
for public API
Exposed methods
◦ Visible from importer
◦ Importer can call or
redefine exposed S1
methods
Exposedly import
◦ Transitive importing
◦ Imported methods are
S2
also visible from importer
26. Hidden chamber S0
- Obj#m1 - Obj#m0
for internally used
methods
Hidden method S1
◦ invisible in importing
shelter
Hiddenly import
S2
◦ Imported methods are not
exposed
27. Global Methods
Ordinal methods not in shelters
◦ Callable from any shelter
◦ Global methods can call methods in a shelter
if the caller is in the shelter
Global
- Obj#g0
S0
obj.g0()
28. No Ambiguity
If 2+ methods are found in imported
shelters S3
- C#m0
◦ Error!
S1 S2
- C#m0
S0
Error!
29. Syntax
I don’t want to edit parse.y
define methods in a block
shelter :ShelterName do
class Foo
def hoge # <- defined in the method shelter
end
end
end
40. Performance: Ruby on Rails
Enabled in an action method
◦ Numeric#/.*bytes?/ methods are in a shelter
In the action
◦ 1. Call one method in shelter
◦ 2. One access to SQLite via ActiveRecord
on WEBRick
Rails3
41. Performance:
Ruby on Rails (result)
4% overhead on production env.
50% on development
◦ Method caches are invalidated per req.
production
development
43. Performance: tDiary 3.0.1
defined
String#to_a, String#each, String#method_
missing in a shelter
◦ These are used for compatibility of 1.8 & 1.9
Ran on CGI with apache
Method shelter improved performance !!
◦ Why?
44. Why shelter made tDiary fast
String#method_missing issue
“require” calls its arg’s to_path method if
defined
◦ If arg’s method_missing is defined, try to call
it
◦ String#method_missing slows “require”
Method shelter restrict its negative effect
45. Other Usage:
protect optimized methods
In ruby, + - * / … are optimized
◦ only if they are not redefined
◦ Redefinition slows programs
Method shelters can confine effect of
redefinition
Method shelter can improve performance
46. Other Usage:
shelter-private accessor
Ruby has no private instance variables
A method shelter can mimic private ivars
◦ by generating unique name
◦ Accessible within the defined shelter
and visible shelters
47. class Module
def shelter_accessor(name)
define_method name do
ivname=get_unique_name(name)
self.instance_variable_get(ivname)
end
define_method( (name.to_s+"=").to_sym) do|val|
ivname= get_unique_name(name)
self.instance_variable_set(ivname,val)
end
end
end
48. Conclusion
Open class is dangerous
Method shelters resolving conflicts
◦ With hidden methods, hiddenly importing
I implemented in Ruby
◦ Not so slow (個人的な感覚)
For more details or the source code,
◦ wait for the acceptance of my paper
Deadline: 2.days.since