A command line application in Ruby provides concise summaries in 3 sentences or less:
The document discusses building command line applications in Ruby and covers topics like why to use a command line application, designing the application, and implementing it as a Ruby gem. It provides examples of parsing command line tool outputs and designing classes for commands and formatting outputs. The document provides guidance on features for command line applications like supporting multiple output formats and an interactive shell.
FITC events. For digital creators.
Save 10% off ANY FITC event with discount code 'slideshare'
See our upcoming events at www.fitc.ca
An Intro To ES6
with Grant Skinner
OVERVIEW
ECMAScript 6 is the approved and published standard for the next version of JavaScript. It offers new syntax and language features that provide new ways of tackling coding problems, and increase your productivity.
This session will introduce ES6 and delve into many of the new features of the language. It will also cover real-world use, including transpilers, runtimes, and browser support.
OBJECTIVE
Create confidence in evaluating and getting started using ES6.
TARGET AUDIENCE
JavaScript developers.
ASSUMED AUDIENCE KNOWLEDGE
JavaScript.
FOUR THINGS AUDIENCE MEMBERS WILL LEARN
Status of ES6
How to get started with ES6
ES6 feature overview
Practical considerations for adopting ES6
Rust
Why do you care about Rust? Who has the time to learn all these new languages? It seems like a new one is popping up every other week and this trend is growing at an exponential rate. Good news, a fair number of them are crafted really well and efficiently solve specific problems. Bad news, how do you keep up with all of this, let alone decide which languages to include in your companies technology portfolio.
Despite the challenges of all these new languages, a majority of developers are intrigued about the idea of becoming a polyglot, but don't know where to begin or don't have the time. In my polyglot travels, there is one language of late that is the sure-fire answer to the above questions, Rust.
In this talk I’ll explore the value behind becoming more polyglotic as a developer, how to pick languages to learn, and then dive deep in the the language of Rust. Which in my opinion, is hands down the best up and coming languages to learn.
About the Presenter
Anthony Broad-Crawford has been a developer since the year 2000 with a short side stint as a semi-professional poker player. Since his transition to software development Anthony has...
1. Built 8 patent receiving technologies
2. Founded two global companies
3. Been a CTO (3x), CPO (1x), and CEO (1x)
and is currently the CTO at Fooda where he manages product, user experience, and engineering. Fooda is predominantly web and mobile technology company focused on bringing great & healthy food from the best restaurant's to people while at the office.
Through his career, in production applications Anthony has used Ruby, Java, Jave (Android), Objective-C and Swift, .NET, Erlang, Scala, Node.JS, LISP, Smalltalk, and even assembly, with his recent favorite, Rust . No, not all at the same time in the same application.
Anthony now spends his time building great teams, that leverage great technology, to build great products, but still looks to codes every chance he can get :)
FITC events. For digital creators.
Save 10% off ANY FITC event with discount code 'slideshare'
See our upcoming events at www.fitc.ca
An Intro To ES6
with Grant Skinner
OVERVIEW
ECMAScript 6 is the approved and published standard for the next version of JavaScript. It offers new syntax and language features that provide new ways of tackling coding problems, and increase your productivity.
This session will introduce ES6 and delve into many of the new features of the language. It will also cover real-world use, including transpilers, runtimes, and browser support.
OBJECTIVE
Create confidence in evaluating and getting started using ES6.
TARGET AUDIENCE
JavaScript developers.
ASSUMED AUDIENCE KNOWLEDGE
JavaScript.
FOUR THINGS AUDIENCE MEMBERS WILL LEARN
Status of ES6
How to get started with ES6
ES6 feature overview
Practical considerations for adopting ES6
Rust
Why do you care about Rust? Who has the time to learn all these new languages? It seems like a new one is popping up every other week and this trend is growing at an exponential rate. Good news, a fair number of them are crafted really well and efficiently solve specific problems. Bad news, how do you keep up with all of this, let alone decide which languages to include in your companies technology portfolio.
Despite the challenges of all these new languages, a majority of developers are intrigued about the idea of becoming a polyglot, but don't know where to begin or don't have the time. In my polyglot travels, there is one language of late that is the sure-fire answer to the above questions, Rust.
In this talk I’ll explore the value behind becoming more polyglotic as a developer, how to pick languages to learn, and then dive deep in the the language of Rust. Which in my opinion, is hands down the best up and coming languages to learn.
About the Presenter
Anthony Broad-Crawford has been a developer since the year 2000 with a short side stint as a semi-professional poker player. Since his transition to software development Anthony has...
1. Built 8 patent receiving technologies
2. Founded two global companies
3. Been a CTO (3x), CPO (1x), and CEO (1x)
and is currently the CTO at Fooda where he manages product, user experience, and engineering. Fooda is predominantly web and mobile technology company focused on bringing great & healthy food from the best restaurant's to people while at the office.
Through his career, in production applications Anthony has used Ruby, Java, Jave (Android), Objective-C and Swift, .NET, Erlang, Scala, Node.JS, LISP, Smalltalk, and even assembly, with his recent favorite, Rust . No, not all at the same time in the same application.
Anthony now spends his time building great teams, that leverage great technology, to build great products, but still looks to codes every chance he can get :)
Implementing pseudo-keywords through Functional ProgramingVincent Pradeilles
Swift is a great language. But we’ve all met situations where a certain feature was missing, and we wished were part of the it.
Since programs are basically functions, and functions are first-class citizen in Swift, it’s possible to implement “pseudo-keywords” at a short cost and to great value.
Slides from Advaned Python lectures I gave recently in Haifa Linux club
Advanced python, Part 2:
- Slots vs Dictionaries
- Basic and Advanced Generators
- Async programming
Slides from Advaned Python lectures I gave recently in Haifa Linux club
Advanced python, Part 1:
- Decorators
- Descriptors
- Metaclasses
- Multiple inheritance
Coming from UNIX System V (IBM AIX & Sun Solaris) System Programmer background, I find Linux has become the defacto choice for many computing workload, from embedded device, mobile phone, mission critical systems, all the way to the largest Super Computer Cluster in the world.
While Linux has tried to maintain its UNIX design philosophy, its foundation has radically changed departing its UNIX root (bye init, hi systemd), towards modern Operating Systems which many of its features have equivalent of its UNIX counterparts - if not better (Linux Container vs AIX WPAR/Solaris Zones, Solaris ZFS vs Stratis, and many more).
This document is not meant to beat Red Hat comprehensive online manual, instead it was written to help me memorize many of advanced RHEL features and to help me pass hands on performance based EX200 exam.
This document is compiled from many sources, and written for anyone who would like to learn Red Hat Enterprise Linux 8, through taking EX200 exam in order to showing off RHCSA title to your friend :D
Happy Learning and may the force be with you!
The fundamentals and advance application of Node will be covered. We will explore the design choices that make Node.js unique, how this changes the way applications are built and how systems of applications work most effectively in this model. You will learn how to create modular code that’s robust, expressive and clear. Understand when to use callbacks, event emitters and streams.
Implementing pseudo-keywords through Functional ProgramingVincent Pradeilles
Swift is a great language. But we’ve all met situations where a certain feature was missing, and we wished were part of the it.
Since programs are basically functions, and functions are first-class citizen in Swift, it’s possible to implement “pseudo-keywords” at a short cost and to great value.
Slides from Advaned Python lectures I gave recently in Haifa Linux club
Advanced python, Part 2:
- Slots vs Dictionaries
- Basic and Advanced Generators
- Async programming
Slides from Advaned Python lectures I gave recently in Haifa Linux club
Advanced python, Part 1:
- Decorators
- Descriptors
- Metaclasses
- Multiple inheritance
Coming from UNIX System V (IBM AIX & Sun Solaris) System Programmer background, I find Linux has become the defacto choice for many computing workload, from embedded device, mobile phone, mission critical systems, all the way to the largest Super Computer Cluster in the world.
While Linux has tried to maintain its UNIX design philosophy, its foundation has radically changed departing its UNIX root (bye init, hi systemd), towards modern Operating Systems which many of its features have equivalent of its UNIX counterparts - if not better (Linux Container vs AIX WPAR/Solaris Zones, Solaris ZFS vs Stratis, and many more).
This document is not meant to beat Red Hat comprehensive online manual, instead it was written to help me memorize many of advanced RHEL features and to help me pass hands on performance based EX200 exam.
This document is compiled from many sources, and written for anyone who would like to learn Red Hat Enterprise Linux 8, through taking EX200 exam in order to showing off RHCSA title to your friend :D
Happy Learning and may the force be with you!
The fundamentals and advance application of Node will be covered. We will explore the design choices that make Node.js unique, how this changes the way applications are built and how systems of applications work most effectively in this model. You will learn how to create modular code that’s robust, expressive and clear. Understand when to use callbacks, event emitters and streams.
Lost in Translation: When Industrial Protocol Translation goes Wrong [CONFide...Marco Balduzzi
Protocol gateways are embedded devices used in industrial facilities to integrate legacy equipment such as serial PLCs with modern control networks. Given the importance that these devices play in the operation of manufacturing plants, we conducted a vendor agnostic analysis of the technology behind protocol translation, by identifying new unexplored weaknesses and vulnerabilities. We evaluated five popular gateway products and discovered translation problems that enable potential adversaries to conduct stealthy and difficult-to-detect attacks, for example to arbitrarily disable, or enable a targeted machinery by mean of innocent-looking packets that bypass common ICS firewalls. In this presentation, we share the results of our findings and discuss the impact to the problems that we identified and their potential countermeasures.
Mathilde Lemée & Romain Maton
La théorie, c’est bien, la pratique … aussi !
Venez nous rejoindre pour découvrir les profondeurs de Node.js !
Nous nous servirons d’un exemple pratique pour vous permettre d’avoir une premiere experience complete autour de Node.js et de vous permettre de vous forger un avis sur ce serveur Javascript qui fait parler de lui !
http://soft-shake.ch/2011/conference/sessions/incubator/2011/09/01/hands-on-nodejs.html
Bare Metal to OpenStack with Razor and ChefMatt Ray
Slides from the OpenStack Spring 2013 Summit workshop presented by Egle Sigler (@eglute) and Matt Ray (@mattray) from Rackspace and Opscode respectively. Please refer to http://anystacker.com/ for additional content.
Managing Large-scale Networks with Triggerjathanism
Trigger was designed to increase the speed and efficiency of managing network configuration while reducing human error, and is the bread and butter of how we manage the large-scale network at AOL. In this talk I intend to cover the problems we solved using Python to manage our network infrastructure, especially how each network vendor does things distinctly differently, and about the code and API that makes Trigger tick using detailed examples.
Given at SCaLE 11x, Los Angeles, CA
Video: http://www.youtube.com/watch?v=7zZ9980X_bs
Based on original presentation by Dan Webb http://slidesha.re/dan_on_rack
Added some bits about Rails at the end, instead of other examples he had originally.
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)Wesley Beary
Cloud computing scared the crap out of me - the quirks and nightmares of provisioning cloud computing, dns, storage, ... on AWS, Terremark, Rackspace, ... - I mean, where do you even start?
Since I couldn't find a good answer, I undertook the (probably insane) task of creating one. fog gives you a place to start by creating abstractions that work across many different providers, greatly reducing the barrier to entry (and the cost of switching later). The abstractions are built on top of solid wrappers for each api. So if the high level stuff doesn't cut it you can dig in and get the job done. On top of that, mocks are available to simulate what clouds will do for development and testing (saving you time and money).
You'll get a whirlwind tour of basic through advanced as we create the building blocks of a highly distributed (multi-cloud) system with some simple Ruby scripts that work nearly verbatim from provider to provider. Get your feet wet working with cloud resources or just make it easier on yourself as your usage gets more complex, either way fog makes it easy to get what you need from the cloud.
The OpenStack Edition adds my concerns about OpenStack API development, including things that have already been fixed and things that we haven't yet encountered. Hopefully this consumer perspective can help shed light on some rough spots.
fog or: How I Learned to Stop Worrying and Love the CloudWesley Beary
Learn how to easily get started on cloud computing with fog. If you can control your infrastructure choices, you’ll make better choices in development and get what you need in production. You'll get an overview of fog and concrete examples to give you a head start on your provisioning workflow.
by Ganesh Shankaran, Sr. Solutions Architect, AWS
Hands-on Lab to compare and contrast relational queries (using RDS for MySQL) with nonrelational queries (using ElastiCache for Redis). You’ll need a laptop with a Firefox or Chrome browser.
Slides from a presentation that David Lopez (@lopezator) and me made for the students of the University of the Basque Country (UPV/EHU) where we talk about current technologies and methodologies used in professional web development.
CSS3, jQuery, Composer, MVC, Clean Code, Git, etc. are different items we talked about.
Some examples shown in the presentation available at:
http://ojoven.es/labs/ehu2014/
Has the traditional intro to event looped servers (thanks Ryan!) with a couple of examples of why I think node.js is particularly exciting today. Code for the demos can be found at https://github.com/davidpadbury/node-intro.
Similar to Command Line Applications in Ruby, 2018-05-08 (20)
Using recycled concrete aggregates (RCA) for pavements is crucial to achieving sustainability. Implementing RCA for new pavement can minimize carbon footprint, conserve natural resources, reduce harmful emissions, and lower life cycle costs. Compared to natural aggregate (NA), RCA pavement has fewer comprehensive studies and sustainability assessments.
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsVictor Morales
K8sGPT is a tool that analyzes and diagnoses Kubernetes clusters. This presentation was used to share the requirements and dependencies to deploy K8sGPT in a local environment.
6th International Conference on Machine Learning & Applications (CMLA 2024)ClaraZara1
6th International Conference on Machine Learning & Applications (CMLA 2024) will provide an excellent international forum for sharing knowledge and results in theory, methodology and applications of on Machine Learning & Applications.
HEAP SORT ILLUSTRATED WITH HEAPIFY, BUILD HEAP FOR DYNAMIC ARRAYS.
Heap sort is a comparison-based sorting technique based on Binary Heap data structure. It is similar to the selection sort where we first find the minimum element and place the minimum element at the beginning. Repeat the same process for the remaining elements.
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...ssuser7dcef0
Power plants release a large amount of water vapor into the
atmosphere through the stack. The flue gas can be a potential
source for obtaining much needed cooling water for a power
plant. If a power plant could recover and reuse a portion of this
moisture, it could reduce its total cooling water intake
requirement. One of the most practical way to recover water
from flue gas is to use a condensing heat exchanger. The power
plant could also recover latent heat due to condensation as well
as sensible heat due to lowering the flue gas exit temperature.
Additionally, harmful acids released from the stack can be
reduced in a condensing heat exchanger by acid condensation. reduced in a condensing heat exchanger by acid condensation.
Condensation of vapors in flue gas is a complicated
phenomenon since heat and mass transfer of water vapor and
various acids simultaneously occur in the presence of noncondensable
gases such as nitrogen and oxygen. Design of a
condenser depends on the knowledge and understanding of the
heat and mass transfer processes. A computer program for
numerical simulations of water (H2O) and sulfuric acid (H2SO4)
condensation in a flue gas condensing heat exchanger was
developed using MATLAB. Governing equations based on
mass and energy balances for the system were derived to
predict variables such as flue gas exit temperature, cooling
water outlet temperature, mole fraction and condensation rates
of water and sulfuric acid vapors. The equations were solved
using an iterative solution technique with calculations of heat
and mass transfer coefficients and physical properties.
Water billing management system project report.pdfKamal Acharya
Our project entitled “Water Billing Management System” aims is to generate Water bill with all the charges and penalty. Manual system that is employed is extremely laborious and quite inadequate. It only makes the process more difficult and hard.
The aim of our project is to develop a system that is meant to partially computerize the work performed in the Water Board like generating monthly Water bill, record of consuming unit of water, store record of the customer and previous unpaid record.
We used HTML/PHP as front end and MYSQL as back end for developing our project. HTML is primarily a visual design environment. We can create a android application by designing the form and that make up the user interface. Adding android application code to the form and the objects such as buttons and text boxes on them and adding any required support code in additional modular.
MySQL is free open source database that facilitates the effective management of the databases by connecting them to the software. It is a stable ,reliable and the powerful solution with the advanced features and advantages which are as follows: Data Security.MySQL is free open source database that facilitates the effective management of the databases by connecting them to the software.
12. A Little Ruby Love
There comes a time,
When you find you need a tool,
When a GUI's more trouble than it's worth,
The command line is waiting there for you,
All it takes is a little Ruby love,
Movin' the mouse
And then clickin'
And then typin'
All of that to do just one little thing...
Automation
We do it for the world,
So why don't we do it for ourselves?
A CLA (Command Line Application)
will solve the problem,
No need to fumble or stumble with a mouse
And then you will come to find,
A whole new peace of mind,
As you use your newfound productivity.
13. Shell Examples
• list available networks
• list available access points
• show, clear, or set nameservers
• get WiFi detailed status information
• show network name (SSID)
• show the password for a saved network
• show wifi on/off and Internet on/off status
14. Shell Example
Use Case: Remove Saved “AIS” Networks
[4] pry()> ais_nets = pref_nets.grep(/AIS/)
=> [" AIS SMART Login", ".@ AIS SUPER WiFi", "STARBUCKS_AIS"]
[5] pry()> rm_pref_nets(*ais_nets)
Password:
=> [" AIS SMART Login", ".@ AIS SUPER WiFi", “STARBUCKS_AIS"]
[6] pry()> ais_nets = pref_nets.grep(/AIS/)
=> []
# or, using the short command forms, and combining them into one
statement:
rm(*pr.grep(/AIS/))
16. Command Line Interface (CLI)
vs.
Command Line Application (CLA)
“Interface”:
• understates the functionality
• exaggerates the simplicity compared with other apps
22. Decision:
Use MacOS command line utilities or
system calls?
• using utilities simplifies implementation
• no need to write native code
• using utilities complicates implementation
• text formats may change over time
• locales!
23. Output Parsing Example:
Detecting the WiFi Port
# Identifies the (first) wireless network hardware port in the system, e.g. en0 or en1
# This may not detect wifi ports with nonstandard names, such as USB wifi devices.
def detect_wifi_port
lines = run_os_command("networksetup -listallhardwareports").split("n")
# Produces something like this:
# Hardware Port: Wi-Fi
# Device: en0
# Ethernet Address: ac:bc:32:b9:a9:9d
#
# Hardware Port: Bluetooth PAN
# Device: en3
# Ethernet Address: ac:bc:32:b9:a9:9e
wifi_port_line_num = (0...lines.size).detect do |index|
/: Wi-Fi$/.match(lines[index])
end
if wifi_port_line_num.nil?
raise Error.new(%Q{Wifi port (e.g. "en0") not found in output of: } +
"networksetup -listallhardwareports”)
else
lines[wifi_port_line_num + 1].split(': ').last
end
end
25. wifi-wand Application
Requirements
• usable by non-Rubyist Mac users with command line expertise
• easily installable
• provides a shell
• installable without additional gems (with caveats)
• `pry` is only required if/when running in shell mode
• `awesome_print` is optional, fallback is `pretty_print`
• `optparse` must be required but comes packaged with the Ruby
distribution
• support using models without command line execution, i.e. can be
used as CLA or not
• Support YAML & JSON
29. Enable Bypassing the CLI
You can use the models in your Ruby code without using the
CommandLineInterface class. Here is a script ‘public_ip’:
#!/usr/bin/env ruby
require 'wifi-wand'
require 'awesome_print'
ap WifiWand::MacOsModel.new.wifi_info['public_ip']
When we run it, we get:
33. Provide a Shell
• no need to type application name with every command
• returned data as Ruby objects
• enables composite commands for data manipulation,
custom behavior
• can store data in variables/constants for later use
34. Use ‘pry’ for the shell
• full featured REPL
• one can access other shell commands using the dot
('.') prefix (e.g. ‘.ping google.com’)
• Pry commands such as `ls` can be accessed using '%'
prefix (e.g. ‘%ls')
35. ProvideShell Convenience
Methods
You can provide convenience methods not directly related to the DSL commands,
with both abbreviated and complete names. For example:
So that it can be used in the shell like this:
def fancy_puts(object)
puts fancy_string(object)
end
alias_method :fp, :fancy_puts
39. Providing an Executable
with Your Ruby Gem
• In your gemspec file, you specify the location of your
executable(s):
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
# or:
spec.executables = [‘wifi-wand’]
• It can be (and probably should be) a simple wrapper
around your other code, e.g.:
#!/usr/bin/env ruby
require_relative '../lib/wifi-wand/main'
WifiWand::Main.new.call
40. Using Available Tools to
Simplify Implementation
• pry - gem providing richly functional interactive shell
(REPL)
• awesome_print - gem that outputs simple Ruby objects
in a clear, logical, and attractive format
• Ruby’s built-in json and yaml support
• open - Mac OS command to open a resource identifier
with the default application for that resource type, e.g.
`open https://www.whatismyip.com/`
44. Shell Commands:
method_missing
def method_missing(method_name, *method_args)
method_name = method_name.to_s
action = find_command_action(method_name)
if action
action.(*method_args)
else
puts(%Q{"#{method_name}" is not a valid command or option. }
<< 'If you intend for this to be a string literal, '
<< 'use quotes or %q{}/%Q{}.')
end
end
46. Formatter Lambda Hash
parser.on("-o", "--output_format FORMAT", "Format output data") do |v|
formatters = {
'i' => ->(object) { object.inspect },
'j' => ->(object) { object.to_json },
'k' => ->(object) { JSON.pretty_generate(object) },
'p' => ->(object) { sio = StringIO.new; sio.puts(object); sio.string },
'y' => ->(object) { object.to_yaml }
}
choice = v[0].downcase
unless formatters.keys.include?(choice)
message = %Q{Output format "#{choice}" not in list of available formats} <<
" (#{formatters.keys})."
puts; puts message; puts
raise Error.new(message)
end
options.post_processor = formatters[choice]
end
47. Tips for Calling Other CLA’s
• Redirect stderr to stdout (command 2>&1)
• Use their exit codes (`$?`, which is threadlocal, not global)
• Provide a way for the user to see the commands and their
output
• Centralize calling the OS in a single method, even if you
think you'll never need it. Here’s mine:
48. run_os_command
def run_os_command(command, raise_on_error = true)
if @verbose_mode
puts CommandOutputFormatter.command_attempt_as_string(command)
end
start_time = Time.now
output = `#{command} 2>&1` # join stderr with stdout
if @verbose_mode
puts "Duration: #{'%.4f' % [Time.now - start_time]} seconds"
puts CommandOutputFormatter.command_result_as_string(output)
end
if $?.exitstatus != 0 && raise_on_error
raise OsCommandError.new($?.exitstatus, command, output)
end
output
end
49. Shellwords
[8] pry(main)> `export MY_PASSWORD=a b c; echo $MY_PASSWORD`
=> "an"
[9] pry(main)> `export MY_PASSWORD=a b c; echo $MY_PASSWORD`
=> "a b cn"
[10] pry(main)> `export MY_PASSWORD="a b c"; echo $MY_PASSWORD`
=> "a b cn"
[11] pry(main)> `export MY_PASSWORD='a b c'; echo $MY_PASSWORD`
=> "a b cn"
[12] pry(main)> require 'shellwords'
=> false
[13] pry(main)> `export MY_PASSWORD=#{Shellwords.escape('a b c')}; echo
$MY_PASSWORD`
=> "a b cn"
[14] pry(main)> backslash = ''
=> ""
[15] pry(main)> Shellwords.escape(backslash)
=> ""
[16] pry(main)> Shellwords.escape(‘$')
=> "$"
50. Ruby as a DSL-Friendly
Language
• optional parentheses
• method_missing
51. Ruby as a CLA Language
• - Distribution can be an obstacle to non-Rubyists (unlike, e.g., go)
• + (As stated previously) it’s a great DSL language!
• + Interpreted, not compiled
• + Rich toolset
• + In addition to MRI, JRuby can be used.
• Can drive JVM code/libraries written in Java, Scala, Clojure, Kotlin,
etc.
• Can be installed where native code cannot be installed but Java
libraries are permitted.
52. The End
Feel free to contact me:
Keith Bennett
@keithrbennett on Twitter, Github, …
Fin