- The document discusses serialization and deserialization of objects for transfer between systems. It compares JSON and optimized JSON formats.
- JSON is more human-readable but has greater memory overhead and reduced compressibility compared to optimized formats like protocol buffers which can improve performance.
- The document recommends designing data transfer objects (DTOs) to optimize for smaller size and better compression when communicating with servers.
This document outlines an presentation on indicators of compromise (IOCs). It discusses IOC standards like OpenIOC and STIX, how to mine and apply IOCs through case studies and practical tasks analyzing network traffic, HTTP logs, and antivirus logs. The document provides examples of IOCs like an exploit pack trace and a Nuclearsploit pack description.
The document discusses Python jails (PyJails), which are CTF problems that provide a limited Python interpreter. The goal is typically to call restricted functions like os.system() or open() to access files. Common solutions leverage attributes of Python objects like __class__, __globals__, and __builtins__ to access the open() function despite restrictions. The document then provides an in-depth explanation of these Python object attributes and how they allow constructing a solution to bypass the restrictions in a PyJail.
Macros and templates in C++ differ in that macros do not perform type checking on parameters and can cause unexpected behavior when parameters are modified, while templates allow the compiler to verify type compatibility and do not have issues with parameter modification. Macros are expanded by the preprocessor before compilation, so errors refer to the expanded code rather than the macro definition. Templates undergo type checking and retain the template parameter types.
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...David Beazley (Dabeaz LLC)
The document describes an embedded error recovery and debugging mechanism for scripting language extensions. It discusses how errors can occur both in script code and extension code built as shared libraries. Debugging errors in extension code is challenging as typical debuggers and tracebacks do not work. The document then presents the Wrapped Application Debugger (WAD) which allows debugging of extension code as if it were part of the script by capturing signals and integrating with the GNU Debugger (GDB).
Best Data Science Ppt using Python
Data science is an inter-disciplinary field that uses scientific methods, processes, algorithms and systems to extract knowledge and insights from many structural and unstructured data. Data science is related to data mining, machine learning and big data.
This document contains information from a Meetup event about Android development. It includes:
- Details about upcoming sessions on topics like views, animations, networking and more
- A summary of announcements from Google I/O 2016 including updates to Firebase, Android Wear and Instant Apps
- Tips and links about optimizing for performance including understanding layouts, measuring GPU usage, and reducing overdraw
- A reminder of an upcoming new course on advanced Android topics like threading and batteries
The document provides information for Android developers about upcoming training opportunities and recommendations for improving app performance. It signposts various Android performance optimization strategies and tools through links and summaries of key concepts.
The document discusses threading in Android applications. It begins by explaining that the main or UI thread is responsible for drawing the user interface and handling input/output events. Any blocking operations on this thread can cause the application to become unresponsive. The document then discusses various approaches for offloading work from the main thread including using AsyncTask, HandlerThread, IntentService, and ThreadPoolExecutor. It provides examples and best practices for implementing each approach to avoid blocking the main thread and ensure responsive user experiences.
This document discusses layout and animation performance in Android. It begins with an overview of how motion is perceived by the human eye and how to achieve smooth motion. It then covers topics like measuring and laying out views, optimizing for the GPU, using hardware layers for animation, and getting size information during animation using ViewTreeObserver. The document provides guidance on profiling performance, reducing unnecessary layout requests, and techniques for creating smooth animations in Android.
This document outlines an presentation on indicators of compromise (IOCs). It discusses IOC standards like OpenIOC and STIX, how to mine and apply IOCs through case studies and practical tasks analyzing network traffic, HTTP logs, and antivirus logs. The document provides examples of IOCs like an exploit pack trace and a Nuclearsploit pack description.
The document discusses Python jails (PyJails), which are CTF problems that provide a limited Python interpreter. The goal is typically to call restricted functions like os.system() or open() to access files. Common solutions leverage attributes of Python objects like __class__, __globals__, and __builtins__ to access the open() function despite restrictions. The document then provides an in-depth explanation of these Python object attributes and how they allow constructing a solution to bypass the restrictions in a PyJail.
Macros and templates in C++ differ in that macros do not perform type checking on parameters and can cause unexpected behavior when parameters are modified, while templates allow the compiler to verify type compatibility and do not have issues with parameter modification. Macros are expanded by the preprocessor before compilation, so errors refer to the expanded code rather than the macro definition. Templates undergo type checking and retain the template parameter types.
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...David Beazley (Dabeaz LLC)
The document describes an embedded error recovery and debugging mechanism for scripting language extensions. It discusses how errors can occur both in script code and extension code built as shared libraries. Debugging errors in extension code is challenging as typical debuggers and tracebacks do not work. The document then presents the Wrapped Application Debugger (WAD) which allows debugging of extension code as if it were part of the script by capturing signals and integrating with the GNU Debugger (GDB).
Best Data Science Ppt using Python
Data science is an inter-disciplinary field that uses scientific methods, processes, algorithms and systems to extract knowledge and insights from many structural and unstructured data. Data science is related to data mining, machine learning and big data.
This document contains information from a Meetup event about Android development. It includes:
- Details about upcoming sessions on topics like views, animations, networking and more
- A summary of announcements from Google I/O 2016 including updates to Firebase, Android Wear and Instant Apps
- Tips and links about optimizing for performance including understanding layouts, measuring GPU usage, and reducing overdraw
- A reminder of an upcoming new course on advanced Android topics like threading and batteries
The document provides information for Android developers about upcoming training opportunities and recommendations for improving app performance. It signposts various Android performance optimization strategies and tools through links and summaries of key concepts.
The document discusses threading in Android applications. It begins by explaining that the main or UI thread is responsible for drawing the user interface and handling input/output events. Any blocking operations on this thread can cause the application to become unresponsive. The document then discusses various approaches for offloading work from the main thread including using AsyncTask, HandlerThread, IntentService, and ThreadPoolExecutor. It provides examples and best practices for implementing each approach to avoid blocking the main thread and ensure responsive user experiences.
This document discusses layout and animation performance in Android. It begins with an overview of how motion is perceived by the human eye and how to achieve smooth motion. It then covers topics like measuring and laying out views, optimizing for the GPU, using hardware layers for animation, and getting size information during animation using ViewTreeObserver. The document provides guidance on profiling performance, reducing unnecessary layout requests, and techniques for creating smooth animations in Android.
Prometheus as exposition format for eBPF programs running on KubernetesLeonardo Di Donato
The kernel knows more than our programs. Stop bloating our applications with copy-and-paste instrumentation code for metrics. Let's go look under the hoods!
Nowadays every application exposes their metrics via an HTTP endpoint readable by using Prometheus. Nevertheless, this very common pattern, by definition only exposes metrics regarding the specific applications being observed.
This talk, and its companion slides, wants to expose the idea, and a reference implementation (https://github.com/bpftools/kube-bpf), of using eBPF programs to collect and automatically expose applications and kernel metrics via a Prometheus endpoint.
It walks through the architecture of the proposed reference implementation - a Kubernetes operator with a custom resource for eBPF programs - and finally links to a simple demo showing how to use it to grab and present some metrics without having touched any application running on the demo cluster.
---
Talk given at Cloud_Native Rejekts EU - Barcelona, Spain - on May 18th, 2019
Lab Handson: Power your Creations with Intel Edison!Codemotion
by Francesco Baldassarri - Come along and play with Intel Edison, for the Internet of Things? Learn about the Developer Kit for IoT, chose your preferred environment and test it – or test all the possibilities? We will be providing information and hands on training for developers interested in testing our solutions in C/C++, Javascript, Arduino, Wyliodrin and Python. Just bring you laptop and we will help you to get started. We will also provide information about our Cloud Analytics platform, and test hardware samples with the Grove Starter Kit – Intel IoT Edition. Visit us anytime and start making! What will you make?
Why should we use TDD to develop in Elixir? When we are applying it correctly? What are the differences that we can find in a code developed with TDD and in code not developed with it? Is it TDD about testing? Really? In this talk, I'll show what is TDD and how can be used it in functional programming like Elixir to design the small and the big parts of your system, showing what are the difference and the similarities between an OOP and FP environment. Showing what is the values of applying a technique like TDD in Elixir and what we should obtain applying it.
carrow - Go bindings to Apache Arrow via C++-APIYoni Davidson
Apache Arrow is a cross-language development platform for in-memory data that specifies a standardized columnar memory format. It provides libraries and messaging for moving data between languages and services without serialization. The presenter discusses their motivation for creating Go bindings for Apache Arrow via C++ to share data between Go and Python programs using the same memory format. They explain several challenges of this approach, such as different memory managers in Go and C++, and solutions like generating wrapper code and handling memory with finalizers.
Designing A Project Using Java ProgrammingKaty Allen
The document discusses the Connector class in the NS simulator. The Connector class is a subclass of NsObject and is the superclass for basic network components that handle packets, such as hubs and links. Connector objects have a single output queue, while Classifier objects can have multiple output queues. When packets traverse connections in the NS simulator, various follow objects are embedded in the connections to log events such as enqueue, dequeue, drop, and receive to trace packet flow.
The document proposes an IT infrastructure for Shiv LLC, a company with locations in Los Angeles, Dallas, and Houston. It recommends implementing an Active Directory domain to enable communication and file sharing across the three locations. A centralized file server would store common files and applications. Each location would have its own local area network, connected to the other sites and to the internet via VPN. Firewalls, antivirus software, and regular backups would help secure the network and protect company data. The design allows for future growth and expansion as the company scales up.
1 Project 2 Introduction - the SeaPort Project seri.docxhoney725342
1
Project 2
Introduction - the SeaPort Project series
For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports.
Here are the classes and their instance variables we wish to define:
SeaPortProgram extends JFrame
o variables used by the GUI interface
o world: World
Thing implement Comparable <Thing>
o index: int
o name: String
o parent: int
World extends Thing
o ports: ArrayList <SeaPort>
o time: PortTime
SeaPort extends Thing
o docks: ArrayList <Dock>
o que: ArrayList <Ship> // the list of ships waiting to dock
o ships: ArrayList <Ship> // a list of all the ships at this port
o persons: ArrayList <Person> // people with skills at this port
Dock extends Thing
o ship: Ship
Ship extends Thing
o arrivalTime, dockTime: PortTime
o draft, length, weight, width: double
o jobs: ArrayList <Job>
PassengerShip extends Ship
o numberOfOccupiedRooms: int
o numberOfPassengers: int
o numberOfRooms: int
CargoShip extends Ship
o cargoValue: double
o cargoVolume: double
o cargoWeight: double
Person extends Thing
o skill: String
Job extends Thing - optional till Projects 3 and 4
o duration: double
o requirements: ArrayList <String>
// should be some of the skills of the persons
PortTime
o time: int
Eventually, in Projects 3 and 4, you will be asked to show the progress of the jobs using JProgressBar's.
2
Here's a very quick overview of all projects:
1. Read a data file, create the internal data structure, create a GUI to display the structure, and let
the user search the structure.
2. Sort the structure, use hash maps to create the structure more efficiently.
3. Create a thread for each job, cannot run until a ship has a dock, create a GUI to show the
progress of each job.
4. Simulate competing for resources (persons with particular skills) for each job.
Project 2 General Objectives
Project 2 - Map class, Comparator, sorting
Use the JDK Map class to write more efficient code when constructing the internal data
structures from the data file.
Implement SORTING using the Comparator interface together with the JDK support for sorting
data structures, thus sorting on different fields of the classes from Project 1.
Extend the GUI from Project 1 to let the user sort the data at run-time.
Documentation Requirements:
You should start working on a documentation file before you do anything else with these projects, and
fill in items as you go along. Leaving the documentation until the project is finished is not a good idea for
any number of reasons.
The documentation should include the following (graded) elements:
Cover page (including name, date, project, your class information)
Design
o including a UML class diagram
o classes, variables and methods: what they mean and why they are there
o tied to the requirements of the project
User's Guide
o how would a user start and run your pro ...
This document summarizes Jonathan Fine's presentation on JavaScript Miller Columns. The presentation covers what Miller Columns are, a demonstration of them, how to specify the user interface and author content, using delegation in frameworks, running tests, sample test data, defining classes in JavaScript, and ways to make JavaScript more Pythonic. The goal is to develop a production version of Miller Columns that relies on library modules and is supported by documentation.
This document provides an agenda and slides for a presentation on introducing big data concepts using open source tools. The presentation covers ingesting and analyzing sample data using Spark SQL, including joining datasets to count the number of books by author. It also demonstrates basic machine learning by loading sample revenue data, applying data quality rules to correct anomalies, and using linear regression to predict revenue for a party of 40 guests. The goal is to make big data concepts accessible to audiences of all experience levels.
Full-stack Web Development with MongoDB, Node.js and AWSMongoDB
Akira Technologies will share its experience of building a universal scalable high-performance platform for conducting surveys. Using MongoDB allowed replacing dozens unique survey systems with a single flexible solution, improved data and questionnaire reusability, simplified data analysis. We will also cover full-stack development and integration with Node.js, Hadoop, deployment to AWS Cloud, offline caching and stress-tecting the entire system with Tsung. A working prototype will be demonstrated including multiple surveys, dynamically rebuilding interface, geolocation, data analysis and visualization.
The document provides information about using the Native Development Kit (NDK) to build native code for Android applications. It discusses what the NDK is, why developers may want to use native code, and how to set up a sample project to call native code from Java using the Java Native Interface (JNI). The sample project implements Fibonacci functions recursively and iteratively in both Java and C++ to demonstrate how to define and call native functions from an Android app.
This document provides an introduction to a course on machine learning. It discusses the large amounts of data now available due to factors like the internet and big data. It also introduces programming and machine learning concepts like data types, variables, conditionals, loops, functions, and classes. Python is presented as a useful programming language for machine learning, with examples of code shown. Setting up an environment with Anaconda and Jupyter Notebook is also covered to allow hands-on coding practice.
Testing is fundamental in software development. Quality gates demand high coverage levels, pull requests need sufficient tests, leading to teams spending considerable time writing and maintaining them. But are we using our tests to their full potential?
'If code is hard to test, the design can be improved'. Starting from this mantra, this deep-dive session unveils hints to simplify code, break-down complexity, and effectively use functional programming. We'll delve into topics like fixture creep, partial mocks, onion architecture, and pure functions, providing numerous best practices and practical tips for your testing.
Be warned: This session may significantly disrupt your work routine and will likely change how you see testing. Attend at your own risk.
This document summarizes integrating the OpenNMS network monitoring platform with modern configuration management tools like Puppet. It discusses using Puppet to provision and automatically configure nodes in OpenNMS from Puppet's configuration data. The authors provide code for pulling node data from Puppet's REST API and generating an XML file for OpenNMS to import the nodes and their configuration. They also discuss opportunities to further improve the integration by developing a Java object model for Puppet's YAML output and filtering imports based on node attributes.
This document provides instructions for a DevSecCon workshop on securing secrets in development pipelines. The workshop aims to help developers and managers address the problem of hardcoded secrets being checked into code repositories by demonstrating how to remove and rotate secrets using a secret management server integrated with Jenkins. Participants will carry out hands-on labs to find hardcoded secrets, replace them with environment variables stored in a secret server, and prevent secrets from being exposed in builds.
JS Fest 2019. Ryan Dahl. Deno, a new way to JavaScriptJSFestUA
From async-await to ArrayBuffers, the JavaScript language has changes significantly in the decade since Node.js was designed. Deno takes advantage of these developments and incorporate lessons learned in the development of Node to provide a new JavaScript platform built on V8 and Rust. This talk will teach the audience how to get started with Deno.
Eric Lafortune - The Jack and Jill build systemGuardSquare
The document discusses the Jack and Jill build system introduced by Google to improve the Android build process. Jack and Jill compile Java code to an intermediate bytecode format called Jayce, allowing for faster builds and optimization. Key points:
- Jack and Jill have replaced the traditional Java compiler and Dalvik dexifier in the Android build tools, speeding up the build process.
- Jill can further optimize the Jayce bytecode, allowing for functionality like bytecode processing that was not possible with just Jack.
- Results have shown that Jack and Jill can reduce build times significantly and produce smaller, faster apps compared to the traditional build system.
When I arrived at Credit Karma I needed to find and connect with people from different teams across multiple projects and verticals.
The problem was that there was no good way to accomplish this except by talking to as many people at the company as possible to find out about the different roles and groups working on things. I decided I needed a way to search for people in order to speed up my workflow.
This resulted in the design and implementation of a pet project called Aura. This presentation is about the process of creating Aura and how it gathered a cult following of support at Credit Karma. I will be covering the problem space, the technology and the methods of winning mind share that led to the execution of the project. This includes React, Electron, Firebase and a host of other libraries and services that allowed Aura to be built over some weekends without the need of a server.
The document discusses MotionLayout, a library that allows for animations and transitions between layouts in Android using ConstraintLayout. Key components of MotionLayout include MotionScene, ConstraintSet, and Transition. ConstraintSet defines start and end states, Transition defines the animation between them, and MotionScene ties it all together. Custom attributes can also be animated between states.
The document discusses MotionLayout in ConstraintLayout 2.0, which allows defining animations through ConstraintSets and transitions between them. It provides an example of a basic animation created by switching between start and end ConstraintSets defined in a MotionScene file. The animation can be triggered by a button click and handles moving a view from the left to the right of its parent layout over 1000 milliseconds.
Prometheus as exposition format for eBPF programs running on KubernetesLeonardo Di Donato
The kernel knows more than our programs. Stop bloating our applications with copy-and-paste instrumentation code for metrics. Let's go look under the hoods!
Nowadays every application exposes their metrics via an HTTP endpoint readable by using Prometheus. Nevertheless, this very common pattern, by definition only exposes metrics regarding the specific applications being observed.
This talk, and its companion slides, wants to expose the idea, and a reference implementation (https://github.com/bpftools/kube-bpf), of using eBPF programs to collect and automatically expose applications and kernel metrics via a Prometheus endpoint.
It walks through the architecture of the proposed reference implementation - a Kubernetes operator with a custom resource for eBPF programs - and finally links to a simple demo showing how to use it to grab and present some metrics without having touched any application running on the demo cluster.
---
Talk given at Cloud_Native Rejekts EU - Barcelona, Spain - on May 18th, 2019
Lab Handson: Power your Creations with Intel Edison!Codemotion
by Francesco Baldassarri - Come along and play with Intel Edison, for the Internet of Things? Learn about the Developer Kit for IoT, chose your preferred environment and test it – or test all the possibilities? We will be providing information and hands on training for developers interested in testing our solutions in C/C++, Javascript, Arduino, Wyliodrin and Python. Just bring you laptop and we will help you to get started. We will also provide information about our Cloud Analytics platform, and test hardware samples with the Grove Starter Kit – Intel IoT Edition. Visit us anytime and start making! What will you make?
Why should we use TDD to develop in Elixir? When we are applying it correctly? What are the differences that we can find in a code developed with TDD and in code not developed with it? Is it TDD about testing? Really? In this talk, I'll show what is TDD and how can be used it in functional programming like Elixir to design the small and the big parts of your system, showing what are the difference and the similarities between an OOP and FP environment. Showing what is the values of applying a technique like TDD in Elixir and what we should obtain applying it.
carrow - Go bindings to Apache Arrow via C++-APIYoni Davidson
Apache Arrow is a cross-language development platform for in-memory data that specifies a standardized columnar memory format. It provides libraries and messaging for moving data between languages and services without serialization. The presenter discusses their motivation for creating Go bindings for Apache Arrow via C++ to share data between Go and Python programs using the same memory format. They explain several challenges of this approach, such as different memory managers in Go and C++, and solutions like generating wrapper code and handling memory with finalizers.
Designing A Project Using Java ProgrammingKaty Allen
The document discusses the Connector class in the NS simulator. The Connector class is a subclass of NsObject and is the superclass for basic network components that handle packets, such as hubs and links. Connector objects have a single output queue, while Classifier objects can have multiple output queues. When packets traverse connections in the NS simulator, various follow objects are embedded in the connections to log events such as enqueue, dequeue, drop, and receive to trace packet flow.
The document proposes an IT infrastructure for Shiv LLC, a company with locations in Los Angeles, Dallas, and Houston. It recommends implementing an Active Directory domain to enable communication and file sharing across the three locations. A centralized file server would store common files and applications. Each location would have its own local area network, connected to the other sites and to the internet via VPN. Firewalls, antivirus software, and regular backups would help secure the network and protect company data. The design allows for future growth and expansion as the company scales up.
1 Project 2 Introduction - the SeaPort Project seri.docxhoney725342
1
Project 2
Introduction - the SeaPort Project series
For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports.
Here are the classes and their instance variables we wish to define:
SeaPortProgram extends JFrame
o variables used by the GUI interface
o world: World
Thing implement Comparable <Thing>
o index: int
o name: String
o parent: int
World extends Thing
o ports: ArrayList <SeaPort>
o time: PortTime
SeaPort extends Thing
o docks: ArrayList <Dock>
o que: ArrayList <Ship> // the list of ships waiting to dock
o ships: ArrayList <Ship> // a list of all the ships at this port
o persons: ArrayList <Person> // people with skills at this port
Dock extends Thing
o ship: Ship
Ship extends Thing
o arrivalTime, dockTime: PortTime
o draft, length, weight, width: double
o jobs: ArrayList <Job>
PassengerShip extends Ship
o numberOfOccupiedRooms: int
o numberOfPassengers: int
o numberOfRooms: int
CargoShip extends Ship
o cargoValue: double
o cargoVolume: double
o cargoWeight: double
Person extends Thing
o skill: String
Job extends Thing - optional till Projects 3 and 4
o duration: double
o requirements: ArrayList <String>
// should be some of the skills of the persons
PortTime
o time: int
Eventually, in Projects 3 and 4, you will be asked to show the progress of the jobs using JProgressBar's.
2
Here's a very quick overview of all projects:
1. Read a data file, create the internal data structure, create a GUI to display the structure, and let
the user search the structure.
2. Sort the structure, use hash maps to create the structure more efficiently.
3. Create a thread for each job, cannot run until a ship has a dock, create a GUI to show the
progress of each job.
4. Simulate competing for resources (persons with particular skills) for each job.
Project 2 General Objectives
Project 2 - Map class, Comparator, sorting
Use the JDK Map class to write more efficient code when constructing the internal data
structures from the data file.
Implement SORTING using the Comparator interface together with the JDK support for sorting
data structures, thus sorting on different fields of the classes from Project 1.
Extend the GUI from Project 1 to let the user sort the data at run-time.
Documentation Requirements:
You should start working on a documentation file before you do anything else with these projects, and
fill in items as you go along. Leaving the documentation until the project is finished is not a good idea for
any number of reasons.
The documentation should include the following (graded) elements:
Cover page (including name, date, project, your class information)
Design
o including a UML class diagram
o classes, variables and methods: what they mean and why they are there
o tied to the requirements of the project
User's Guide
o how would a user start and run your pro ...
This document summarizes Jonathan Fine's presentation on JavaScript Miller Columns. The presentation covers what Miller Columns are, a demonstration of them, how to specify the user interface and author content, using delegation in frameworks, running tests, sample test data, defining classes in JavaScript, and ways to make JavaScript more Pythonic. The goal is to develop a production version of Miller Columns that relies on library modules and is supported by documentation.
This document provides an agenda and slides for a presentation on introducing big data concepts using open source tools. The presentation covers ingesting and analyzing sample data using Spark SQL, including joining datasets to count the number of books by author. It also demonstrates basic machine learning by loading sample revenue data, applying data quality rules to correct anomalies, and using linear regression to predict revenue for a party of 40 guests. The goal is to make big data concepts accessible to audiences of all experience levels.
Full-stack Web Development with MongoDB, Node.js and AWSMongoDB
Akira Technologies will share its experience of building a universal scalable high-performance platform for conducting surveys. Using MongoDB allowed replacing dozens unique survey systems with a single flexible solution, improved data and questionnaire reusability, simplified data analysis. We will also cover full-stack development and integration with Node.js, Hadoop, deployment to AWS Cloud, offline caching and stress-tecting the entire system with Tsung. A working prototype will be demonstrated including multiple surveys, dynamically rebuilding interface, geolocation, data analysis and visualization.
The document provides information about using the Native Development Kit (NDK) to build native code for Android applications. It discusses what the NDK is, why developers may want to use native code, and how to set up a sample project to call native code from Java using the Java Native Interface (JNI). The sample project implements Fibonacci functions recursively and iteratively in both Java and C++ to demonstrate how to define and call native functions from an Android app.
This document provides an introduction to a course on machine learning. It discusses the large amounts of data now available due to factors like the internet and big data. It also introduces programming and machine learning concepts like data types, variables, conditionals, loops, functions, and classes. Python is presented as a useful programming language for machine learning, with examples of code shown. Setting up an environment with Anaconda and Jupyter Notebook is also covered to allow hands-on coding practice.
Testing is fundamental in software development. Quality gates demand high coverage levels, pull requests need sufficient tests, leading to teams spending considerable time writing and maintaining them. But are we using our tests to their full potential?
'If code is hard to test, the design can be improved'. Starting from this mantra, this deep-dive session unveils hints to simplify code, break-down complexity, and effectively use functional programming. We'll delve into topics like fixture creep, partial mocks, onion architecture, and pure functions, providing numerous best practices and practical tips for your testing.
Be warned: This session may significantly disrupt your work routine and will likely change how you see testing. Attend at your own risk.
This document summarizes integrating the OpenNMS network monitoring platform with modern configuration management tools like Puppet. It discusses using Puppet to provision and automatically configure nodes in OpenNMS from Puppet's configuration data. The authors provide code for pulling node data from Puppet's REST API and generating an XML file for OpenNMS to import the nodes and their configuration. They also discuss opportunities to further improve the integration by developing a Java object model for Puppet's YAML output and filtering imports based on node attributes.
This document provides instructions for a DevSecCon workshop on securing secrets in development pipelines. The workshop aims to help developers and managers address the problem of hardcoded secrets being checked into code repositories by demonstrating how to remove and rotate secrets using a secret management server integrated with Jenkins. Participants will carry out hands-on labs to find hardcoded secrets, replace them with environment variables stored in a secret server, and prevent secrets from being exposed in builds.
JS Fest 2019. Ryan Dahl. Deno, a new way to JavaScriptJSFestUA
From async-await to ArrayBuffers, the JavaScript language has changes significantly in the decade since Node.js was designed. Deno takes advantage of these developments and incorporate lessons learned in the development of Node to provide a new JavaScript platform built on V8 and Rust. This talk will teach the audience how to get started with Deno.
Eric Lafortune - The Jack and Jill build systemGuardSquare
The document discusses the Jack and Jill build system introduced by Google to improve the Android build process. Jack and Jill compile Java code to an intermediate bytecode format called Jayce, allowing for faster builds and optimization. Key points:
- Jack and Jill have replaced the traditional Java compiler and Dalvik dexifier in the Android build tools, speeding up the build process.
- Jill can further optimize the Jayce bytecode, allowing for functionality like bytecode processing that was not possible with just Jack.
- Results have shown that Jack and Jill can reduce build times significantly and produce smaller, faster apps compared to the traditional build system.
When I arrived at Credit Karma I needed to find and connect with people from different teams across multiple projects and verticals.
The problem was that there was no good way to accomplish this except by talking to as many people at the company as possible to find out about the different roles and groups working on things. I decided I needed a way to search for people in order to speed up my workflow.
This resulted in the design and implementation of a pet project called Aura. This presentation is about the process of creating Aura and how it gathered a cult following of support at Credit Karma. I will be covering the problem space, the technology and the methods of winning mind share that led to the execution of the project. This includes React, Electron, Firebase and a host of other libraries and services that allowed Aura to be built over some weekends without the need of a server.
The document discusses MotionLayout, a library that allows for animations and transitions between layouts in Android using ConstraintLayout. Key components of MotionLayout include MotionScene, ConstraintSet, and Transition. ConstraintSet defines start and end states, Transition defines the animation between them, and MotionScene ties it all together. Custom attributes can also be animated between states.
The document discusses MotionLayout in ConstraintLayout 2.0, which allows defining animations through ConstraintSets and transitions between them. It provides an example of a basic animation created by switching between start and end ConstraintSets defined in a MotionScene file. The animation can be triggered by a button click and handles moving a view from the left to the right of its parent layout over 1000 milliseconds.
The document discusses features from Google I/O and Android Q, including:
- Kotlin and in-app updates
- Changes in Android Q like the new navigation system, scoped storage, location permissions, settings panel actions, and dark mode
- Implementing dark theme support using DayNight and setting different themes for light and dark modes
This document summarizes a presentation on new features in Google I/O and Android Q. It discusses Kotlin, in-app updates, the new navigation system in Android Q including gestures, scoped storage, location changes, dark mode, and Jetpack improvements for security and compose. The navigation system in Android Q uses gestures for navigation rather than buttons. Developers need to account for the safe zone and can exclude areas from gestures. In-app updates allow flexible or immediate updates within an app.
The document discusses Clean Architecture and provides an example of implementing it using a Movie Night app. It describes separating the app into Presentation, Data, and Domain layers with specific responsibilities. The Domain layer contains entities, use cases, and interfaces. The Data layer encapsulates data sources and mappers. The Presentation layer connects everything using ViewModels, LiveData, and observing lifecycle changes. It demonstrates how data flows from the Data layer through UseCases to the Presentation layer and updates the UI.
This document provides information about an Android development community and courses. It includes details about course topics like fundamentals, UI/UX, and advanced topics. It lists mentors and their backgrounds. Event details are provided for courses in Moscow and a mentors program. Links are included to sign up for courses and view the community on Facebook.
The document discusses Retrofit, a type-safe HTTP client for Android. It describes how to initialize Retrofit by defining interfaces for APIs, creating a Retrofit instance, and making network calls. It also covers using interceptors to log requests/responses and add authentication headers to requests. Custom interceptors allow controlling the behavior of authentication based on internal request headers.
The document discusses threads and handlers in Android. It contains the following key points:
1. Threads allow for concurrent execution while the main thread is responsible for UI updates. Additional threads can be used for network requests and background tasks.
2. Handlers allow threads to communicate by posting messages and runnables to a message queue. This avoids direct method calls between threads.
3. The main thread has a looper by default while custom threads require adding a looper. Handlers are used to post tasks from a thread's looper queue back to the main thread for UI updates.
This document provides wifi login credentials for Samsung-Next-Guest with the password NEXT@tlv4ever. It then introduces the largest Android community in Israel and lists its staff, activities, and locations. It promotes an IDC entrepreneurship program and provides details on its structure, mentors, advisory board, and past alumni. Finally, it advertises upcoming Android advanced courses on UI, GPU, animations, clean architecture, CPU, memory, and threads.
All the support you need. Support libs in AndroidVitali Pekelis
The support library provides support for older Android versions by backporting new features and components. It includes libraries for app compatibility, fragments, cardview, recyclerview and more. The support library works by including shims that check the Android version and use the native implementation where available, or a support version as needed. It is important to use consistent support library versions and follow best practices around configuration, versioning and compatibility. The support library continues to be updated regularly with new features, bug fixes and improvements to support developers.
This document provides best practices for developing SDKs. It discusses defining the SDK's purpose and services, planning the public API with an easy to use builder pattern and exceptions, planning the internal architecture with minimal dependencies and permissions, writing code with unique prefixes and lifecycle considerations, including sample apps and documentation, packaging as an AAR file, and tools for testing like Battery Historian and Stetho.
The document provides an overview of dependency injection and how it can be implemented using Dagger2 in Android. It discusses dependency injection principles like constructor injection and how modules, components, and clients work together in Dagger2. Key points covered include defining module classes to provide dependencies, component classes to assemble modules and inject clients, and using dependency injection annotations like @Inject in client classes. The document emphasizes best practices like separating dependencies into multiple modules and avoiding direct instantiation in clients.
This document discusses an upcoming hackathon and provides an agenda for a session on design patterns. The session will cover topics like code smells, different categories of design patterns (creational, structural, behavioral), and examples from Android like the Observer pattern implemented in ViewTreeObserver and builder patterns like AlertDialog.Builder and NotificationCompat.Builder. The goals are to learn about and inspire the use of design patterns to improve code readability, writability, and communication.
The document discusses advanced Android threading concepts including:
1. The main thread is responsible for UI rendering and user interactions. Blocking it can cause app jank and ANRs.
2. Additional threads can be created using Thread or Runnable classes and started to offload work.
3. The Handler, Looper, and MessageQueue classes provide an asynchronous messaging system for communication between threads without blocking. A Looper dispatches messages that are sent via a Handler.
This document discusses best practices for designing mobile user experiences that transition between iOS and Android platforms. It emphasizes that iOS and Android have different design philosophies and patterns that must be understood. Specifically, it notes that iOS focuses on simplicity, clarity and depth while Android follows Material Design principles of bold graphics and intentional motion. Directly porting an iOS design to Android is discouraged as the two platforms have different navigation, buttons, notifications and other interface conventions. The document provides an overview of major Android design components and patterns to consider when adapting a mobile experience for both platforms.
Loaders are objects that abstract data retrieval and observation to simplify handling the activity lifecycle and data changes. CursorLoaders make it easy to access data from a content provider using a few simple steps. Loaders are initialized with a unique ID and callbacks handle the loading process, caching data between configuration changes. This prevents needing to reload data when a device rotates.
This lesson covers providing data correctly in Android applications using content providers and loaders. It discusses using SQLite databases to store structured data and querying the data using SQL statements like SELECT, UPDATE, INSERT, and DELETE. The document provides examples of creating a database table and performing CRUD operations on it. It also mentions challenges like avoiding SQL injection and handling database upgrades.
This document discusses the process of rendering views and pixels on the screen from a high level object to pixels. It covers the key steps of measure, layout, and draw and explains important concepts like double buffering, vsync, and avoiding overdraw. Key topics include how the GPU helps with rasterization, using viewtreeobserver for size changes, different root view types, and using constraint layout for a more optimized layout. It emphasizes best practices like minimizing unnecessary layout requests and using tools like hierarchy viewer and GPU profiling.
This document discusses building clean and flexible Android architecture using principles like separation of concerns, single responsibility, and dependency injection. It recommends patterns like MVVM and VIPER to separate an app's business logic from its UI framework. The key aspects are interfaces for Views, Presenters, Interactors and Repositories. Sample code shows how to implement these patterns using interfaces, dependency injection and testing. The goal is architecture that is easy to iterate on, collaborate with and test independently of Android frameworks and libraries.
This document summarizes an Android design workshop held by Britt Barak and Figure 8. The workshop covered topics like color, imagery, meaningful motion, and the Android design vision. Attendees learned about using color palettes and themes, different types of images like bitmaps and vectors, animation principles, and how to design intuitive and delightful experiences for Android users. The workshop provided practical tips and examples to help developers and designers create high-quality Android apps adhering to Material Design standards.
12. 30 / 10 / 2016
New course coming
30 / 10 / 2016
New course coming
13. 30 / 10 / 2016
New course coming
30 / 10 / 2016
New course coming
● +: Networking Debt.
● A: CPU
○ Theory
○ Practice
● B: Battery
○ Theory
○ Practice
10/08/2016
CPU & Battery
14. - Assess the problem and
establish acceptable behavior.
- Measure perf b4 modification.
- Identify bottleneck.
- Remove bottleneck.
- Measure perf after modification.
- If better, adopt.
If worse, put it back.
Methods of Systematic performance improvement
https://en.wikipedia.org/wiki/Performance_tuning
16. Last month, Yonatan talked about
- Networks basics
- Retrofit 2.0
- Caching, Prefetching
- Bundling-up with Android (~ Sync Adapters),
Or at least playing nice (~ Job Scheduler)
- Doze (Will be revised
today)Really, check it out. https://docs.google.com/presentation/d/1maecLjfOOy38_VJWc2YKzoXGSR2ulF3KLG6wmoJ3OwE/edit?usp=sharing
22. GZip
When communicating with servers, it makes sense to compress the
data, and it’s quite easy to do so.
GZip is a GNU-Licensed compression algorithm, which is a merge of
2 compression algorithms: Lampel-Ziv-77 and Huffman-Codes,
That works in 32kb chunks.
23. GZip - LZ77 Concept - Back References
קולגלגלהמתגלגלמלמטה
למעלה
מרכבותסתומותהולכות
ומתגלגלות
Credit for the example: Orevi Joe
2,28,4
7,27,210,2 49,4 41,2
5,2
24. How to mess up compressibility
When you’re sending arrays or lists of large objects, the JSON format
OOB has a lot of redundancy, and if the object is large, then some of
the references fail.
25. How to mess up compressibility - Solution
Consider crafting a DTO that would be optimized for smaller footprint
and compression.
Have numbers and similar strings close to each other.
Consider refactoring a list-of-object to an object-of-lists.
26. JSON Class Representation
[
{
"id": 314,
"shoe_size": 42,
"show_image": "-- 32kB Base64 representation of a PNG --",
},
{
"id": 42,
"shoe_size": 42,
"show_image": "-- 32kB Base64 representation of another PNG --",
},
{
"id": 456,
"shoe_size": 42,
"show_image": "-- 32kB Base64 representation of a different PNG --",
},
}
27. JSON Class Representation
{
"id": [314,42,456],
"shoe_sizes": [42,42,42],
"show_images": [
"-- 32kB Base64 representation of a PNG --",
"-- 32kB Base64 representation of another PNG --",
"-- 32kB Base64 representation of a different PNG --"
]
}
31. Process
1.Create schema
2.Compile schema with flatc compiler
3.Import generated files into your project
4.Read from byte[]:
java.nio.ByteBuffer buf = builder.dataBuffer();
// Deserialize the data from the buffer.
33. Any Questions?
● +: Networking Debt.
● A: CPU
○ Theory
○ Practice
● B: Battery
○ Theory
○ Practice
10/08/2016
CPU & Battery
34. Part A: CPU
A
“Tears come from the heart and not from the brain. ”
Leonardo Di Vinci
35. Understanding CPU
- How does my phone know Java?
- Big-O Notation and an intro to Data Structures
- Auto-Boxing
- Optimized Data Structures (Sparse Arrays and Maps)
- Things we can’t control
36. But before we begin,
something totally unrelated..
What is Eyjafjörður?
38. Build → Execute
On your PC, Gradle does a really complicated
Build process, that takes the Java Code and
Turns it into an APK.
We’ll go into what it does,
So we can appreciate the beauty.
39. Build → Execute
Simplified Walkthrough the build:
A. Manifest Merging
B. AAPT goes over the RES file and produces R.java and resources
C. Javac takes the code and produces a JAR file
D. ProGuard optimizes the JAR(s)
E.Dx takes the JAR(s) and produces a DEX file
F. AAPT takes everything (+ the Manifest), signs it and packs it to an APKRead more: https://developer.android.com/studio/build/index.html
40. The APK is unzipped on the device.
The customized Java Runtime loads and executes your code.
Build → Execute
If KitKat (4.4) and below
DALVIK
If Lollipop and above
ART
42. Build → Execute: Dalvik
Dalvik is a VM that..:
- uses dex (and odex) files to run programs.
Thanks, DEX, for using a short to index the method table. #65K
- Instead of being Stack based (Like the JVM), it is Register based.
- It’s main idea:
Being optimized for low memory consumption.
43. Build → Execute: Dalvik
And then there was Froyo (2.2)
Google added an amazing ability,
called JIT compiling (by trace).
JIT - Compile parts (~by trace) of the “ByteCode” to Machine-Code.
Performance was better - but the optimization options were limited.
44. Runtime-Perf: What to measure?
These are some of the KPIs for the Runtime:
- Performance
- App Startup Time
- Jank
- Battery Footprint
- Memory Footprint
45. Build → Execute: Art
The Art (~Android Runtime) uses the same dx format,
But instead of JIT-Compiling, uses AOT-Compiling.
When installing an app, the phone compiles the entire dex to
machine-code, and binds (statically link) whatever it needs
to the framework.
46.
47.
48. Build → Execute: Art
In N, ART does both JIT and AOT.
It profiles your code, and decides which
methods it should compile.
Since compilation is not a trivial task, it does it
only when the device is 100% charged and
connected to the charger.
Read: In Nougat, connecting your phone to a charger makes it work faster.
49. So, Is your phone a computer or not?
Why Yes:
It has a CPU, Memory, GPU, an OS,
It runs Java
Why No:
Not the same VM,
Not the same amounts of CPU, Memory,
Not the same usage patterns and expectations.
51. Big-O and Data Structures
This is what we were taught in Intro2CS, DataStructures, and etc.:
- Considering very large inputs (limn->∞) and ignore constants
- The Big O Notation: “1.02n” >> “n3 + 5n2” === “30n3” > “1000n2”
- Counting operations
- Accessing a memory cell by address is O(1)
Loops on some input are O(n),
- Trade-off Everything
53. Big-O and Data Structures
Some rules still apply in mobile:
- Use the right algorithm,
- Use the right data-structure,
- Be Smart
Don’t forget that this is a mobile device.
54. Storing a list of numbers
You need to store n integers.
If you know what n is, use an array.
If you don’t - What do you do?
(Support insert-last
and get operation)
55. Possible Solution:
Create an array-like interface:
int get(int index)
void insertLast(int value)
Guess or get an initial size, and if needed,
Create a new array with more room,
copy the items, and use the new array.
Discuss.
56. Possible Solution, Now with Generics:
Create an array-like interface:
T get(int index)
void insert(T value, int index)
This is also called an ArrayList<T>.
Are there any
implications? Discuss.
57. How Generics Work
In Java,
The compiler translates your <T>s to Objects, and adds casting as
necessary.
So, you can’t use int (or boolean, or double, or long, …), so instead,
you use Integer (or Boolean, Double, or Long), which do the same
thing, more or less.
58. Now, consider these codes
int i = 5;
Integer i = 5;
int j = i + 2;
Integer j = i + 2;
What do these compile to?
59. Now, consider these codes
int i = 5;
Integer i = 5;
int j = i + 2;
Integer j = i + 2;
public void noBoxing();
Code:
0: iconst_5
1: istore_1
2: iload_1
3: iconst_2
4: iadd
5: istore_2
public void withBoxing();
Code:
0: iconst_5
1: invokestatic #2 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
4: astore_1
5: aload_1
6: invokevirtual #3 // Method java/lang/Integer.intValue:()I
9: iconst_2
10: iadd
11: invokestatic #2 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
14: astore_2
15: return
60. Now, consider this code
ArrayList<Integer> list =
new ArrayList<Integer>();
list.add(1);
list.add(2);
Same issue.
61. Now, consider this code
ArrayList<Integer> list = new ArrayList<Integer>();
For (int i = 0; i++; i < list.size()){
int value = list.get(i);
}
Same issue.
62. AutoBoxing
To handle previous code samples,
The runtime automagically takes your int, puts it inside a box, called
Integer and stores it in the heap.
This is AutoBoxing.
Colt McAnlis: https://youtu.be/dgzOwuoXVJU
65. Storing a list of objects, by Key
You need to store n objects, by key.
If you know what n is, use an array.
If you don’t - What do you do?
(Support an insert and get operations)
66. Storing a list of objects, by Key
Consider this API:
void insert(key, value)
int get(key)
67. What’s in a key?
Consider this task:
You have a list of devices that you want to retrieve by their IMEI.
Here’s a sample IMEI: 53865487920334156 (17 digits)
It doesn’t make sense to have an array with 1017 cells…
Same for Creditcards, ID numbers, GUIDs, and mostly anything that has an id and there’s a lot of it in the world, and you
will not need them all
68. Here’s what we’ll do
- Squash the key to something we can handle (~HashCode),
Store according to the key
- Handle Conflicts somehow (Open-hash / Closed-hash)
- Handle resizing somehow
- If we add Generics, This will be called
java.util.HashMap<TKey, TValue>
69. Is it the right algorithm?
- Inserting: Amortized O(1), but up to O(n)
- Searching: Amortized O(1), but up to O(n)
- Memory Consumption - Not so good.
70. What’s wrong with it?
- If you’re using Integers or Longs (IMEIs), for keys or for values,
you might hit AutoBoxing.
- The “Entry” class (internal implementation detail) is another layer
of abstraction that gets allocated that we don’t need.
- Compacting and Expending are expensive
71. HashMap solution 1: ArrayMaps
ArrayMaps (from android.util) use a different algorithm:
It uses 2 arrays - one for the values and the keys, and one for the
hashes, which is kept sorted.
Colt McAnlis: https://youtu.be/ORgucLTtTDI
72. HashMap solution 1: ArrayMaps
ArrayMaps (from android.util) use a different algorithm:
It uses 2 arrays - one for the values and the keys, and one for the
hashes, which is kept sorted.
Insertion - O(n)
Searching - O(log n)
Colt McAnlis: https://youtu.be/ORgucLTtTDI
73. HashMap solution 1: ArrayMaps
ArrayMaps (from android.util) use a different algorithm:
It uses 2 arrays - one for the values and the keys, and one for the
hashes, which is kept sorted.
Insertion - O(n)
Searching - O(log n)
Memory consumption - much better, but autoboxing is still an issue
Colt McAnlis: https://youtu.be/ORgucLTtTDI
74. HashMap Solution #1: ArrayMaps
This data-structure is useful on mobile for 2 use-cases:
75. HashMap solution 2: SparseArrays and co.
Sparse Arrays are optimized for no-autoboxing, and use similar
algorithms for storage as ArrayMaps.
Use SparseArrays when the keys or the values are primitives (partial):
Colt McAnlis: https://youtu.be/I16lz26WyzQ
Key Type Value Type SparseArray
Integer Object SparseArray
Integer Boolean SparseBooleanArray
Long Object LongSparseArray
76. Important for job interviews
SparseArrays and Array-Maps:
GET - Requires binary search - O(log n)
INS - Require binary search and moving - O(n)
(and they also don’t retain order, נבלות)
77. Another “what does this compiles to”
Consider the following code:
// from Iterators.foo();
ArrayList<Foo> foos = new ArrayList<Foo>();
for (Foo foo : foos){
// … Do something with foo
}
78. public void foo();
Code:
0: new #2 // class java/util/ArrayList
3: dup
4: invokespecial #3 // Method java/util/ArrayList."<init>":()V
7: astore_1
8: aload_1
9: invokevirtual #4 // Method java/util/ArrayList.iterator:()Ljava/util/Iterator;
12: astore_2
13: aload_2
14: invokeinterface #5, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z
19: ifeq 35
22: aload_2
23: invokeinterface #6, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
28: checkcast #7 // class Foo
31: astore_3
32: goto 13
35: return
What does it compile to? (In Bytecode)
79. Now, Let’s compare
public void baz(){
ArrayList<Foo> foos = new ArrayList<Foo>();
int size = foos.size();
for (int i = 0; i < size; i++){
Foo foo = foos.get(i);
// Do something with foo...
}
}
81. Hmm. Android vs. Java?
- Java: use for(int i : list) because that’s how we do
it in java.
- Android: do what Java says, especially if you’re using
an iterator. https://developer.android.com/training/articles/perf-
tips.html#Loops
- Colt McAnlis:
Use a CS101 for loop, avoid the iterator if possible.
See for yourself: https://youtu.be/MZOf3pOAM6A
82. One thing we can’t control
Android can change the speed of the CPU to conserve battery.
Slower CPU ⇒ Battery lasts longer
This might cause 2 symptoms:
- Dropped frames (it takes 20ms for the CPU to speed-up again)
- Normal things take longer
ThisColt McAnlis: https://youtu.be/c8u3fEM3JG0
84. Any Questions?
● +: Networking Debt.
● A: CPU
○ Theory
○ Practice
● B: Battery
○ Theory
○ Practice
10/08/2016
CPU & Battery
85. A recent study showed that 100% of your users don’t use
your app when their battery is out of juice.
The Battery
B
86. Understanding Battery
- Battery theory
- As A Developer, How to reduce battery usage
- As ANDROID, How to reduce battery usage
87. Measurement Units
Ampere (A) is a unit of electric current.
It describes how much power
something needs at an instant.
Milli-Ampere (mA) is the unit that
we actually use, because it’s a mobile
device, and things don’t use a lot of power.
Example: My GPS needs 140mA, and my 4G chip needs 180mA.
https://en.wikipedia.org/wiki/Ampere
88. Measurement Units
However, it doesn’t take time into considerations -
That’s why we use mAh.
Example:
Nexus 5X battery is 2,700 mAh
https://en.wikipedia.org/wiki/Ampere-hour
89. Battery Theory
My GPS needs 140mA, and my 4G chip needs 180mA.
Which is better for getting a location:
using the GPS or the 4G chip?
90. Battery Theory
My GPS needs 140mA, and my 4G chip needs 180mA.
Getting a GPS lock takes about 25 seconds, so:
25s x 140mA ~= 1mAh
91. Battery Theory
My GPS needs 140mA, and my 4G chip needs 180mA.
Getting network location lock takes about 2 seconds, so:
2s x 180mA ~= 0.1mAh
Jeffrey Sharkey: https://youtu.be/OUemfrKe65c (From Google I/O 2009)
92. So, What’s killing your battery?
The
Screen
The
Modem
The
GPS
Foreground work Background work
94. So what can you do?
Taste of what’s possible: https://developer.android.com/reference/android/app/job/JobInfo.Builder.html
Reduce
Keep
background
activity to
minimum
Defer
Wait with the
activity until the
device is
charging
Coalesce
Try to piggy-back,
batch, queue or group
background work with
other background
tasks that has to be
done
95. The battery and the Radio
True or false:
3G and WIFI need (more or less)
the same amount of power ~180 mAh
96. The battery and the Radio
However, downloading 100mb
via 3G radio takes 1’56’’
and via WIFI 0’10’’
180mAh x 10sec = 0.5 mAh
180mAh x 116sec = 5.8 mAh
97. The battery and the Radio
Also:
- Radio wake-up costs a lot of power
- Radio has to stay awake for responses (and responses of responses)
- Radio goes to sleep after about ~20sec of activity.
Dive Deeper: Ran Nachmani @ Big Android BBQ 2015: https://youtu.be/LO_Swql0zVg
98. The battery and the Radio
So what can you do?
I/O 2016: https://youtu.be/VC2Hlb22mZM
Reduce Defer Coalesce
- If it’s not important - Don’t
- Reduce payload (GZIP, FlatBuffers)
- Use the JobScheduler to wait for
- Charger
- WIFI
- Piggy-back with
SyncAdapters
- Prefetch and Batch
Change usage pattern according to network state!
99. Tool: DDMS / ADM
The Android Device Monitor can really help in understanding what the
network is doing.
101. GPS in action
Your device can find its locations using 3 devices:
- The GPS, which uses few satellites for exact location.
- The 3G network that uses cell-tower triangulation.
- Some WIFI networks can also hint of where you are.
Each of these is a location provider.
102. Most use the Fused Location Provider from Google Play services.
It merges all location providers for bests results and optimal
footprint.
protected void createLocationRequest() {
LocationRequest mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(10000);
mLocationRequest.setFastestInterval(5000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
GPS in action
https://developer.android.com/training/location/change-location-settings.html
103. GPS in action
True or false:
You might be updated on location
More frequent than you ask.
104. The battery and the GPS
We already talked about using the GPS vs the 3G data.
What else can we do?
More: Colt McAnlis: https://youtu.be/81W61JA6YHw
Reduce Defer Coalesce
- Ask for less accurate location
- Ask for less updates
- Limit number of callbacks
- Ask for less updates - Piggy-back other GPS
requests
105. Reduce the location battery footprint
of your app.
Set the priority for the accuracy you need.
PRIORITY_LOW_POWER (~10km "city" accuracy)
PRIORITY_BALANCED_POWER_ACCURACY (~100m "block" accuracy)
PRIORITY_HIGH_ACCURACY (accurate as possible at the expense of
battery life)
The battery and the GPS
https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest
Reduce
- Ask for less accurate location
- Ask for less updates
- Limit number of callbacks
106. The battery and the GPS
Reduce the location battery footprint
of your app.
Set the interval as high as you can.
mLocationRequest.setInterval(10000);
https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest
DeferReduce
- Ask for less accurate location
- Ask for less updates
- Limit number of callbacks
107. The battery and the GPS
Reduce the location battery footprint
of your app.
Also limit the number of callbacks.
mLocationRequest.setFastestInterval(5000);
https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest
Reduce
- Ask for less accurate location
- Ask for less updates
- Limit number of callbacks
108. The battery and the GPS
Reduce the location battery footprint
of your app.
Use PRIORITY_NO_POWER to passively listen for location updates
from other clients.
https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest
- Piggy-back other GPS requests
Coalesce
112. Wasting screen / cpu energy
Sometimes, you want to keep the device awake to do some work.
Perhaps you want the screen to stay on while watching a video, or wake-up from sleep to calculate
something periodically.
This can be done with WakeLocks:
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"MyWakelockTag");
wakeLock.acquire();
Training: https://developer.android.com/training/scheduling/wakelock.html
Colt McAnlis: https://youtu.be/reMau7d0yeg
113. Wasting screen / cpu energy
However, it’s really important to handle WakeLocks with care.
- Beware of dependencies
(User data, server faults, etc.)
- Always use a timeout
Training: https://developer.android.com/training/scheduling/wakelock.html
Colt McAnlis: https://youtu.be/reMau7d0yeg
114.
115. Short story
Friday, ~8:00AM
My phone has ~22%
Mr. Levin: “Put it on the floor in your bag, don’t touch it,
and let it go into DOZE.”
117. Doze
Introduced with Marshmallow (6.0, API 23),
https://developer.android.com/training/monitoring-device-state/doze-standby.html
118. Doze
When the device is in this state:
- Network access is suspended
- The device ignores wake locks
- Alarms (a la AlarmManager) don’t get execute (unless While-Idle or setAlarmClock)
- No SyncAdapters or JobSchedulers
- System also does not do Wifi Scans
https://developer.android.com/training/monitoring-device-state/doze-standby.html
121. If you have a problem with Doze, It means that you have a problem
with a simple fact:
Your users have life
They might forget their tablet at home when they leave for a 3 days
trip to Amsterdam, and would love for it to have battery when they
come back from their trip.
#TrueStory #FML
Doze
Joanna Smith, Big Android BBQ 2015: https://youtu.be/Rwshwq_vI1s
122. Doze
Besides that,
Don’t do anything.
If you’re using all the stuff we taught, you should be good
- SyncAdapters, JobSchedulers will work as expected.
- Alarms are to be watched, and other network access too.
Joanna Smith, Big Android BBQ 2015: https://youtu.be/Rwshwq_vI1s
123. Doze
These are the states that the phone can be in:
Joanna Smith, Big Android BBQ 2015: https://youtu.be/Rwshwq_vI1s
Active Inactive
Idle
Pending
Idle Idle
Maintenance
This transition takes ~2h
Remember my story? About a 45m lecture?
124. Doze
In Android Nougat,
The terms for entering Doze were loosened.
This means that even while the device is in the user’s
pocket it can go into Doze. Still same principle apply:
Don’t do anything about it.