An introduction to the elixir language and the otp framework. A workshop was done and the code can be found here: https://github.com/mendrugory/elixir_and_otp_apps_presentation_1
The Ring programming language version 1.2 book - Part 18 of 84Mahmoud Samir Fayed
This document describes MySQL functions in Ring for interacting with MySQL databases, including functions for:
- Initializing and closing connections
- Executing queries and retrieving results
- Getting error and info messages
- Escaping strings, committing transactions, and more
It provides the syntax for each function and examples of their use for common tasks like connecting, querying, inserting and retrieving data.
The document discusses Scala as a potential replacement for Java on the JVM. It provides quotes from several influential Java developers who express their view that Scala is the most capable replacement for Java currently available on the JVM, and the momentum behind Scala is growing. The document also briefly outlines an agenda for introducing Scala, covering basic syntax, patterns, functions, classes and traits.
The Ring programming language version 1.3 book - Part 20 of 88Mahmoud Samir Fayed
This document provides documentation on using SQLite database functions in Ring. It introduces the sqlite_init(), sqlite_open(), sqlite_execute(), and sqlite_close() functions for initializing a SQLite object, opening a database, executing SQL statements, and closing the database. An example shows how to create a table, insert records, and retrieve data using these functions. The example creates a 'COMPANY' table, inserts 4 records, then selects and prints the records.
The Ring programming language version 1.5.2 book - Part 28 of 181Mahmoud Samir Fayed
This document describes MySQL functions available in the Ring programming language. It provides examples of using various MySQL functions such as MySQL_Info(), MySQL_Init(), MySQL_Connect(), MySQL_Query(), MySQL_Insert_ID(), MySQL_Result(), MySQL_Columns(), MySQL_Escape_String(), MySQL_AutoCommit(), MySQL_Commit(), and MySQL_Rollback(). It also shows how to connect to a MySQL database, execute queries, retrieve and print results, handle errors, and work with transactions.
The Ring programming language version 1.5.3 book - Part 29 of 184Mahmoud Samir Fayed
This document describes various functions for security, encryption, hashing and internet usage in the Ring programming language. It covers functions for calculating hashes using MD5, SHA1, SHA256 and SHA512. It also covers functions for encryption/decryption and generating random bytes. Additionally, it describes functions for downloading content from the internet and sending emails.
The Ring programming language version 1.10 book - Part 37 of 212Mahmoud Samir Fayed
This document provides documentation on MySQL functions in the Ring programming language. It describes functions for connecting to a MySQL database, executing queries, retrieving results, and managing transactions. Example code is provided to demonstrate connecting to a database, creating tables, inserting and retrieving data, handling errors, and using transactions with commit and rollback.
The document contains 17 Java code snippets that provide solutions to common programming problems and examples. Some of the problems addressed include: reversing an integer, checking if two words are anagrams, palindrome checking, merging two sorted arrays, left rotation of an array, sorting an array of 0s, 1s and 2s, counting character occurrences in a string, factorial, Fibonacci series, prime number checking, bubble sort, and substring searching. The code snippets provide full programs or methods to solve each problem in 1-5 steps or lines of code each.
The Ring programming language version 1.5.1 book - Part 27 of 180Mahmoud Samir Fayed
- The document describes MySQL functions in Ring programming language for connecting to and interacting with MySQL databases. It provides examples and explanations of functions like MySQL_Connect(), MySQL_Query(), MySQL_Result(), MySQL_Insert_ID(), MySQL_Columns(), and others.
- It also demonstrates how to save and retrieve images from a database by encoding/decoding with MySQL_Escape_String(), and how to use transactions with MySQL_Autocommit(), MySQL_Commit(), and MySQL_Rollback().
The Ring programming language version 1.7 book - Part 32 of 196Mahmoud Samir Fayed
This document provides documentation on MySQL functions in the Ring programming language. It describes functions for connecting to a MySQL database, executing queries, retrieving results, and managing transactions. Key functions covered include MySQL_Connect() for connecting to a database, MySQL_Query() for executing queries, MySQL_Result() and MySQL_Result2() for retrieving query results, and MySQL_Commit() and MySQL_Rollback() for managing transactions. Examples are provided to illustrate how to use these functions to perform common tasks like creating databases and tables, inserting and retrieving data, and handling transactions.
The Ring programming language version 1.5.4 book - Part 29 of 185Mahmoud Samir Fayed
The document describes various SQLite functions in Ring for working with SQLite databases. It shows how to initialize a SQLite object, open a database, execute SQL statements to create a table, insert data, and retrieve results. Code examples demonstrate creating a database "mytest.db", adding records to a table, and selecting all records to display the names.
The Ring programming language version 1.6 book - Part 46 of 189Mahmoud Samir Fayed
This document summarizes code from the Ring documentation related to user registration, login, and database classes. It describes classes for users, models, views, controllers, and languages that allow for user registration, login, form views, and routing. It also summarizes the Database, ModelBase, and ControllerBase classes that provide functionality for connecting to databases, executing queries, and managing model data.
The document contains code for an image processing program that:
1) Loads a series of images from a file into memory and analyzes frame differences to determine scene changes.
2) Applies frame transformations to adjust for motion between images.
3) Generates a reduced set of frames to display by selecting key frames around detected scene changes.
The program analyzes histograms, motion vectors, and color differences between frames to evaluate scene changes and filter out unnecessary frames.
The Ring programming language version 1.4 book - Part 7 of 30Mahmoud Samir Fayed
Here are the key functions for connecting and interacting with an ODBC database in Ring:
- odbc_init() - Creates an ODBC handle
- odbc_drivers()/odbc_datasources() - Get available drivers/data sources
- odbc_connect() - Connect to a data source using a connection string
- odbc_execute() - Execute an SQL statement
- odbc_colcount() - Get number of columns in result set
- odbc_fetch() - Fetch rows from result set
- odbc_getdata() - Get data from columns
- odbc_close() - Close connection and release resources
Some additional functions:
- odbc_
Developing Applications with MySQL and Java for beginnersSaeid Zebardast
A presentation about Developing Applications with MySQL and Java for beginners. It includes the following topics:
- Requirements
- MySQL Data Definitions
- Java Classes
- MySQL Connector (JDBC)
- Define Methods
- Compile and Run
The Ring programming language version 1.2 book - Part 16 of 84Mahmoud Samir Fayed
The document describes various functions in Ring for determining operating system and environment details. It explains functions like IsMacOSX(), IsLinux(), IsFreeBSD(), IsAndroid() that return 1 if the OS is the given one, and 0 otherwise. It also presents functions for getting command line arguments (sysargv), active source file name (filename()), Windows/Linux newline characters (Windowsnl()), current directory (CurrentDir()), Ring executable path (exefolder()), Ring version (version()), and changing directory (ChDir()). Examples are given to demonstrate the usage of these functions.
The art of reverse engineering flash exploitsPriyanka Aash
"Adobe Flash is one of the battlegrounds of exploit and mitigation methods. As most of the Flash exploits demonstrate native memory layer exploit technique, it is valuable to understand the memory layout and behavior of Adobe Flash Player. We developed fine-grained debugging tactics to observe memory exploit technique and the way to interpret them effectively. This eventually helps defenders to understand new exploit techniques that are used for current targets quickly. This information is also valuable in deciding which area should defenders focus on for mitigation and code fixes. Adobe Flash Player was one of the major attack targets in 2015. We observed at least 17 effective zero-days or 1-day attacks in the wild. Flash is not just used by exploit kits like Angler, it has also been commonly used for advanced persistent threat (APT) attacks. The bug class ranges from simple heap overflows, uninitialized memory to type confusion and use-after-free. At Microsoft, understanding exploits in-the-wild is a continuous process. Flash exploit is one of the hardest to reverse-engineer. It often involves multi-layer obfuscation, and by default, is highly obfuscated and has non-decompilable codes. The challenge with Flash exploit comes from the lack of tools for static and dynamic analysis. Exploits are written with ActionScript programming language and obfuscated in bytecode level using commercial-grade obfuscation tools. Understanding highly obfuscated logic and non-decompilable AVM bytecode is a big challenge. Especially, the lack of usable debuggers for Flash file itself is a huge hurdle for exploit reverse engineers. It is just like debugging PE binaries without using Windbg or Olly debugger. The ability of the researcher is highly limited.
With this presentation, I want to deliver two things: 1. The tactics and debugging technique that can be used to reverse engineer exploits. This includes using existing toolsets and combining them in an effective way. 2. The detailed exploit code reverse engineering examples that can help you understand what's the current and past status of attack and mitigation war. You might have heard of Vector corruption, ByteArray corruption and other JIT manipulation technique. Technical details will be discussed on how the exploits are using these and how the vendor defended against these."
(Source: Black Hat USA 2016, Las Vegas)
The Ring programming language version 1.9 book - Part 36 of 210Mahmoud Samir Fayed
The document describes SQLite functions in Ring for connecting to and interacting with a SQLite database. It includes functions for initializing a SQLite object, opening a database connection, executing SQL statements, and closing the connection. An example shows how to create a database, insert records, retrieve data via a SELECT statement, and display the results.
The Ring programming language version 1.5.3 book - Part 27 of 184Mahmoud Samir Fayed
This document discusses Ring's ODBC functions for connecting to databases. It describes functions for initializing an ODBC connection, getting lists of ODBC drivers and data sources, connecting to and executing queries on a data source, and closing an ODBC connection. Examples are given to print lists of available ODBC drivers and data sources on a system.
The Ring programming language version 1.4.1 book - Part 8 of 31Mahmoud Samir Fayed
The document discusses various hashing and encryption functions available in the Ring programming language for security purposes. It describes functions like MD5(), SHA1(), SHA256(), SHA512() etc to calculate hashes of strings. It also discusses the Encrypt() and Decrypt() functions for encrypting and decrypting data along with the Randbytes() function for generating random bytes. Functions from the internetlib library like Download() and SendEmail() are also mentioned. Examples are provided to demonstrate calculating hashes of strings using different hashing algorithms.
The Ring programming language version 1.5 book - Part 5 of 31Mahmoud Samir Fayed
Load the ODBC library. Initialize an ODBC connection handle. Connect to a data source using the handle. Execute SQL statements and process the results. Close the ODBC connection when done.
Recentrer l'intelligence artificielle sur les connaissancesMathieu d'Aquin
The document appears to contain rules for assigning values to variables (x[n]) based on logical conditions. It includes 14 rules using comparisons of the variable values, logical operators, and numeric values. It also reports the training and test accuracies of the rules as 92.13% and 89.3% respectively.
How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...Matt Harrison
Python makes data science easy. In this deck we walk through a complete example of creating and evaluating a predictive model using Decision Trees and Random Forests. All of the code is included in the slides.
The document discusses various techniques in Django including:
- Using model inheritance and mixins to add common fields and functionality to models
- Monkey patching the model save method to add additional keyword arguments
- Handling null values across deep dictionary lookups
- Using locals() to pass additional context when rendering templates
- Defining choices as classes to avoid hardcoding in models
- Adding operators to choice values to customize display
- Conditionally including fields and methods based on settings
- Injecting context from other files using execfile
Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...Matt Harrison
I gave this presentation at Code Camp. As a data scientist and backcountry skier, I was interested in looking at fatal avalanche data. This covers scraping the data, analysis with Python, pandas and IPython Notebook. The final result is an infographic
The Ring programming language version 1.2 book - Part 32 of 84Mahmoud Samir Fayed
The document discusses user registration and login functionality in Ring. It describes classes for users (Model, View & Controller), form views for registration and login, and code to handle registration, login, and checking authentication. It also summarizes classes for database access (Database), model objects (ModelBase), and controllers (ControllerBase).
Manchester Social Media Surgery Events: an IntroductionChi-chi Ekweozor
A slide deck documenting our discussions about monthly Manchester Social Media Surgery events at Social Media Cafe Manchester, #smc_mcr on 1st Dec 2009.
The document discusses using social media for marketing. It provides examples of how businesses and individuals have used social media successfully. Some key points covered include:
- Social media allows for two-way interaction between brands and customers as opposed to traditional one-way broadcast media.
- Major social media platforms like Facebook have grown rapidly, with 18 million UK users on Facebook alone last month.
- Case studies are presented showing how a movie studio used social media to build an audience for a film and how artists have promoted and sold their work online.
- Tips are provided on setting up social media profiles and engaging with audiences. The importance of listening to customers and giving credit to others is stressed.
MobiWeb provides two-factor authentication through one-time PINs (OTPs) sent via SMS. This adds security over simple usernames and passwords and helps reduce fraud. The process works by MobiWeb generating an OTP when a user tries to login, sending it via SMS to the user's phone, and validating the OTP when the user enters it. This solution has benefits like increased security, reduced fraud losses, and a better customer experience compared to hardware tokens. MobiWeb has been providing global SMS services since 1999 through direct connections to mobile networks worldwide.
Bootstrap |> Elixir - Easy fun for busy developersDavid Schmitz
The document provides an overview of the Elixir programming language. It discusses key features of Elixir like processes, concurrency, fault tolerance using supervision trees, and distribution across nodes. It also briefly compares Elixir to other languages like Ruby, Erlang, and Clojure, highlighting reasons why one may choose each. The document demonstrates concepts like GenServers, testing with ExUnit, and macros. Overall it promotes Elixir as a good choice for building scalable and fault tolerant applications.
The Ring programming language version 1.7 book - Part 32 of 196Mahmoud Samir Fayed
This document provides documentation on MySQL functions in the Ring programming language. It describes functions for connecting to a MySQL database, executing queries, retrieving results, and managing transactions. Key functions covered include MySQL_Connect() for connecting to a database, MySQL_Query() for executing queries, MySQL_Result() and MySQL_Result2() for retrieving query results, and MySQL_Commit() and MySQL_Rollback() for managing transactions. Examples are provided to illustrate how to use these functions to perform common tasks like creating databases and tables, inserting and retrieving data, and handling transactions.
The Ring programming language version 1.5.4 book - Part 29 of 185Mahmoud Samir Fayed
The document describes various SQLite functions in Ring for working with SQLite databases. It shows how to initialize a SQLite object, open a database, execute SQL statements to create a table, insert data, and retrieve results. Code examples demonstrate creating a database "mytest.db", adding records to a table, and selecting all records to display the names.
The Ring programming language version 1.6 book - Part 46 of 189Mahmoud Samir Fayed
This document summarizes code from the Ring documentation related to user registration, login, and database classes. It describes classes for users, models, views, controllers, and languages that allow for user registration, login, form views, and routing. It also summarizes the Database, ModelBase, and ControllerBase classes that provide functionality for connecting to databases, executing queries, and managing model data.
The document contains code for an image processing program that:
1) Loads a series of images from a file into memory and analyzes frame differences to determine scene changes.
2) Applies frame transformations to adjust for motion between images.
3) Generates a reduced set of frames to display by selecting key frames around detected scene changes.
The program analyzes histograms, motion vectors, and color differences between frames to evaluate scene changes and filter out unnecessary frames.
The Ring programming language version 1.4 book - Part 7 of 30Mahmoud Samir Fayed
Here are the key functions for connecting and interacting with an ODBC database in Ring:
- odbc_init() - Creates an ODBC handle
- odbc_drivers()/odbc_datasources() - Get available drivers/data sources
- odbc_connect() - Connect to a data source using a connection string
- odbc_execute() - Execute an SQL statement
- odbc_colcount() - Get number of columns in result set
- odbc_fetch() - Fetch rows from result set
- odbc_getdata() - Get data from columns
- odbc_close() - Close connection and release resources
Some additional functions:
- odbc_
Developing Applications with MySQL and Java for beginnersSaeid Zebardast
A presentation about Developing Applications with MySQL and Java for beginners. It includes the following topics:
- Requirements
- MySQL Data Definitions
- Java Classes
- MySQL Connector (JDBC)
- Define Methods
- Compile and Run
The Ring programming language version 1.2 book - Part 16 of 84Mahmoud Samir Fayed
The document describes various functions in Ring for determining operating system and environment details. It explains functions like IsMacOSX(), IsLinux(), IsFreeBSD(), IsAndroid() that return 1 if the OS is the given one, and 0 otherwise. It also presents functions for getting command line arguments (sysargv), active source file name (filename()), Windows/Linux newline characters (Windowsnl()), current directory (CurrentDir()), Ring executable path (exefolder()), Ring version (version()), and changing directory (ChDir()). Examples are given to demonstrate the usage of these functions.
The art of reverse engineering flash exploitsPriyanka Aash
"Adobe Flash is one of the battlegrounds of exploit and mitigation methods. As most of the Flash exploits demonstrate native memory layer exploit technique, it is valuable to understand the memory layout and behavior of Adobe Flash Player. We developed fine-grained debugging tactics to observe memory exploit technique and the way to interpret them effectively. This eventually helps defenders to understand new exploit techniques that are used for current targets quickly. This information is also valuable in deciding which area should defenders focus on for mitigation and code fixes. Adobe Flash Player was one of the major attack targets in 2015. We observed at least 17 effective zero-days or 1-day attacks in the wild. Flash is not just used by exploit kits like Angler, it has also been commonly used for advanced persistent threat (APT) attacks. The bug class ranges from simple heap overflows, uninitialized memory to type confusion and use-after-free. At Microsoft, understanding exploits in-the-wild is a continuous process. Flash exploit is one of the hardest to reverse-engineer. It often involves multi-layer obfuscation, and by default, is highly obfuscated and has non-decompilable codes. The challenge with Flash exploit comes from the lack of tools for static and dynamic analysis. Exploits are written with ActionScript programming language and obfuscated in bytecode level using commercial-grade obfuscation tools. Understanding highly obfuscated logic and non-decompilable AVM bytecode is a big challenge. Especially, the lack of usable debuggers for Flash file itself is a huge hurdle for exploit reverse engineers. It is just like debugging PE binaries without using Windbg or Olly debugger. The ability of the researcher is highly limited.
With this presentation, I want to deliver two things: 1. The tactics and debugging technique that can be used to reverse engineer exploits. This includes using existing toolsets and combining them in an effective way. 2. The detailed exploit code reverse engineering examples that can help you understand what's the current and past status of attack and mitigation war. You might have heard of Vector corruption, ByteArray corruption and other JIT manipulation technique. Technical details will be discussed on how the exploits are using these and how the vendor defended against these."
(Source: Black Hat USA 2016, Las Vegas)
The Ring programming language version 1.9 book - Part 36 of 210Mahmoud Samir Fayed
The document describes SQLite functions in Ring for connecting to and interacting with a SQLite database. It includes functions for initializing a SQLite object, opening a database connection, executing SQL statements, and closing the connection. An example shows how to create a database, insert records, retrieve data via a SELECT statement, and display the results.
The Ring programming language version 1.5.3 book - Part 27 of 184Mahmoud Samir Fayed
This document discusses Ring's ODBC functions for connecting to databases. It describes functions for initializing an ODBC connection, getting lists of ODBC drivers and data sources, connecting to and executing queries on a data source, and closing an ODBC connection. Examples are given to print lists of available ODBC drivers and data sources on a system.
The Ring programming language version 1.4.1 book - Part 8 of 31Mahmoud Samir Fayed
The document discusses various hashing and encryption functions available in the Ring programming language for security purposes. It describes functions like MD5(), SHA1(), SHA256(), SHA512() etc to calculate hashes of strings. It also discusses the Encrypt() and Decrypt() functions for encrypting and decrypting data along with the Randbytes() function for generating random bytes. Functions from the internetlib library like Download() and SendEmail() are also mentioned. Examples are provided to demonstrate calculating hashes of strings using different hashing algorithms.
The Ring programming language version 1.5 book - Part 5 of 31Mahmoud Samir Fayed
Load the ODBC library. Initialize an ODBC connection handle. Connect to a data source using the handle. Execute SQL statements and process the results. Close the ODBC connection when done.
Recentrer l'intelligence artificielle sur les connaissancesMathieu d'Aquin
The document appears to contain rules for assigning values to variables (x[n]) based on logical conditions. It includes 14 rules using comparisons of the variable values, logical operators, and numeric values. It also reports the training and test accuracies of the rules as 92.13% and 89.3% respectively.
How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...Matt Harrison
Python makes data science easy. In this deck we walk through a complete example of creating and evaluating a predictive model using Decision Trees and Random Forests. All of the code is included in the slides.
The document discusses various techniques in Django including:
- Using model inheritance and mixins to add common fields and functionality to models
- Monkey patching the model save method to add additional keyword arguments
- Handling null values across deep dictionary lookups
- Using locals() to pass additional context when rendering templates
- Defining choices as classes to avoid hardcoding in models
- Adding operators to choice values to customize display
- Conditionally including fields and methods based on settings
- Injecting context from other files using execfile
Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...Matt Harrison
I gave this presentation at Code Camp. As a data scientist and backcountry skier, I was interested in looking at fatal avalanche data. This covers scraping the data, analysis with Python, pandas and IPython Notebook. The final result is an infographic
The Ring programming language version 1.2 book - Part 32 of 84Mahmoud Samir Fayed
The document discusses user registration and login functionality in Ring. It describes classes for users (Model, View & Controller), form views for registration and login, and code to handle registration, login, and checking authentication. It also summarizes classes for database access (Database), model objects (ModelBase), and controllers (ControllerBase).
Manchester Social Media Surgery Events: an IntroductionChi-chi Ekweozor
A slide deck documenting our discussions about monthly Manchester Social Media Surgery events at Social Media Cafe Manchester, #smc_mcr on 1st Dec 2009.
The document discusses using social media for marketing. It provides examples of how businesses and individuals have used social media successfully. Some key points covered include:
- Social media allows for two-way interaction between brands and customers as opposed to traditional one-way broadcast media.
- Major social media platforms like Facebook have grown rapidly, with 18 million UK users on Facebook alone last month.
- Case studies are presented showing how a movie studio used social media to build an audience for a film and how artists have promoted and sold their work online.
- Tips are provided on setting up social media profiles and engaging with audiences. The importance of listening to customers and giving credit to others is stressed.
MobiWeb provides two-factor authentication through one-time PINs (OTPs) sent via SMS. This adds security over simple usernames and passwords and helps reduce fraud. The process works by MobiWeb generating an OTP when a user tries to login, sending it via SMS to the user's phone, and validating the OTP when the user enters it. This solution has benefits like increased security, reduced fraud losses, and a better customer experience compared to hardware tokens. MobiWeb has been providing global SMS services since 1999 through direct connections to mobile networks worldwide.
Bootstrap |> Elixir - Easy fun for busy developersDavid Schmitz
The document provides an overview of the Elixir programming language. It discusses key features of Elixir like processes, concurrency, fault tolerance using supervision trees, and distribution across nodes. It also briefly compares Elixir to other languages like Ruby, Erlang, and Clojure, highlighting reasons why one may choose each. The document demonstrates concepts like GenServers, testing with ExUnit, and macros. Overall it promotes Elixir as a good choice for building scalable and fault tolerant applications.
Flowex: Flow-Based Programming with Elixir GenStage - Anton MishchukElixir Club
This document discusses flow-based programming (FBP) and how it can be implemented using Elixir and the Flowex library. FBP defines applications as networks of independent processes that exchange data via message passing. Railway-oriented programming (ROP) is a design pattern that structures programs as a sequence of functions that pass data along. Railway FBP combines these concepts by implementing each function as an independent process. The Flowex library allows defining Elixir modules as processing pipelines and running them concurrently using GenStage to enable parallelism. It provides an easy way to build reusable and independently running process components.
Bottleneck in Elixir Application - Alexey Osipenko Elixir Club
This document appears to be a presentation in a foreign language (not English) about performance bottlenecks in Elixir applications. It introduces the presenter, Alexey, and mentions that while Elixir has advantages over JavaScript for asynchronous programming, high loads can still cause performance problems. It concludes by thanking the audience and providing Alexey's contact information.
The document discusses concurrency in Elixir using OTP (Open Telecom Platform). OTP provides libraries and design principles for writing concurrent applications in Erlang/Elixir. It includes components like supervisors, applications, agents, tasks and GenServers that help manage concurrency. Supervisors oversee worker processes in a supervision tree, restarting them based on configured restart strategies if they fail. State is managed by agents and GenServers. This allows applications to have many concurrent processes that are fault tolerant and can seamlessly spread across machines.
Elixir Elevated: The Ups and Downs of OTP at ElixirConf2014Greg Vaughn
The document discusses OTP (Open Telecom Platform) and Elixir. It provides an overview of OTP including that it is mature, battle tested for 16-18 years, and uses actors, object orientation, and design patterns. It then discusses behaviors and callback modules in OTP, the importance of initialization steps and parameter/return value contracts, using supervisors and strategies, and handling failures in Elixir applications. Code examples are provided for GenServers and supervisors.
The document provides an introduction to Elixir and OTP (Open Telecom Platform). It discusses key aspects of Elixir including its functional and meta-programming capabilities. It also covers OTP including processes as the concurrency model, and common behaviors like GenServer, Supervisor, and Application. GenServer is used for building servers, Supervisor supervises child processes, and Application initializes everything at the top level. Overall the document serves as a high-level overview of the Elixir language and OTP framework for building distributed, fault-tolerant applications.
The document describes setting up an Elixir project to perform optical character recognition (OCR) using the Google Vision API. It goes through initializing a new Mix project, adding dependencies like Credo for code analysis and HTTPoison for making HTTP requests, and creating modules to call the Google Vision API and provide a facade. Code examples are provided for creating a GoogleVision module that handles making requests to Google Vision and extracting text from responses. The overall goal is to build an OCR module that extracts quotes from memes by leveraging the Google Vision API.
This talk explains how to deploy Elixir in a real-world production setting, including releases, rolling and hot upgrades, rollbacks, clustering, and fault tolerance. Mentioned in detail are some of the numerous gotchas the Elixir developer may encounter on the way to creating a bulletproof service.
Elixir – Peeking into Elixir's Processes, OTP and SupervisorsBenjamin Tan
The document discusses key concepts in Elixir including processes, OTP framework, and supervisors. It provides an overview of processes as Elixir's basic concurrency primitive. It then explains OTP as a framework for building fault-tolerant and scalable applications, including behaviors like GenServer and common patterns. Finally, it covers supervisors and how they provide fault tolerance and recovery through restarting processes based on different strategies. Code examples are provided to demonstrate processes, GenServers, and supervisors.
A short introduction to Elixir presented by Chi-chi Ekweozor at Manchester UK's MadLab on 20 February.
Learn how to use the ubiquitous pipeline operator |> to consume functions as data, pattern matching, modules, lists and other language constructs.
Elixir is a functional programming language that is well-suited for building scalable and fault-tolerant applications. The document provides an introduction to Elixir by discussing its roots in Erlang and how it builds upon Erlang's strengths like concurrency, distribution, and fault tolerance. It also demonstrates some basic Elixir concepts like functions, pattern matching, recursion, and the BEAM virtual machine. Finally, it provides examples of real-world applications of Elixir like building Phoenix web applications and developing embedded hardware projects with Nerves.
Elixir is a dynamic, functional language designed for building scalable and maintainable applications. It leverages the Erlang VM, known for running low-latency, distributed and fault-tolerant systems. Elixir compiles to Erlang bytecode and provides developers' productivity through amazing tooling and documentation while enabling concurrency programming without locks or semaphores. The document then provides examples of Elixir types, functions, macros, and tools like Mix and Phoenix.
Haskell is a pure functional programming language that is statically typed and implements immutable data structures. It uses recursion extensively in place of loops. Some key features include:
- Functional programming with immutable values and functions as first-class citizens
- Static typing with type inference
- Recursion instead of loops for iteration
- List comprehensions and pattern matching
It has compilers like GHC and interpreters like Hugs. Code examples demonstrate list handling, recursion, and functional concepts like currying, partial application, and let/in bindings. Haskell has advantages for learning functional programming but also has disadvantages like initial complexity and lack of performance of other languages.
This document provides an introduction to the Julia programming language. It discusses key features of Julia such as writing code that is readable like Python but runs as fast as C. Examples are given showing Julia's dynamic typing, numeric types, operators, control flow statements like if/else and while loops, and arrays. The document ends with a rock-paper-scissors game example that demonstrates functions, conditionals, and refactoring code for simplicity.
A slightly-modified version of my IPRUG talk, this time for the BT DevCon5 developer conference at Adastral Park on 25 May 2012.
The main changes are the addition of the Ruby section and the increased number of HHGTTG references in honour of towel day.
This document provides an overview of key Java concepts including:
- Java is an object-oriented, platform-independent programming language similar to C++ in syntax. It was developed by Sun Microsystems.
- Java features include automatic memory management, type safety, multi-threading, and network programming capabilities. Code is compiled to bytecode that runs on the Java Virtual Machine.
- Core Java concepts discussed include primitive types, variables, operators, control flow statements, methods, classes, objects, arrays, inheritance, polymorphism and encapsulation.
- Additional topics covered are packages, access modifiers, constructors, overloading, overriding, and inner classes.
Technical operations is plagued with an unhealthy infatuation of typically untested, imperative code with a high reliance on shared mutable state using dynamically typed languages such as Ruby, Python, Bash, and - ugh - remember Perl? :) In an age where building reliable infrastructure to elastically scale applications and services are paramount to business success, we need to start rethinking the infrastructure engineer’s toolkit and guiding principles. This talk will take a look at applying various functional techniques to building and automating infrastructure. From functional package management and congruent configuration to declarative cloud provisioning we’ll see just how practical these techniques typically used in functional programming for applications can be used to help build more robust and predictable infrastructures. While specific code examples will be given, the emphasis of the talk will be on guiding principles and functional design.
This document provides an introduction to the R programming language. It discusses R as both a statistical analysis tool and a programming language. Key aspects of R covered include interacting with R in an interactive way, assigning variables and basic data types like vectors and factors, performing basic statistics and visualization, and R's object-oriented programming approach with generic functions and class-specific methods. Examples are provided throughout to demonstrate basic R syntax and capabilities.
This document provides an introduction and overview of Matlab. It discusses (1) vectors, matrices and arithmetic operations in Matlab, (2) plotting functions, and (3) flow control structures like if/else statements and for loops. Some key aspects covered include how to define vectors and matrices, perform element-wise and standard matrix operations, create plots of data, and write programs with basic programming constructs. The document also lists some useful Matlab commands and functions.
This document provides an introduction and overview of Matlab. It discusses (1) vectors, matrices and arithmetic operations in Matlab, (2) plotting capabilities, and (3) flow control structures like if/else statements and for loops. Some key aspects covered include how to define vectors and matrices, perform element-wise and standard matrix operations, create plots of data, and write programs with basic programming constructs. The document also provides examples of plotting commands and symbolic math operations in Matlab.
This document compares and contrasts Clojure and Elixir programming languages. It provides an overview of their origins, syntax, concurrency models, macro systems, and further reading recommendations. Key points include Clojure running on the JVM while Elixir runs on the BEAM VM, both having Lisp-like syntax with differences in collection types, and both supporting metaprogramming through macros while having different macro expansion approaches.
Examples: https://gist.github.com/aditya01933/c6a867e981110885369f06c5a4103644
1. 3 pillars of ruby.
2. Classes and objects.
3. Inheritance - diving deep
4. Meta programming and reflection - diving deep.
5. Power of method missing.
6. Mixins and ducktyping
7. Super - diving deep
8. Yield
9. Closure
10. Block, proc and lambda
11. More meta programming(examples).
12. Ruby open classes.
Presentation given at the 2013 Clojure Conj on core.matrix, a library that brings muli-dimensional array and matrix programming capabilities to Clojure
Parallel R in snow (english after 2nd slide)Cdiscount
This presentation discusses parallelizing computations in R using the snow package. It demonstrates how to:
1. Create a cluster with multiple R sessions using makeCluster()
2. Split data across the sessions using clusterSplit() and export data to each node
3. Write functions to execute in parallel on each node using clusterEvalQ()
4. Collect the results, such as by summing outputs, to obtain the final parallelized computation. As an example, it shows how to parallelize the likelihood calculation for a probit regression model, reducing the computation time.
Introducing Elixir and OTP at the Erlang BASHdevbash
This document provides an overview of Elixir and OTP (Open Telephony Platform). It defines Elixir as a dynamic, functional language designed for building scalable applications that leverages the Erlang VM. It discusses some key aspects of Elixir including Mix for project management, macros, protocols, and pipelines. It also covers OTP principles like behaviors, supervision trees, and error handling. Common patterns in Elixir like GenServers, Agents, Tasks and Task Supervisors are explained.
- Install Python 2.5 or 2.6 and SQLAlchemy 0.5 using easy_install
- Michael Bayer created SQLAlchemy and is a software architect in New York City
- SQLAlchemy allows modeling database queries and relationships between objects in a more Pythonic way compared to raw SQL
This document provides an overview of using Clojure for data science. It discusses why Clojure is suitable for data science due to its functional programming capabilities, performance on the JVM, and rich library ecosystem. It introduces core.matrix, a Clojure library that provides multi-dimensional array programming functionality through Clojure protocols. The document covers core.matrix concepts like array creation and manipulation, element-wise operations, broadcasting, and optional support for mutability. It also discusses core.matrix implementation details like the performance benefits of using Clojure protocols.
This document provides an overview of the Python programming language. It begins with an introduction to running Python code and output. It then covers Python's basic data types like integers, floats, strings, lists, tuples and dictionaries. The document explains input and file I/O in Python as well as common control structures like if/else statements, while loops and for loops. It also discusses functions as first-class objects in Python that can be defined and passed as parameters. The document provides examples of higher-order functions like map, filter and reduce. Finally, it notes that functions can be defined inside other functions in Python.
Societal challenges of AI: biases, multilinguism and sustainabilityJordi Cabot
Towards a fairer, inclusive and sustainable AI that works for everybody.
Reviewing the state of the art on these challenges and what we're doing at LIST to test current LLMs and help you select the one that works best for you
Not So Common Memory Leaks in Java WebinarTier1 app
This SlideShare presentation is from our May webinar, “Not So Common Memory Leaks & How to Fix Them?”, where we explored lesser-known memory leak patterns in Java applications. Unlike typical leaks, subtle issues such as thread local misuse, inner class references, uncached collections, and misbehaving frameworks often go undetected and gradually degrade performance. This deck provides in-depth insights into identifying these hidden leaks using advanced heap analysis and profiling techniques, along with real-world case studies and practical solutions. Ideal for developers and performance engineers aiming to deepen their understanding of Java memory management and improve application stability.
Cryptocurrency Exchange Script like Binance.pptxriyageorge2024
This SlideShare dives into the process of developing a crypto exchange platform like Binance, one of the world’s largest and most successful cryptocurrency exchanges.
Why Orangescrum Is a Game Changer for Construction Companies in 2025Orangescrum
Orangescrum revolutionizes construction project management in 2025 with real-time collaboration, resource planning, task tracking, and workflow automation, boosting efficiency, transparency, and on-time project delivery.
PDF Reader Pro Crack Latest Version FREE Download 2025mu394968
🌍📱👉COPY LINK & PASTE ON GOOGLE https://dr-kain-geera.info/👈🌍
PDF Reader Pro is a software application, often referred to as an AI-powered PDF editor and converter, designed for viewing, editing, annotating, and managing PDF files. It supports various PDF functionalities like merging, splitting, converting, and protecting PDFs. Additionally, it can handle tasks such as creating fillable forms, adding digital signatures, and performing optical character recognition (OCR).
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfTechSoup
In this webinar we will dive into the essentials of generative AI, address key AI concerns, and demonstrate how nonprofits can benefit from using Microsoft’s AI assistant, Copilot, to achieve their goals.
This event series to help nonprofits obtain Copilot skills is made possible by generous support from Microsoft.
What You’ll Learn in Part 2:
Explore real-world nonprofit use cases and success stories.
Participate in live demonstrations and a hands-on activity to see how you can use Microsoft 365 Copilot in your own work!
AgentExchange is Salesforce’s latest innovation, expanding upon the foundation of AppExchange by offering a centralized marketplace for AI-powered digital labor. Designed for Agentblazers, developers, and Salesforce admins, this platform enables the rapid development and deployment of AI agents across industries.
Email: [email protected]
Phone: +1(630) 349 2411
Website: https://www.fexle.com/blogs/agentexchange-an-ultimate-guide-for-salesforce-consultants-businesses/?utm_source=slideshare&utm_medium=pptNg
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AIdanshalev
If we were building a GenAI stack today, we'd start with one question: Can your retrieval system handle multi-hop logic?
Trick question, b/c most can’t. They treat retrieval as nearest-neighbor search.
Today, we discussed scaling #GraphRAG at AWS DevOps Day, and the takeaway is clear: VectorRAG is naive, lacks domain awareness, and can’t handle full dataset retrieval.
GraphRAG builds a knowledge graph from source documents, allowing for a deeper understanding of the data + higher accuracy.
Avast Premium Security Crack FREE Latest Version 2025mu394968
🌍📱👉COPY LINK & PASTE ON GOOGLE https://dr-kain-geera.info/👈🌍
Avast Premium Security is a paid subscription service that provides comprehensive online security and privacy protection for multiple devices. It includes features like antivirus, firewall, ransomware protection, and website scanning, all designed to safeguard against a wide range of online threats, according to Avast.
Key features of Avast Premium Security:
Antivirus: Protects against viruses, malware, and other malicious software, according to Avast.
Firewall: Controls network traffic and blocks unauthorized access to your devices, as noted by All About Cookies.
Ransomware protection: Helps prevent ransomware attacks, which can encrypt your files and hold them hostage.
Website scanning: Checks websites for malicious content before you visit them, according to Avast.
Email Guardian: Scans your emails for suspicious attachments and phishing attempts.
Multi-device protection: Covers up to 10 devices, including Windows, Mac, Android, and iOS, as stated by 2GO Software.
Privacy features: Helps protect your personal data and online privacy.
In essence, Avast Premium Security provides a robust suite of tools to keep your devices and online activity safe and secure, according to Avast.
🌱 Green Grafana 🌱 Essentials_ Data, Visualizations and Plugins.pdfImma Valls Bernaus
eady to harness the power of Grafana for your HackUPC project? This session provides a rapid introduction to the core concepts you need to get started. We'll cover Grafana fundamentals and guide you through the initial steps of building both compelling dashboards and your very first Grafana app. Equip yourself with the essential tools to visualize your data and bring your innovative ideas to life!
Download YouTube By Click 2025 Free Full Activatedsaniamalik72555
Copy & Past Link 👉👉
https://dr-up-community.info/
"YouTube by Click" likely refers to the ByClick Downloader software, a video downloading and conversion tool, specifically designed to download content from YouTube and other video platforms. It allows users to download YouTube videos for offline viewing and to convert them to different formats.
Who Watches the Watchmen (SciFiDevCon 2025)Allon Mureinik
Tests, especially unit tests, are the developers’ superheroes. They allow us to mess around with our code and keep us safe.
We often trust them with the safety of our codebase, but how do we know that we should? How do we know that this trust is well-deserved?
Enter mutation testing – by intentionally injecting harmful mutations into our code and seeing if they are caught by the tests, we can evaluate the quality of the safety net they provide. By watching the watchmen, we can make sure our tests really protect us, and we aren’t just green-washing our IDEs to a false sense of security.
Talk from SciFiDevCon 2025
https://www.scifidevcon.com/courses/2025-scifidevcon/contents/680efa43ae4f5
Exploring Wayland: A Modern Display Server for the FutureICS
Wayland is revolutionizing the way we interact with graphical interfaces, offering a modern alternative to the X Window System. In this webinar, we’ll delve into the architecture and benefits of Wayland, including its streamlined design, enhanced performance, and improved security features.
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Eric D. Schabell
It's time you stopped letting your telemetry data pressure your budgets and get in the way of solving issues with agility! No more I say! Take back control of your telemetry data as we guide you through the open source project Fluent Bit. Learn how to manage your telemetry data from source to destination using the pipeline phases covering collection, parsing, aggregation, transformation, and forwarding from any source to any destination. Buckle up for a fun ride as you learn by exploring how telemetry pipelines work, how to set up your first pipeline, and exploring several common use cases that Fluent Bit helps solve. All this backed by a self-paced, hands-on workshop that attendees can pursue at home after this session (https://o11y-workshops.gitlab.io/workshop-fluentbit).
5. history
Joe designed erlang
in the 80s, when he
was an Ericsson
engineer, focusing on:
● Scalability
● Fault Tolerance
● Concurrency
6. history
● Moore’s law is almost
over, but it is too easy
to have multicore pc.
● Languages like
Python, Javascript or
Ruby can’t take
advantage of several
CPUs
7. history
Jose Valim tried to
improve Ruby on Rails
framework, but he could
not. Then, he discovered
how Erlang worked, but
he did not like the syntax,
therefore he decided to
create a new language
which will run in the
BEAM (Erlang Virtual
Machine).
12. control flow structures
Case compares a value against many patterns until we find a matching one:
iex> x = {1, 2, 3}
{1, 2, 3}
iex> case x do
...> {2, 3, 4} → “First option”
...> {1, _, 3} → “Second Option”
...> _ → “It always matches”
...> end
“Second Option”
iex> x = {1, 7, 3}
{1, 2, 3}
iex()> case x do
...> {2, 3, 4} → “First option”
...> {1, _, 3} → “Second Option”
...> _ → “It always matches”
...> end
“Second Option”
iex> x = {1, 2, 3}
{1, 2, 3}
iex> case x do
...> {2, 3, 4} → “First option”
...> {1, _, 3} → “Second Option”
...> _ → “It always matches”
...> end
“Second Option”
iex> x = {1, 7, 3}
{1, 2, 3}
iex()> case x do
...> {2, 3, 4} → “First option”
...> {1, _, 3} → “Second Option”
...> _ → “It always matches”
...> end
“Second Option”
You can also use guards in your pattern matching: {1, z, 3} when z > 0 → “guards !!!”
13. control flow structures
Cond allows us to check different conditions until we find the first true.
iex> x = {1, 2, 3}
{1, 2, 3}
iex> cond do
...> x == {2, 3, 4} → “First option”
...> is_list(x) → “It is a list !!”
...> 2 + 5 == x → “ it is 7 !!”
...> true → “It always matches”
...> end
“It always matches”
iex> x = {1, 2, 3}
{1, 2, 3}
iex> cond do
...> x == {2, 3, 4} → “First option”
...> is_list(x) → “It is a list !!”
...> 2 + 5 == x → “ it is 7 !!”
...> true → “It always matches”
...> end
“It always matches”
14. control flow structures
If and unless are macros, but you can normally use them ;).
iex> x = {1, 2, 3}
{1, 2, 3}
iex> if {1, 2, 3} == x do
...> “Yes, it is”
...> else
...> “No, it is not”
...> end
“Yes, it is”
iex> unless {1, 2, 3} == x do
...> “No, it is not”
...> else
...> “Yes, it is”
...> end
“Yes, it is”
iex> x = {1, 2, 3}
{1, 2, 3}
iex> if {1, 2, 3} == x do
...> “Yes, it is”
...> else
...> “No, it is not”
...> end
“Yes, it is”
iex> unless {1, 2, 3} == x do
...> “No, it is not”
...> else
...> “Yes, it is”
...> end
“Yes, it is”
15. functions
Functions are first citizens in elixir. Don’t forget the “.” if it is an anonymous one.
iex> square = fn x → x*x end
Function<6.52032458/1 in :erl_eval.expr/5>
iex> square.(2)
4
iex>my_very_difficult_algo = fn x -> square.(x) end
#Function<6.52032458/1 in :erl_eval.expr/5>
iex> my_very_difficult_algo.(2)
4
iex> square = fn x → x*x end
Function<6.52032458/1 in :erl_eval.expr/5>
iex> square.(2)
4
iex>my_very_difficult_algo = fn x -> square.(x) end
#Function<6.52032458/1 in :erl_eval.expr/5>
iex> my_very_difficult_algo.(2)
4
16. modules
The functions are grouped in Modules.
iex> defmodule MyCalculator do
...> def square(x) do
...> x * x
...> end
...> end
{:module, MyCalculator,
<<70, 79, 82, 49, 0, 0, 4, 212, 66, 69, 65, 77, 69,
120, 68, 99, 0, 0, 0, 147,
131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105,
114, 95, 100, 111, 99, 115,
95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>, {:square,
1}}
iex> MyCalculator.square(2)
4
iex> defmodule MyCalculator do
...> def square(x) do
...> x * x
...> end
...> end
{:module, MyCalculator,
<<70, 79, 82, 49, 0, 0, 4, 212, 66, 69, 65, 77, 69,
120, 68, 99, 0, 0, 0, 147,
131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105,
114, 95, 100, 111, 99, 115,
95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>, {:square,
1}}
iex> MyCalculator.square(2)
4
17. modules
Elixir has a lot of standard modules that you will take advantage of them.
● Enum
● List
● Map
● Stream
● String
● Integer
● Process
● ...
18. modules
But Elixir works in the BEAM, so we can also use all the standard modules of Erlang.
● :os
● :calendar
● :rand
● :ets
● :crypto
● :global
● ...
20. Processes
Elixir (and Erlang)
follows the actor
model paradigm.
● Every process (Erlang
process) has his own
mailbox and it
communicates using
messages
21. Processes
Self communication !!
iex> Process.send(self(), “Hello from Process.send()”, [])
iex> send(self(), “Hello send()”)
iex> receive do
...> msg → msg
...> end
"Hello from Process.send()"
iex> receive do
...> msg → msg
...> end
"Hello from send()"
iex> Process.send(self(), “Hello from Process.send()”, [])
iex> send(self(), “Hello send()”)
iex> receive do
...> msg → msg
...> end
"Hello from Process.send()"
iex> receive do
...> msg → msg
...> end
"Hello from send()"
22. Processes
Communication from outside !!
iex> spawn(fn -> send(parent, {:hello, self()}) end)
#PID<0.48.0>
iex> receive do
...> {:hello, pid} -> "Got hello from #{inspect pid}"
...> end
Got hello from #PID<0.48.0>
iex> spawn(fn -> send(parent, {:hello, self()}) end)
#PID<0.48.0>
iex> receive do
...> {:hello, pid} -> "Got hello from #{inspect pid}"
...> end
Got hello from #PID<0.48.0>
23. Processes
I highly recommend to use Task !!
iex> Task.start(fn -> send(parent, {:hello, self()}) end)
{:ok, #PID<0.48.0>}
iex> receive do
...> {:hello, pid} -> "Got hello from #{inspect pid}"
...> end
Got hello from #PID<0.48.0>
iex> task = Task.async(fn -> 2 + 2 end)
%Task{owner: #PID<0.80.0>, pid: #PID<0.82.0>, ref:
#Reference<0.0.1.211>}
iex> middle_sum = 3 + 5
8
iex> result = middle_sum + Task.await(task)
12
iex> Task.start(fn -> send(parent, {:hello, self()}) end)
{:ok, #PID<0.48.0>}
iex> receive do
...> {:hello, pid} -> "Got hello from #{inspect pid}"
...> end
Got hello from #PID<0.48.0>
iex> task = Task.async(fn -> 2 + 2 end)
%Task{owner: #PID<0.80.0>, pid: #PID<0.82.0>, ref:
#Reference<0.0.1.211>}
iex> middle_sum = 3 + 5
8
iex> result = middle_sum + Task.await(task)
12
24. processes
● Linked Processes: If one process dies, the other dies as well
●
Monitored Process: If a monitored process dies, the monitor process will receive a
notification.
● Linking: You can start a process with the function start_link() instead of start or just use
Process.link(pid) from one process indicating the pid of the other process.
● Monitoring: Execute Process.monitor(pid) from one process indicating the pid of the other process.
26. scalability
We have already talk
about vertical
scalability, but I love
this gift
Vertical scalability
means: “If you have a
‘bigger’ server, your SW
will take advantage of
it.”
27. scalability
Vertical scalability can
reach some
limitations, but we
need to scale, the
solution can be
horizontal scalability,
or adding more
servers. It also
implies distribution.
28. fault tolerance
The only SW that has not bug is the SW that has
never been executed.
SWs which run indefinitely have to be fault tolerance.
The only SW that has no bug is the SW that has
never been executed.
SWs which run indefinitely have to be fault tolerance.
Really good
Exampe !!
29. concurrency
Although we are able
to scale in order to
use more CPU cores,
sure that you will
have more tasks than
cores, so you need
concurrency.
30. history
Having all this things in
mind, the Ericsson guys
developed OTP which
is a collection of useful
middle-ware, libraries,
and tools written in
Erlang programming
language.
Ericsson OTP Team
Twitter: @erlang_org
31. behaviours
Behaviours in Elixir (and Erlang) are a way to separate and abstract the generic part
of a component (which becomes the behaviour module) from the specific part (which
becomes the callback module).
The following are provided by OTP (and some new ones from Elixir):
● Supervisor
● GenServer
●
GenStage
● Agent
● GenEvent
32. behaviours
A Supervisor is a process which supervises other
processes, which are referred to as child processes. (Do
you remember the linking/monitoring actions?)
# Import helpers for defining supervisors
import Supervisor.Spec
# Supervise the Stack server which will be started with
# a single argument [:hello] and the default registered
# name of MyStack.
children = [
worker(MyProcess, [[:hello], [name: :my_process]])
]
# Start the supervisor with our child
{:ok, pid} = Supervisor.start_link(children, strategy:
:one_for_one)
# Import helpers for defining supervisors
import Supervisor.Spec
# Supervise the Stack server which will be started with
# a single argument [:hello] and the default registered
# name of MyStack.
children = [
worker(MyProcess, [[:hello], [name: :my_process]])
]
# Start the supervisor with our child
{:ok, pid} = Supervisor.start_link(children, strategy:
:one_for_one)
34. behaviours
A GenServer is a process like any other Elixir process and it can be used to
keep state, execute code asynchronously and other interesting stuffs providing
a standard set of interface functions and include functionality for tracing and
error reporting. It will also fit into a supervision tree.
defmodule Stack do
use GenServer
# Callbacks
def handle_call(:pop, _from, [h | t]) do
{:reply, h, t}
end
def handle_cast({:push, item}, state) do
{:noreply, [item | state]}
end
end
# Start the server
{:ok, pid} = GenServer.start_link(Stack, [:hello])
# This is the client
GenServer.call(pid, :pop)
#=> :hello
GenServer.cast(pid, {:push, :world})
#=> :ok
GenServer.call(pid, :pop)
#=> :world
defmodule Stack do
use GenServer
# Callbacks
def handle_call(:pop, _from, [h | t]) do
{:reply, h, t}
end
def handle_cast({:push, item}, state) do
{:noreply, [item | state]}
end
end
# Start the server
{:ok, pid} = GenServer.start_link(Stack, [:hello])
# This is the client
GenServer.call(pid, :pop)
#=> :hello
GenServer.cast(pid, {:push, :world})
#=> :ok
GenServer.call(pid, :pop)
#=> :world
35. behaviours
● GenStage provides the interface to create a distributed set
of producer, producer-consumer and consumer processes
with back-pressure mechanism. It is based on GenServer.
Producer
Consumer
Consumer
Consumer
Consumer
Prod-ConsProd-Cons
Prod-Cons
36. ets
ETS is a cache system which allows us to
store any Elixir term in an in-memory table.
iex> table = :ets.new(:my_table, [:named_table])
:my_table
iex> :ets.insert(table, {"foo", self})
true
iex> :ets.lookup(table, "foo")
[{"foo", #PID<0.80.0>}]
iex> :ets.delete(table, "foo")
true
iex> table = :ets.new(:my_table, [:named_table])
:my_table
iex> :ets.insert(table, {"foo", self})
true
iex> :ets.lookup(table, "foo")
[{"foo", #PID<0.80.0>}]
iex> :ets.delete(table, "foo")
true
37. mix
Mix is a build
tool that ships
with Elixir that
provides tasks
for creating,
compiling,
testing your
application,
managing its
dependencies
and much more
$> mix new my_project --sup
* creating README.md
* creating .gitignore
* creating mix.exs
* creating config
* creating config/config.exs
* creating lib
* creating lib/my_project.ex
* creating test
* creating test/test_helper.exs
* creating test/my_project_test.exs
Your Mix project was created
successfully.
You can use "mix" to compile it, test
it, and more:
cd my_project
mix test
Run "mix help" for more commands.
$> mix new my_project --sup
* creating README.md
* creating .gitignore
* creating mix.exs
* creating config
* creating config/config.exs
* creating lib
* creating lib/my_project.ex
* creating test
* creating test/test_helper.exs
* creating test/my_project_test.exs
Your Mix project was created
successfully.
You can use "mix" to compile it, test
it, and more:
cd my_project
mix test
Run "mix help" for more commands.
$> cat my_project/mix.exs
defmodule MyProject.Mixfile do
use Mix.Project
def project do
[app: :my_project,
version: "0.1.0",
elixir: "~> 1.3",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps()]
end
# Configuration for the OTP application
#
# Type "mix help compile.app" for more information
def application do
[applications: [:logger],
mod: {MyProject, []}]
end
# Dependencies can be Hex packages:
#
# {:mydep, "~> 0.3.0"}
#
# Or git/path repositories:
#
# {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag:
"0.1.0"}
#
# Type "mix help deps" for more examples and options
defp deps do
[]
end
end
$> cat my_project/mix.exs
defmodule MyProject.Mixfile do
use Mix.Project
def project do
[app: :my_project,
version: "0.1.0",
elixir: "~> 1.3",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps()]
end
# Configuration for the OTP application
#
# Type "mix help compile.app" for more information
def application do
[applications: [:logger],
mod: {MyProject, []}]
end
# Dependencies can be Hex packages:
#
# {:mydep, "~> 0.3.0"}
#
# Or git/path repositories:
#
# {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag:
"0.1.0"}
#
# Type "mix help deps" for more examples and options
defp deps do
[]
end
end