This document outlines a chapter about ASP.NET and web services. It includes code for a web service called HugeInteger that performs operations on large integers. The HugeInteger service exposes methods like Add, Subtract, Bigger etc through SOAP over HTTP. It shows how to publish web services, add service references to projects, and invoke web service methods from a client application.
The document contains 5 questions related to C++ programs for matrix and array operations:
1) Finding the average of numbers in an array
2) Finding the smallest number in a 1D array
3) Adding two matrices
4) Finding the transpose of a matrix
5) Multiplying two matrices (for 2x2 matrices and matrices up to 10x10)
Each question provides the full C++ code to implement the operation and sample input/output.
This document contains C++ code examples using numerical methods like Newton-Raphson, successive approximation, and secant methods to find the real roots of various equations. It includes 6 questions/problems with sample code to find roots of equations like x^4 - 11x = 8, e^x - 3x^2 = 0, x^3 - 2x - 3 = 0, and sin(x) + 3cos(x) = 2. For each problem, the code provided the numerical method used, input/output examples, and calculations to iteratively approximate the root to within a set tolerance.
The document contains code snippets in VB.NET for various programming concepts like addition of two numbers, reversing a number, calculating factorial using a for loop, checking if a number is a palindrome, finding the greatest of three numbers, checking if a number is an Armstrong number, calculating the sum of digits, checking for a leap year, generating Fibonacci series, reversing a number, printing a number triangle, finding the maximum of two numbers, generating palindrome numbers, swapping two variables using a function, converting between Fahrenheit and Centigrade, swapping two variables without a third variable, summing array elements using a function, finding Armstrong numbers between 1 to 2000, inputting and printing array elements, adding array elements, using message boxes
This document contains C++ code to find roots of equations using the bisection method. It includes 4 questions:
1) Finds the root of x3 – 4x – 8.95 = 0 between 2 and 3 to 3 decimal places.
2) Finds the root of ex – 3x = 0 using bisection up to a specified number of iterations.
3) Defines a bisection function to find the root of f(x) = x6 – x – 1 = 0 within 0.001 accuracy.
4) Defines a bisection function to find the smallest positive root of a cubic equation ax3+bx2+cx+d=0 within an error tolerance of 10-6.
Numerical solution of ordinary differential equations by using Runge-Kutta Method of Order Two and Runge-Kutta Method of Order Four
How to write the C++ codes?
This document contains code snippets from a structured programming tutorial/lab assignment. It includes 5 questions that involve printing text, performing basic math operations on hardcoded and user-inputted values, and converting floating point numbers to integers using different rounding methods. For each question, the code to solve it is provided along with example outputs.
This document contains code snippets and explanations for 5 questions on structured programming in C++. Question 1 involves writing a program to determine if a number is odd or even. Question 2 prints a multiplication table as a lower triangular matrix using different loop structures. Question 3 solves quadratic equations. Question 4 finds the mean of N numbers using various loops. Question 5 calculates the sum of even and odd numbers up to N using different loops. The document provides the code and output for each question using different loop structures like for, while, and do-while loops.
The document discusses how the Promise library can be used to optimize Python code by promising that values will remain constant or invariant during execution. It demonstrates how Promise works by annotating functions in examples with decorators like @promise.pure() and @promise.invariant(), and showing the effect on bytecode through disassembly. The document suggests Promise for optimizing CPU-bound code but acknowledges most production code likely does not need optimization and better algorithms may be more effective than ugly code.
The document contains 5 questions related to C++ programs for matrix and array operations:
1) Finding the average of numbers in an array
2) Finding the smallest number in a 1D array
3) Adding two matrices
4) Finding the transpose of a matrix
5) Multiplying two matrices (for 2x2 matrices and matrices up to 10x10)
Each question provides the full C++ code to implement the operation and sample input/output.
This document contains C++ code examples using numerical methods like Newton-Raphson, successive approximation, and secant methods to find the real roots of various equations. It includes 6 questions/problems with sample code to find roots of equations like x^4 - 11x = 8, e^x - 3x^2 = 0, x^3 - 2x - 3 = 0, and sin(x) + 3cos(x) = 2. For each problem, the code provided the numerical method used, input/output examples, and calculations to iteratively approximate the root to within a set tolerance.
The document contains code snippets in VB.NET for various programming concepts like addition of two numbers, reversing a number, calculating factorial using a for loop, checking if a number is a palindrome, finding the greatest of three numbers, checking if a number is an Armstrong number, calculating the sum of digits, checking for a leap year, generating Fibonacci series, reversing a number, printing a number triangle, finding the maximum of two numbers, generating palindrome numbers, swapping two variables using a function, converting between Fahrenheit and Centigrade, swapping two variables without a third variable, summing array elements using a function, finding Armstrong numbers between 1 to 2000, inputting and printing array elements, adding array elements, using message boxes
This document contains C++ code to find roots of equations using the bisection method. It includes 4 questions:
1) Finds the root of x3 – 4x – 8.95 = 0 between 2 and 3 to 3 decimal places.
2) Finds the root of ex – 3x = 0 using bisection up to a specified number of iterations.
3) Defines a bisection function to find the root of f(x) = x6 – x – 1 = 0 within 0.001 accuracy.
4) Defines a bisection function to find the smallest positive root of a cubic equation ax3+bx2+cx+d=0 within an error tolerance of 10-6.
Numerical solution of ordinary differential equations by using Runge-Kutta Method of Order Two and Runge-Kutta Method of Order Four
How to write the C++ codes?
This document contains code snippets from a structured programming tutorial/lab assignment. It includes 5 questions that involve printing text, performing basic math operations on hardcoded and user-inputted values, and converting floating point numbers to integers using different rounding methods. For each question, the code to solve it is provided along with example outputs.
This document contains code snippets and explanations for 5 questions on structured programming in C++. Question 1 involves writing a program to determine if a number is odd or even. Question 2 prints a multiplication table as a lower triangular matrix using different loop structures. Question 3 solves quadratic equations. Question 4 finds the mean of N numbers using various loops. Question 5 calculates the sum of even and odd numbers up to N using different loops. The document provides the code and output for each question using different loop structures like for, while, and do-while loops.
The document discusses how the Promise library can be used to optimize Python code by promising that values will remain constant or invariant during execution. It demonstrates how Promise works by annotating functions in examples with decorators like @promise.pure() and @promise.invariant(), and showing the effect on bytecode through disassembly. The document suggests Promise for optimizing CPU-bound code but acknowledges most production code likely does not need optimization and better algorithms may be more effective than ugly code.
This document configures IP addresses, firewall NAT, routing, and firewall mangle rules on a router with 3 interfaces: ether1, ether3, ether4. It sets IP addresses for the interfaces, enables masquerading for ether3 and ether4. Traffic incoming on ether1 is classified and marked to be routed out either ether3 or ether4 interfaces based on destination address. Routing tables are configured to send traffic with specific marks out the corresponding interfaces.
This C++ program implements a binomial heap data structure. It includes functions to insert nodes, extract the minimum node, decrease a node's key, delete a node, and display the heap. The main function provides a menu for testing these binomial heap operations on a sample run of the program.
The Ring programming language version 1.2 book - Part 55 of 84Mahmoud Samir Fayed
The document discusses different methods for distributing Ring applications, including:
1) Copying the Ring files and renaming the executable to distribute Windows applications.
2) Generating an object file from Ring code to protect the source code when distributing applications.
3) Using tools like NSIS to create Windows installers for applications.
4) Compiling Ring code with a C/C++ compiler and linker to create executable files.
5) Embedding Ring in Qt or LibSDL projects to build mobile apps and games for distribution.
The Ring programming language version 1.10 book - Part 31 of 212Mahmoud Samir Fayed
The document provides information about string manipulation in Ring programming language. It describes how to create strings, get string length, convert case, access characters, trim whitespace, compare strings, and convert between strings and lists. Functions covered include len(), upper(), lower(), left(), right(), trim(), copy(), lines(), substr(), strcmp(), str2list(), and list2str(). It also discusses merging binary character values from strings.
The Ring programming language version 1.5.4 book - Part 23 of 185Mahmoud Samir Fayed
This document discusses various string and date/time functions in Ring. It describes how to get string lengths, convert case, access characters, trim strings, find/replace substrings. It also covers getting the system time, date, and converting between strings and lists of lines. Functions covered include len(), upper()/lower(), left(), right(), trim(), copy(), lines(), substr(), strcmp(), str2list(), list2str(), time(), date(), and timelist().
The Ring programming language version 1.6 book - Part 25 of 189Mahmoud Samir Fayed
This document provides summaries of various string, date, and time functions in Ring programming language. It explains how to work with string literals, get string length, convert case, access characters, trim strings, duplicate strings, count lines, find/extract substrings, compare strings, and convert between strings and lists. It also covers functions for getting the current time and date, adding/comparing days, and getting detailed time information in a list.
The document contains 9 Java programs (Ejercicio_1 through Ejercicio_9) that demonstrate various exercises using arrays and vectors. Each program defines a class with a main method that declares variables, initializes arrays/vectors, uses loops to input/output values, and performs basic operations like summing, averaging, searching.
The Ring programming language version 1.5.1 book - Part 23 of 180Mahmoud Samir Fayed
This document provides an overview of mathematical and file handling functions available in the Ring programming language. In the mathematical functions section, it lists common functions like sin(), cos(), tan(), log(), sqrt(), and random(). Examples are provided to demonstrate their usage. The files section describes functions for reading, writing, getting directory listings, renaming, deleting files as well as lower level file handling functions. Specific functions covered include Read(), Write(), Dir(), fopen(), fclose(), fseek(), ftell(), and others.
The Ring programming language version 1.8 book - Part 28 of 202Mahmoud Samir Fayed
This chapter discusses string manipulation functions in Ring. It covers creating and accessing string literals and characters, converting case, trimming whitespace, comparing and searching strings, and converting between strings and lists. Functions covered include len(), upper(), lower(), trim(), copy(), left(), right(), substr(), strcmp(), and str2list(). The chapter also discusses working with dates and times using functions like date(), time(), addDays(), and diffDays().
Problem Solving Techniques For Evolutionary DesignNaresh Jain
In this workshop, Naresh Jain explains what are the core techniques one should master to effectively practice evolutionary design while solving real-world problems. To summarize:
1. Eliminate Noise - Distill down the crux of the problem
2. Divide and Conquer to prioritize and focus on the most important part
3. Add constraints to future simplify the problem
4. Come up with a simple design to incrementally build your solution
5. Refactor: Pause, look for a much simpler alternative
6. Be ready to throw away your solution & start again
The Ring programming language version 1.5.3 book - Part 40 of 184Mahmoud Samir Fayed
This document provides an overview and examples of developing web applications using Ring's CGI library. It discusses configuring the Apache web server to support Ring CGI scripts, and provides a basic "Hello World" CGI example. It then demonstrates using the Web library to simplify CGI development, covering features like generating HTML, HTTP GET and POST requests, file uploads, and templates. Examples are given for an HTTP GET form and processing the response.
The Ring programming language version 1.5.3 book - Part 23 of 184Mahmoud Samir Fayed
The document discusses various string and date/time functions in Ring programming language. It describes how to create and manipulate strings, get string length, convert case, access characters, trim strings, compare strings, and convert between strings and lists. It also explains functions to work with dates and times, like getting the current date/time, adding/subtracting days, and converting between dates and epoch seconds.
The document contains code for several C++ programs that demonstrate basic programming concepts like arrays, matrices, structures, and functions. Specifically, it includes code snippets that: 1) sort an array using a bubble sort algorithm; 2) calculate the sum of each row in a matrix; and 3) define a structure to store personal details like name, date of birth, address etc. and accept user input for an object of that structure.
This document contains C++ code that implements various classical ciphers including Caesar cipher, Playfair cipher, Affine cipher, Autokey cipher, and Vigenere cipher. The code provides functions for encrypting and decrypting messages with each cipher. The main function allows a user to select which cipher to use and whether to encrypt or decrypt a message by entering inputs. It then calls the relevant encryption or decryption functions and displays the output.
1. Loops (while and for) allow repeating a block of code multiple times based on a condition. Key loop components are the condition, statement list, and condition update.
2. Nested loops involve loops within other loops, allowing multiple levels of repetition. Variables used in inner loops may shadow those in outer loops.
3. Loop scopes determine variable visibility. Variables declared within loops are local to the loop and not accessible outside. Variables declared before loops can be accessed within and outside loops.
The Ring programming language version 1.5.4 book - Part 25 of 185Mahmoud Samir Fayed
This document describes various file handling functions in Ring programming language including Read(), Write(), Dir(), Rename(), Remove(), Fopen(), Fclose(), Fflush(), Freopen(), Tempfile(), Tempname(), Fseek(), Ftell(), and provides examples of how to use each function to read, write, modify and get information about files. It also covers opening and closing files, seeking to different positions in a file, generating temporary file names and more.
Numerical Methods with Computer ProgrammingUtsav Patel
This document contains summaries of 9 numerical methods programs written in C++ including: Bisection Method, Regula-Falsi Method, Secant Method, Newton-Raphson Method, Gauss-Jordan Method, Gauss Elimination Method, Method of Least Squares, Euler's Method, and Runge-Kutta Method. For each method, the document provides the program code, sample output, and a brief 1-2 sentence description.
Example of Dynamic Programming to achieve O(n).
Interview question: N houses, each with weighting on value of goods. How can a burglar maximise profit if they are not allowed to visit neighbouring houses?
Solution: optimum(i) = max( optimum(i-1)-w(i-1)+w(i) , optimum(i-2)+w(i) )
Web services are open standard-based applications that allow for the exchange of data between web applications. They use technologies like XML, SOAP, and HTTP to enable interoperability between different operating systems and programming languages. Web services are self-contained, distributed applications that can be described, published, and invoked over a network to share information in a standardized way.
The document provides an introduction to web services. It defines a web service as a piece of software that makes itself available over the internet using standardized XML messaging. Web services communicate using open protocols and can be published, discovered, and used by other applications. The document outlines that web services are application components that are self-contained, self-describing, and use HTTP and XML as the basis for communication. It also notes that web services take web applications to the next level by allowing different platforms to interact in a way that earlier web applications could not due to interoperability issues.
This document configures IP addresses, firewall NAT, routing, and firewall mangle rules on a router with 3 interfaces: ether1, ether3, ether4. It sets IP addresses for the interfaces, enables masquerading for ether3 and ether4. Traffic incoming on ether1 is classified and marked to be routed out either ether3 or ether4 interfaces based on destination address. Routing tables are configured to send traffic with specific marks out the corresponding interfaces.
This C++ program implements a binomial heap data structure. It includes functions to insert nodes, extract the minimum node, decrease a node's key, delete a node, and display the heap. The main function provides a menu for testing these binomial heap operations on a sample run of the program.
The Ring programming language version 1.2 book - Part 55 of 84Mahmoud Samir Fayed
The document discusses different methods for distributing Ring applications, including:
1) Copying the Ring files and renaming the executable to distribute Windows applications.
2) Generating an object file from Ring code to protect the source code when distributing applications.
3) Using tools like NSIS to create Windows installers for applications.
4) Compiling Ring code with a C/C++ compiler and linker to create executable files.
5) Embedding Ring in Qt or LibSDL projects to build mobile apps and games for distribution.
The Ring programming language version 1.10 book - Part 31 of 212Mahmoud Samir Fayed
The document provides information about string manipulation in Ring programming language. It describes how to create strings, get string length, convert case, access characters, trim whitespace, compare strings, and convert between strings and lists. Functions covered include len(), upper(), lower(), left(), right(), trim(), copy(), lines(), substr(), strcmp(), str2list(), and list2str(). It also discusses merging binary character values from strings.
The Ring programming language version 1.5.4 book - Part 23 of 185Mahmoud Samir Fayed
This document discusses various string and date/time functions in Ring. It describes how to get string lengths, convert case, access characters, trim strings, find/replace substrings. It also covers getting the system time, date, and converting between strings and lists of lines. Functions covered include len(), upper()/lower(), left(), right(), trim(), copy(), lines(), substr(), strcmp(), str2list(), list2str(), time(), date(), and timelist().
The Ring programming language version 1.6 book - Part 25 of 189Mahmoud Samir Fayed
This document provides summaries of various string, date, and time functions in Ring programming language. It explains how to work with string literals, get string length, convert case, access characters, trim strings, duplicate strings, count lines, find/extract substrings, compare strings, and convert between strings and lists. It also covers functions for getting the current time and date, adding/comparing days, and getting detailed time information in a list.
The document contains 9 Java programs (Ejercicio_1 through Ejercicio_9) that demonstrate various exercises using arrays and vectors. Each program defines a class with a main method that declares variables, initializes arrays/vectors, uses loops to input/output values, and performs basic operations like summing, averaging, searching.
The Ring programming language version 1.5.1 book - Part 23 of 180Mahmoud Samir Fayed
This document provides an overview of mathematical and file handling functions available in the Ring programming language. In the mathematical functions section, it lists common functions like sin(), cos(), tan(), log(), sqrt(), and random(). Examples are provided to demonstrate their usage. The files section describes functions for reading, writing, getting directory listings, renaming, deleting files as well as lower level file handling functions. Specific functions covered include Read(), Write(), Dir(), fopen(), fclose(), fseek(), ftell(), and others.
The Ring programming language version 1.8 book - Part 28 of 202Mahmoud Samir Fayed
This chapter discusses string manipulation functions in Ring. It covers creating and accessing string literals and characters, converting case, trimming whitespace, comparing and searching strings, and converting between strings and lists. Functions covered include len(), upper(), lower(), trim(), copy(), left(), right(), substr(), strcmp(), and str2list(). The chapter also discusses working with dates and times using functions like date(), time(), addDays(), and diffDays().
Problem Solving Techniques For Evolutionary DesignNaresh Jain
In this workshop, Naresh Jain explains what are the core techniques one should master to effectively practice evolutionary design while solving real-world problems. To summarize:
1. Eliminate Noise - Distill down the crux of the problem
2. Divide and Conquer to prioritize and focus on the most important part
3. Add constraints to future simplify the problem
4. Come up with a simple design to incrementally build your solution
5. Refactor: Pause, look for a much simpler alternative
6. Be ready to throw away your solution & start again
The Ring programming language version 1.5.3 book - Part 40 of 184Mahmoud Samir Fayed
This document provides an overview and examples of developing web applications using Ring's CGI library. It discusses configuring the Apache web server to support Ring CGI scripts, and provides a basic "Hello World" CGI example. It then demonstrates using the Web library to simplify CGI development, covering features like generating HTML, HTTP GET and POST requests, file uploads, and templates. Examples are given for an HTTP GET form and processing the response.
The Ring programming language version 1.5.3 book - Part 23 of 184Mahmoud Samir Fayed
The document discusses various string and date/time functions in Ring programming language. It describes how to create and manipulate strings, get string length, convert case, access characters, trim strings, compare strings, and convert between strings and lists. It also explains functions to work with dates and times, like getting the current date/time, adding/subtracting days, and converting between dates and epoch seconds.
The document contains code for several C++ programs that demonstrate basic programming concepts like arrays, matrices, structures, and functions. Specifically, it includes code snippets that: 1) sort an array using a bubble sort algorithm; 2) calculate the sum of each row in a matrix; and 3) define a structure to store personal details like name, date of birth, address etc. and accept user input for an object of that structure.
This document contains C++ code that implements various classical ciphers including Caesar cipher, Playfair cipher, Affine cipher, Autokey cipher, and Vigenere cipher. The code provides functions for encrypting and decrypting messages with each cipher. The main function allows a user to select which cipher to use and whether to encrypt or decrypt a message by entering inputs. It then calls the relevant encryption or decryption functions and displays the output.
1. Loops (while and for) allow repeating a block of code multiple times based on a condition. Key loop components are the condition, statement list, and condition update.
2. Nested loops involve loops within other loops, allowing multiple levels of repetition. Variables used in inner loops may shadow those in outer loops.
3. Loop scopes determine variable visibility. Variables declared within loops are local to the loop and not accessible outside. Variables declared before loops can be accessed within and outside loops.
The Ring programming language version 1.5.4 book - Part 25 of 185Mahmoud Samir Fayed
This document describes various file handling functions in Ring programming language including Read(), Write(), Dir(), Rename(), Remove(), Fopen(), Fclose(), Fflush(), Freopen(), Tempfile(), Tempname(), Fseek(), Ftell(), and provides examples of how to use each function to read, write, modify and get information about files. It also covers opening and closing files, seeking to different positions in a file, generating temporary file names and more.
Numerical Methods with Computer ProgrammingUtsav Patel
This document contains summaries of 9 numerical methods programs written in C++ including: Bisection Method, Regula-Falsi Method, Secant Method, Newton-Raphson Method, Gauss-Jordan Method, Gauss Elimination Method, Method of Least Squares, Euler's Method, and Runge-Kutta Method. For each method, the document provides the program code, sample output, and a brief 1-2 sentence description.
Example of Dynamic Programming to achieve O(n).
Interview question: N houses, each with weighting on value of goods. How can a burglar maximise profit if they are not allowed to visit neighbouring houses?
Solution: optimum(i) = max( optimum(i-1)-w(i-1)+w(i) , optimum(i-2)+w(i) )
Web services are open standard-based applications that allow for the exchange of data between web applications. They use technologies like XML, SOAP, and HTTP to enable interoperability between different operating systems and programming languages. Web services are self-contained, distributed applications that can be described, published, and invoked over a network to share information in a standardized way.
The document provides an introduction to web services. It defines a web service as a piece of software that makes itself available over the internet using standardized XML messaging. Web services communicate using open protocols and can be published, discovered, and used by other applications. The document outlines that web services are application components that are self-contained, self-describing, and use HTTP and XML as the basis for communication. It also notes that web services take web applications to the next level by allowing different platforms to interact in a way that earlier web applications could not due to interoperability issues.
The document discusses various graphical user interface controls in C#, including menus, link labels, list boxes, combo boxes, tree views, and tab controls. It provides code examples to demonstrate how to implement menus with options to change font colors and styles, as well as link labels that link to other programs or files when clicked. Event handlers are used to handle user interactions with the controls.
The document discusses graphics and media capabilities in .NET, including graphics contexts, colors, fonts, and images. It covers creating graphics objects, setting colors using RGB values or names, constructing fonts and accessing font metrics, and loading/displaying images. Code examples are provided to demonstrate these graphics and font capabilities.
The document outlines control structures in programming, including counter-controlled repetition, the for loop structure, the switch multiple-selection structure, and the do/while repetition structure. It provides code examples to demonstrate these structures, including initializing and incrementing counters, using break and continue statements to alter loop flow, and displaying output.
The document discusses object-oriented programming concepts like inheritance, base classes, and derived classes. It provides code examples to illustrate inheritance relationships between classes like Point, Circle, and Cylinder. The code defines base classes like Point and derived classes like Circle that inherit properties and methods from their base classes. Tests are provided to create objects from derived classes and demonstrate inherited functionality.
This document discusses XML and the Document Object Model (DOM). It introduces XML documents and namespaces. It describes how the DOM represents an XML document as a tree structure with parent and child nodes. It provides code examples for reading an XML file using an XmlReader, and manipulating an XML document's DOM tree by building a copy of the tree as TreeNodes in a TreeView control.
Hang Son Doong cave in Vietnam is the largest cave in the world. Discovered in 1991 by Ho-Khanh, it wasn't until 2009 when British scientists surveyed it that its massive size was known. One of its caverns could fit an entire New York City block and it holds a river and jungle inside. National Geographic documented the cave in 2010, revealing its chambers that are over 5 km long, 200m high, and 150m wide, making it twice the size of the previous largest cave.
The document describes how to search directories and files using the File and Directory classes in C#. It defines a regular expression to match file extensions and stores the number of files found for each extension. The program recursively searches all subdirectories, counts the number of files for each extension, and outputs a summary of the results. It also checks for and allows deleting any backup (.bak) files found.
This document provides an introduction to basic electronics concepts including electricity, voltage, current, resistance, LEDs, Ohm's law, and capacitors. It covers the following key points in 3 sentences:
The document defines basic concepts of electricity including how electrons flow in conductors to create currents, and defines voltage and current. It explains how voltage, current, and resistance are related by Ohm's law and how to measure these quantities using a multimeter. Various circuit components such as LEDs, resistors, capacitors, and breadboards are introduced along with exercises to apply concepts of series and parallel circuits.
The document describes object-oriented programming concepts like classes, objects, encapsulation, and properties. It provides code examples of a Time class that encapsulates time data and provides methods to work with it. The Time class uses properties to safely access private member variables for hour, minute and second. Constructors are demonstrated that initialize Time objects with different parameters.
El documento proporciona información sobre diferentes medicamentos hipolipemiantes y antihipertensivos, incluyendo sus indicaciones, mecanismos de acción, efectos adversos y precauciones. Describe resinas de intercambio iónico, derivados del ácido fíbrico, estatinas e inhibidores de la HMG-CoA reductasa para tratar la hiperlipemia. También cubre antagonistas alfa adrenérgicos centrales, antagonistas de acción periférica, vasodilatadores directos y bloqueadores beta como agentes antihipertensivos
This chapter discusses ASP.NET web forms and controls. It introduces the system architecture of web applications with different tiers. It then demonstrates creating a simple web form application in Visual Studio that displays the current time using labels and setting properties in the code-behind file. The application is run locally and the generated HTML is shown.
The document is a list of English activities for the first years of high school provided by Professor Carla Aurora. It reviews imperative verbs and time clauses studied in the previous month. Students are instructed to complete exercises on these grammar points using their textbook and notebook. The exercises practice forming imperative and negative sentences, as well as writing time clauses with verbs in various tenses. Comprehension questions follow a short English text about a US Army captain's perspective on fighting in Iraq.
This document outlines the key concepts covered in Chapter 3 of an introduction to C# programming textbook. It discusses simple programs that print text, perform basic math operations, and make decisions using relational operators. Code examples are provided to demonstrate how to write, compile, and run simple C# console applications and use basic programming elements like variables, methods, and conditional statements.
The document provides an overview of web service implementation using ASP.NET. It defines web services as software components that can be published, located, and run over the Internet using XML. The key points covered include: how web services work by allowing client applications to request and use classes and methods hosted on a web server; the technologies that power web services including the web, XML, and service-oriented architecture (SOA); how to create a basic web service in ASP.NET and test it using a client application.
The document outlines a chapter on methods in C#. It discusses key concepts like defining methods, passing arguments by value vs reference, and using built-in classes like Math. It provides examples of methods that square integers, find the maximum of 3 numbers, and demonstrate passing by reference and out parameters.
The document discusses the differences between consumer/hobbyist Web of Things (WoT) and industrial WoT. Industrial WoT focuses on robustness, efficiency, collaboration, high quality, and automation rather than being lightweight and human-actionable. It also has higher non-functional requirements around security, reliability and scalability. The document advocates applying modern software engineering practices like continuous delivery, DevOps, automation, containers and on-demand testing to the industrial WoT to enable innovative yet high-quality connected physical systems.
1. The document discusses elementary programming concepts in Java such as variables, data types, operators, and expressions. It provides examples of computing the area of a circle and converting temperatures between Fahrenheit and Celsius.
2. Tracing the execution of a sample area computation program is demonstrated. Key steps include declaring variables, assigning values, performing calculations, and printing output.
3. Numeric data types in Java are explained along with various arithmetic operators for performing calculations on integer and floating-point values.
Modify this code to use multiple threads with the same data1.Modif.pdfmallik3000
Modify this code to use multiple threads with the same data
1.Modify the main function to implement a loop that reads 10 integers from the console (user
input) and stores these numbers in a one-dimensional (1D) array (this code will go right after the
comment that says “Add code to perform any needed initialization or to process user input”).
You should use a global array for this.
2.Implement a separatepthread function function for each one of the following operations:
a.Count and print out how many of the entered numbers are negative. This function must be
named countNegatives
b.Calculate and print the average value of all the numbers entered. This function must be named
average
c.Print the numbers in reverse order from the order in which they were entered. This function
must be named reverse
3.Modify the main function to create one pthread for each one of the functions that you
implemented in (3) above (this code will go between the comment that says “TODO: Modify
according to assignment requirements” and the “if (rc)” check).
Compile your program and run it several times. If the output of your program is garbled, you
may need to add a small delay in between creating the next thread.
#include
#include
using namespace std;
void *routineName(void *arg)
{
// TODO: Add code that implements
// the thread\'s functionality
cout << \"Thread is running...\" << endl;
return 0;
}
int main()
{
pthread_t id;
int rc;
int ints;
for(int x; x<10; x++)
{
cout << \"Enter Integer: \" <>
}
rc = pthread_create(&id, NULL, routineName, NULL);
if (rc){
cout << \"ERROR; return code from pthread_create() is \" << rc << endl;
return -1;
}
pthread_exit(0);
}
Solution
#include
#include
#include
using namespace std;
int ints[10];
//Method to count negatives in the input array
void *countNegatives(void*){
int count = 0;
for(int i=0;i<10;i++){
if(ints[i]<0){
count++;
}
}
cout<<\"Number of negatives: \"<=0;i--){
cout<> ints[x];
}
//Creating pthread to countNegatives
rc = pthread_create(&t1, NULL, countNegatives, NULL);
if(rc){
cout << \"Error:unable to create thread,\" << rc << endl;
}
//Adding delay
sleep(1);
//Creating pthread to compute average
rc = pthread_create(&t2, NULL, average, NULL);
if(rc){
cout << \"Error:unable to create thread,\" << rc << endl;
}
//Adding delay
sleep(1);
//Creating pthread to print in reverse
rc = pthread_create(&t3, NULL, reverse, NULL);
if(rc){
cout << \"Error:unable to create thread,\" << rc << endl;
}
//Adding delay
sleep(1);
void* status;
//waiting for t1 to join
rc = pthread_join(t1,&status);
if(rc){
cout << \"Error:unable to join,\" << rc << endl;
}
//waiting for t2 to join
rc = pthread_join(t2,&status);
if(rc){
cout << \"Error:unable to join,\" << rc << endl;
}
//waiting for t3 to join
rc = pthread_join(t3,&status);
if(rc){
cout << \"Error:unable to join,\" << rc << endl;
}
pthread_exit(0);
}.
The document describes an implementation of the simulated annealing algorithm to solve the traveling salesman problem. It defines a City class to represent locations with name, coordinates, and derived Metro class to add remarks. It includes functions to calculate distance between cities, total route distance, and acceptance probability for simulated annealing. The main function gets user input for cities, runs simulated annealing to optimize the route, and outputs results.
The document provides an overview of key concepts in the C# programming language including variables and data types, arrays, conditional logic, loops, methods, parameters, and delegates. It discusses basic syntax, operators, and how to perform common tasks like type conversions and working with dates and strings. The goal is to give readers enough information to get started with C# as well as refer back to for language details while working through ASP.NET examples.
This document discusses batch processing using Apache Flink. It provides code examples of using Flink's DataSet and Table APIs to perform batch word count jobs. It also covers iterative algorithms in Flink, including how Flink handles bulk and delta iterations more efficiently than other frameworks like Spark and MapReduce. Delta iterations are optimized by only processing changes between iterations to reduce the working data set size over time.
The document discusses functions in C++. It defines functions as modular pieces that divide programs into more manageable components. It describes function components like modules, functions, classes, and function calls. It provides examples of math library functions and how to define, call, and prototype functions. It also covers function parameters, return types, and scope rules for local variables and storage classes.
This document contains the source code for a Java program that demonstrates various programming concepts to a user through a conversational interface. It walks the user through examples of data types, variables, input/output, mathematical operations, conditional statements, arrays and more. It collects user input, performs calculations, and provides feedback and explanations at each step. The overall purpose is to educate the user about basic Java programming concepts in an interactive way.
The document provides code examples to generate different patterns using loops in C++. It includes code to:
1. Generate patterns like A B C D E F G, A B C E F G, A B F G, A G using nested for loops.
2. Generate patterns like 1, 1 2, 1 2 3 using nested for loops.
3. Generate patterns like *, * *, * * * using for loops and whitespace formatting.
4. Generate patterns like 1, 121, 1331, 14641 using pow() function.
It also includes code for a class to generate different patterns based on user input, code to display numbers in octal, decimal and hexadecimal format,
C++ Nested loops, matrix and fuctions.pdfyamew16788
Nested loops allow executing a set of statements multiple times in a loop within another loop. This can be used to iterate over multidimensional data structures. The outer loop completes one full iteration for each iteration of the inner loop, nesting the loops within each other. Functions allow breaking programs into reusable blocks of code to perform specific tasks, with declarations informing the compiler of functions' names, return types, and parameters, while definitions contain the function body.
The document provides an introduction to parallel programming basics, including why parallel programming is useful, what parallel programming is, and how to perform parallel programming in languages like C++, MATLAB, and C#. It gives an example of a simple sequential C++ program and walks through how it could be parallelized using tools like OpenMP and TBB. It also discusses other parallelization methods like std::thread in C++ and the parfor function in MATLAB.
The document discusses functions in C++. It provides examples of functions without parameters or return values, functions with return values but no parameters, functions with both parameters and return values, and functions that return references. It also discusses passing arguments to functions by reference, const reference, and using inline functions to avoid function call overhead.
JavaScript is evolving. It’s an exciting time to be involved with this ubiquitous language of the web. Every year, we get exciting new features landing as part of the language. Let’s explore the freshly released features that were part of the 2019 ECMAScript specification. We’ll also briefly explore the process of how new features get proposed and added to the language, as well as the leading contenders expected to land in ES2020.
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...ssuserd6b1fd
C++ programming language notes for beginners and Collage students. Written for beginners. Colored graphics. Function by Function explanation with complete examples. Well commented examples. Illustrations are made available for data dealing at memory level.
02 of 02 parts,
Get Part 1 from https://www.slideshare.net/ArunUmrao/introduction-to-c-programming-for-beginners-by-arunumrao-1-of-2
Introduction to c++ programming, Introduction to c++ programming, Introduction to c++ programming, Introduction to c++ programming,
The document discusses various operators in C++ including assignment operators, increment and decrement operators, logical operators, and the common mistake of confusing the equality operator (==) and the assignment operator (=).
It provides examples of how to use assignment operator abbreviations, preincrement and postincrement operators, logical operators like AND (&&), OR (||), and NOT (!) in conditions. It also demonstrates the different repetition structures like while, for, and do-while loops. Finally, it cautions about accidentally using the assignment operator instead of equality operator in conditions.
The document contains the code for a menu driven C++ program that performs various operations on matrices such as calculating row and column sums, finding the transpose, and checking if two matrices are equal. It defines functions to perform these operations and contains a main function that inputs the matrices, displays a menu, and calls the appropriate functions based on the user's selection.
The document describes the objectives of a C++ lab course. It includes:
1. Designing classes with static members, methods with default arguments, and friend functions like a matrix and vector class.
2. Implementing a complex number class with operator overloading.
3. Implementing a matrix class with dynamic memory allocation.
4. Overloading new and delete operators for custom memory allocation.
5. Developing linked list and sorting algorithm templates.
Arrry structure Stacks in data structurelodhran-hayat
There are two types of arrays in C++: single dimensional and multidimensional arrays. The document then provides examples of using single dimensional arrays, traversing arrays using for loops and foreach loops, using structs with constructors and methods, pointers including declaring, assigning, and dereferencing pointers, and dynamic memory allocation using new and delete operators for built-in types, arrays, objects, and multidimensional arrays.
This document outlines key concepts related to data structures including linked lists, stacks, queues, and trees. It provides code examples of a Node class that is self-referential, allowing objects to link to one another. A LinkedListLibrary class is defined, with methods for inserting and removing nodes from linked lists. A ListTest class tests the functionality of the List class.
The document discusses accessibility in web development and software applications. It covers regulations and guidelines for accessibility from the Web Accessibility Initiative (WAI) and other organizations. It also provides examples of implementing accessibility in Visual Studio .NET, C#, XHTML, and Microsoft Windows, including features for visual impairments, hearing impairments, and mobility issues. Specific techniques discussed include adding alt text for images, proper use of headings and structure, keyboard shortcuts, screen reading support, font size adjustments, and more.
The document discusses accessibility in web development and software applications. It covers topics like web accessibility guidelines, providing alternatives for images, maximizing readability in structures, accessibility in Visual Studio .NET, C#, XHTML tables and frames, and accessibility tools. Code examples are provided to demonstrate making applications more accessible for people with disabilities.
The document discusses client-server networking using both stream sockets and datagrams. It provides code examples for a server and client application that allow text-based communication using stream sockets, establishing a connection between the two. It also gives an example of a connectionless server and client that can send and receive datagrams containing byte arrays to simulate a chat. The server waits for packets and displays the contents, then echoes the data back to the client.
The document outlines how to connect to and query an Access database using ADO.NET in C#. It describes creating a TableDisplay form with a DataGrid to display query results. The form initializes a DataSet and OleDbDataAdapter to retrieve data from the Authors table and bind it to the DataGrid. It also configures OleDbCommands for selecting, inserting, updating, and deleting data.
The document outlines the key topics covered in Chapter 15 on strings and characters in C#, including fundamentals of characters and strings, string constructors, using the string indexer and length property, comparing strings, and using methods like StartsWith and EndsWith. Code examples are provided to demonstrate using features like the string indexer, Length property, CopyTo method, comparing strings with Equals and CompareTo, and checking if a string starts or ends with a substring.
The document describes multithreading concepts in .NET including thread states, priorities, synchronization, and the producer-consumer relationship. It provides code examples to demonstrate threading without and with synchronization. Key points covered include allowing concurrent execution with threads, thread life cycles and states, using monitors for synchronization, and ensuring proper communication between producer and consumer threads.
This document provides an outline and overview of Chapter 12 which covers graphical user interface (GUI) concepts in Windows Forms. The chapter introduces GUI components like windows, controls, properties, events and event handling. It describes common controls like labels, text boxes, buttons and how to set properties, handle events, and lay out controls on a form. Code examples are provided to demonstrate creating a simple form with a textbox, label and button to display text on a label when a button is clicked.
This document discusses exception handling in C# and .NET. It provides examples of try/catch blocks, the different exception classes in .NET, and how to access exception properties like Message and StackTrace. Code samples are given that demonstrate throwing, catching, and rethrowing exceptions. Finally blocks are also discussed and shown to always execute even if an exception occurs.
The document discusses object-oriented programming concepts like polymorphism. It includes:
- An introduction to polymorphism and how it allows programs to handle related classes generically and be easily extensible.
- Examples of polymorphism including a shape hierarchy with classes like Quadrilateral, Rectangle, etc. and a space object hierarchy with classes that all implement a DrawYourself method.
- Details about abstract classes and how they provide base classes that concrete classes inherit from while requiring the concrete classes to implement abstract methods and properties.
- A case study demonstrating inheritance and polymorphism using abstract base class Shape and concrete classes Point2, Circle2, and Cylinder2 that inherit from Shape.
The document outlines key concepts about arrays including:
- Declaring and allocating arrays
- Initializing arrays with initializer lists or dynamically with 'new'
- Accessing array elements using indexes/subscripts
- Common array operations like totaling elements, creating histograms, and using arrays as counters
It provides code examples demonstrating initializing arrays, summing array elements, creating a histogram to display array data, and using arrays as counters in a dice rolling simulation program.
The document outlines control structures in programming including algorithms, pseudocode, selection structures like if/else, repetition structures like while loops, and case studies applying these concepts. Key topics are counter-controlled and sentinel-controlled repetition for loops, and nesting control structures with if statements inside loops. Examples in C# demonstrate accumulating values in loops and nested if/else statements.
The document provides an overview of the Visual Studio .NET integrated development environment (IDE). It describes the main interface elements like the menu bar, toolbar, solution explorer, toolbox and properties window. It then demonstrates how to create a simple project in Visual Studio .NET that displays text in a label and an image in a picture box without writing any code, using the drag and drop features of the IDE.
The document provides an overview of computers, operating systems, programming languages, the internet, and Microsoft .NET. It discusses the evolution of computers from early mainframes to personal computers and networks. It covers the development of operating systems, languages like C, C++, Java and C#, and web technologies like HTML, XML and the World Wide Web. It also summarizes Microsoft's .NET framework and how it allows applications to be developed in any .NET compatible language and run across platforms using the Common Language Runtime.
The document outlines key concepts about data structures including linked lists, stacks, queues, and trees. It provides code examples for a Node class that is self-referential, allowing objects to link to each other. It also includes a List class that implements basic linked list functionality through methods like InsertAtFront, InsertAtBack, RemoveFromFront, and RemoveFromBack. The code examples demonstrate how to create and manipulate linked lists through a List object.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
Full-RAG: A modern architecture for hyper-personalizationZilliz
Mike Del Balso, CEO & Co-Founder at Tecton, presents "Full RAG," a novel approach to AI recommendation systems, aiming to push beyond the limitations of traditional models through a deep integration of contextual insights and real-time data, leveraging the Retrieval-Augmented Generation architecture. This talk will outline Full RAG's potential to significantly enhance personalization, address engineering challenges such as data management and model training, and introduce data enrichment with reranking as a key solution. Attendees will gain crucial insights into the importance of hyperpersonalization in AI, the capabilities of Full RAG for advanced personalization, and strategies for managing complex data integrations for deploying cutting-edge AI solutions.
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfMalak Abu Hammad
Discover how MongoDB Atlas and vector search technology can revolutionize your application's search capabilities. This comprehensive presentation covers:
* What is Vector Search?
* Importance and benefits of vector search
* Practical use cases across various industries
* Step-by-step implementation guide
* Live demos with code snippets
* Enhancing LLM capabilities with vector search
* Best practices and optimization strategies
Perfect for developers, AI enthusiasts, and tech leaders. Learn how to leverage MongoDB Atlas to deliver highly relevant, context-aware search results, transforming your data retrieval process. Stay ahead in tech innovation and maximize the potential of your applications.
#MongoDB #VectorSearch #AI #SemanticSearch #TechInnovation #DataScience #LLM #MachineLearning #SearchTechnology
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceIndexBug
Imagine a world where machines not only perform tasks but also learn, adapt, and make decisions. This is the promise of Artificial Intelligence (AI), a technology that's not just enhancing our lives but revolutionizing entire industries.
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
Maruthi Prithivirajan, Head of ASEAN & IN Solution Architecture, Neo4j
Get an inside look at the latest Neo4j innovations that enable relationship-driven intelligence at scale. Learn more about the newest cloud integrations and product enhancements that make Neo4j an essential choice for developers building apps with interconnected data and generative AI.
Infrastructure Challenges in Scaling RAG with Custom AI modelsZilliz
Building Retrieval-Augmented Generation (RAG) systems with open-source and custom AI models is a complex task. This talk explores the challenges in productionizing RAG systems, including retrieval performance, response synthesis, and evaluation. We’ll discuss how to leverage open-source models like text embeddings, language models, and custom fine-tuned models to enhance RAG performance. Additionally, we’ll cover how BentoML can help orchestrate and scale these AI components efficiently, ensuring seamless deployment and management of RAG systems in the cloud.
Climate Impact of Software Testing at Nordic Testing DaysKari Kakkonen
My slides at Nordic Testing Days 6.6.2024
Climate impact / sustainability of software testing discussed on the talk. ICT and testing must carry their part of global responsibility to help with the climat warming. We can minimize the carbon footprint but we can also have a carbon handprint, a positive impact on the climate. Quality characteristics can be added with sustainability, and then measured continuously. Test environments can be used less, and in smaller scale and on demand. Test techniques can be used in optimizing or minimizing number of tests. Test automation can be used to speed up testing.
For the full video of this presentation, please visit: https://www.edge-ai-vision.com/2024/06/building-and-scaling-ai-applications-with-the-nx-ai-manager-a-presentation-from-network-optix/
Robin van Emden, Senior Director of Data Science at Network Optix, presents the “Building and Scaling AI Applications with the Nx AI Manager,” tutorial at the May 2024 Embedded Vision Summit.
In this presentation, van Emden covers the basics of scaling edge AI solutions using the Nx tool kit. He emphasizes the process of developing AI models and deploying them globally. He also showcases the conversion of AI models and the creation of effective edge AI pipelines, with a focus on pre-processing, model conversion, selecting the appropriate inference engine for the target hardware and post-processing.
van Emden shows how Nx can simplify the developer’s life and facilitate a rapid transition from concept to production-ready applications.He provides valuable insights into developing scalable and efficient edge AI solutions, with a strong focus on practical implementation.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Best 20 SEO Techniques To Improve Website Visibility In SERPPixlogix Infotech
Boost your website's visibility with proven SEO techniques! Our latest blog dives into essential strategies to enhance your online presence, increase traffic, and rank higher on search engines. From keyword optimization to quality content creation, learn how to make your site stand out in the crowded digital landscape. Discover actionable tips and expert insights to elevate your SEO game.
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!SOFTTECHHUB
As the digital landscape continually evolves, operating systems play a critical role in shaping user experiences and productivity. The launch of Nitrux Linux 3.5.0 marks a significant milestone, offering a robust alternative to traditional systems such as Windows 11. This article delves into the essence of Nitrux Linux 3.5.0, exploring its unique features, advantages, and how it stands as a compelling choice for both casual users and tech enthusiasts.
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Building Production Ready Search Pipelines with Spark and MilvusZilliz
Spark is the widely used ETL tool for processing, indexing and ingesting data to serving stack for search. Milvus is the production-ready open-source vector database. In this talk we will show how to use Spark to process unstructured data to extract vector representations, and push the vectors to Milvus vector database for search serving.
GraphRAG for Life Science to increase LLM accuracyTomaz Bratanic
GraphRAG for life science domain, where you retriever information from biomedical knowledge graphs using LLMs to increase the accuracy and performance of generated answers
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Speck&Tech
ABSTRACT: A prima vista, un mattoncino Lego e la backdoor XZ potrebbero avere in comune il fatto di essere entrambi blocchi di costruzione, o dipendenze di progetti creativi e software. La realtà è che un mattoncino Lego e il caso della backdoor XZ hanno molto di più di tutto ciò in comune.
Partecipate alla presentazione per immergervi in una storia di interoperabilità, standard e formati aperti, per poi discutere del ruolo importante che i contributori hanno in una comunità open source sostenibile.
BIO: Sostenitrice del software libero e dei formati standard e aperti. È stata un membro attivo dei progetti Fedora e openSUSE e ha co-fondato l'Associazione LibreItalia dove è stata coinvolta in diversi eventi, migrazioni e formazione relativi a LibreOffice. In precedenza ha lavorato a migrazioni e corsi di formazione su LibreOffice per diverse amministrazioni pubbliche e privati. Da gennaio 2020 lavora in SUSE come Software Release Engineer per Uyuni e SUSE Manager e quando non segue la sua passione per i computer e per Geeko coltiva la sua curiosità per l'astronomia (da cui deriva il suo nickname deneb_alpha).
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Csphtp1 21
1. Chapter 21 – ASP .NET and Web Services Outline 21.1 Introduction 21.2 Web Services 21.3 Simple Object Access Protocol (SOAP) and Web Services 21.4 Publishing and Consuming Web Services 21.5 Session Tracking in Web Services 21.6 Using Web Forms and Web Services 21.7 Case Study: Temperature Information Application 21.8 User-Defined Types in Web Services
2. 21.2 Web Services Fig. 21.1 ASMX file rendered in Internet Explorer. Link to service description Links to web service methods
3. 21.2 Web Services Fig. 21.2 Service description for a Web service.
4. 21.2 Web Services Fig. 21.3 Invoking a method of a Web service from a Web browser.
5. 21.2 Web Services Fig. 21.4 Results of invoking a Web-service method from a Web browser.
6. 21.3 Simple Object Access Protocol (SOAP) and Web Services Fig. 21.5 SOAP request for the HugeInteger Web service. Name of method Represent arguments named first and second . The value string indicates that they need to be of type string , but in a method call they would be replaced with the argument values.
7. HugeInteger.asmx.cs 1 // Fig. 21.6: HugeInteger.asmx.cs 2 // HugeInteger Web Service. 3 4 using System; 5 using System.Text; 6 using System.Collections; 7 using System.ComponentModel; 8 using System.Data; 9 using System.Diagnostics; 10 using System.Web; 11 using System.Web.Services; // contains Web service related classes 12 13 namespace HugeIntegerWebService 14 { 15 /// <summary> 16 /// performs operations on large integers 17 /// </summary> 18 [ WebService( 19 Namespace = "http://www.deitel.com/csphtp1/ch21/" , 20 Description = "A Web service which provides methods that" + 21 " can manipulate large integer values." ) ] 22 public class HugeInteger : System.Web.Services.WebService 23 { 24 // default constructor 25 public HugeInteger() 26 { 27 // CODEGEN: This call is required by the ASP .NET Web 28 // Services Designer 29 InitializeComponent(); 30 31 number = new int [ MAXIMUM ]; 32 } 33 Set Namespace property of WebService attribute to specify the namespace that the Web service belongs to Set Description property of WebService attribute to describe the function of the Web Service Class HugeInteger inherits from System.Web.Services.WebService
8. HugeInteger.asmx.cs 34 #region Component Designer generated code 35 /// <summary> 36 /// Required method for Designer support - do not modify 37 /// the contents of this method with the code editor. 38 /// </summary> 39 private void InitializeComponent() 40 { 41 } 42 #endregion 43 44 /// <summary> 45 /// Clean up any resources being used. 46 /// </summary> 47 protected override void Dispose( bool disposing ) 48 { 49 } 50 51 // WEB SERVICE EXAMPLE 52 // The HelloWorld() example service returns 53 // the string Hello World 54 // To build, uncomment the following lines 55 // then save and build the project 56 // To test this web service, press F5 57 58 // [WebMethod] 59 // public string HelloWorld() 60 // { 61 // return "Hello World"; 62 // } 63 64 private const int MAXIMUM = 100 ; 65 66 public int [] number; 67
9. HugeInteger.asmx.cs 68 // indexer that accepts an integer parameter 69 public int this [ int index ] 70 { 71 get 72 { 73 return number[ index ]; 74 } 75 76 set 77 { 78 number[ index ] = value ; 79 } 80 81 } // end indexer 82 83 // returns string representation of HugeInteger 84 public override string ToString() 85 { 86 StringBuilder returnString = new StringBuilder(); 87 88 foreach ( int digit in number ) 89 returnString.Insert( 0 , digit ); 90 91 return returnString.ToString(); 92 } 93 94 // creates HugeInteger based on argument 95 public static HugeInteger FromString( string integer ) 96 { 97 HugeInteger parsedInteger = new HugeInteger(); 98 99 for ( int i = 0 ; i < integer. Length ; i++ ) 100 parsedInteger[ i ] = Int32.Parse( 101 integer[ integer. Length - i - 1 ].ToString() ); Indexer for class HugeInteger
10. HugeInteger.asmx.cs 102 103 return parsedInteger; 104 } 105 106 // WebMethod that performs integer addition 107 // represented by string arguments 108 [ WebMethod ( Description = "Adds two huge integers." ) ] 109 public string Add( string first, string second ) 110 { 111 int carry = 0 ; 112 113 HugeInteger operand1 = HugeInteger.FromString( first ); 114 HugeInteger operand2 = 115 HugeInteger.FromString( second ); 116 117 // store result of addition 118 HugeInteger result = new HugeInteger(); 119 120 // perform addition algorithm for each digit 121 for ( int i = 0 ; i < MAXIMUM ; i++ ) 122 { 123 // add two digits in same column 124 // result is their sum, plus carry from 125 // previous operation modulus 10 126 result[ i ] = 127 ( operand1[ i ] + operand2[ i ] ) % 10 + carry; 128 129 // store remainder of dividing 130 // sums of two digits by 10 131 carry = ( operand1[ i ] + operand2[ i ] ) / 10 ; 132 } 133 134 return result.ToString(); 135 136 } // end method Add Method Add that adds two HugeInteger s WebMethod attribute specifies that this method may be called by remote client applications Description property of WebMethod attribute summarizes the function of the method
11. HugeInteger.asmx.cs 137 138 // WebMethod that performs the subtraction of integers 139 // represented by string arguments 140 [ WebMethod ( 141 Description = "Subtracts two huge integers." ) ] 142 public string Subtract( string first, string second ) 143 { 144 HugeInteger operand1 = HugeInteger.FromString( first ); 145 HugeInteger operand2 = 146 HugeInteger.FromString( second ); 147 HugeInteger result = new HugeInteger(); 148 149 // subtract top digit from bottom digit 150 for ( int i = 0 ; i < MAXIMUM ; i++ ) 151 { 152 // if top digit is smaller than bottom 153 // digit we need to borrow 154 if ( operand1[ i ] < operand2[ i ] ) 155 Borrow( operand1, i ); 156 157 // subtract bottom from top 158 result[ i ] = operand1[ i ] - operand2[ i ]; 159 } 160 161 return result.ToString(); 162 163 } // end method Subtract 164 165 // borrows 1 from next digit 166 private void Borrow( HugeInteger integer, int place ) 167 { 168 // if no place to borrow from, signal problem 169 if ( place >= MAXIMUM - 1 ) 170 throw new ArgumentException(); 171 Method Subtract that subtracts one HugeInteger from another Helper method Borrow used by method Subtract when 1 needs to be borrowed from the next number
12. HugeInteger.asmx.cs 172 // otherwise if next digit is zero, 173 // borrow from digit to left 174 else if ( integer[ place + 1 ] == 0 ) 175 Borrow( integer, place + 1 ); 176 177 // add ten to current place because we borrowed 178 // and subtract one from previous digit - 179 // this is digit borrowed from 180 integer[ place ] += 10 ; 181 integer[ place + 1 ] -= 1 ; 182 183 } // end method Borrow 184 185 // WebMethod that returns true if first integer is 186 // bigger than second 187 [ WebMethod ( Description = "Determines whether first " + 188 "integer is larger than the second integer." ) ] 189 public bool Bigger( string first, string second ) 190 { 191 char [] zeroes = { '0' }; 192 193 try 194 { 195 // if elimination of all zeroes from result 196 // of subtraction is an empty string, 197 // numbers are equal, so return false, 198 // otherwise return true 199 if ( Subtract( first, second ).Trim( zeroes ) == "" ) 200 return false ; 201 else 202 return true ; 203 } 204 Returns true if the first integer is bigger then the second and false otherwise
13. HugeInteger.asmx.cs 205 // if ArgumentException occurs, first number 206 // was smaller, so return false 207 catch ( ArgumentException ) 208 { 209 return false ; 210 } 211 212 } // end method Bigger 213 214 // WebMethod returns true if first integer is 215 // smaller than second 216 [ WebMethod ( Description = "Determines whether the " + 217 "first integer is smaller than the second integer." ) ] 218 public bool Smaller( string first, string second ) 219 { 220 // if second is bigger than first, then first is 221 // smaller than second 222 return Bigger( second, first ); 223 } 224 225 // WebMethod that returns true if two integers are equal 226 [ WebMethod ( Description = "Determines whether the " + 227 "first integer is equal to the second integer." ) ] 228 public bool EqualTo( string first, string second ) 229 { 230 // if either first is bigger than second, or first is 231 // smaller than second, they are not equal 232 if ( Bigger( first, second ) || 233 Smaller( first, second ) ) 234 return false ; Returns true if the first integer is smaller then the second and false otherwise Returns true if the two integers are equal and false otherwise
14. HugeInteger.asmx.cs Program Output 235 else 236 return true ; 237 } 238 239 } // end class HugeInteger 240 241 } // end namespace HugeIntegerWebService
15. 21.4 Publishing and Consuming Web Services Fig. 21.7 Design view of a Web service.
16. 21.4 Publishing and Consuming Web Services Fig. 21.8 Adding a Web service reference to a project.
17. 21.4 Publishing and Consuming Web Services Fig. 21.9 Add Web Reference dialog. Link to root directory of web server
18. 21.4 Publishing and Consuming Web Services Fig. 21.10 Web services located on localhost .
19. 21.4 Publishing and Consuming Web Services Fig. 21.11 Web reference selection and description.
20. 21.4 Publishing and Consuming Web Services Fig. 21.12 Solution Explorer after adding a Web reference to a project. Service description Proxy class Web service discovery file
21. UsingHugeIntegerService.cs 1 // Fig. 21.13: UsingHugeIntegerService.cs 2 // Using the HugeInteger Web Service. 3 4 using System; 5 using System.Drawing; 6 using System.Collections; 7 using System.ComponentModel; 8 using System.Windows.Forms; 9 using System.Web.Services.Protocols; 10 11 // allows user to perform operations on large integers 12 public class UsingHugeIntService : System.Windows.Forms.Form 13 { 14 private System.Windows.Forms.Label promptLabel; 15 private System.Windows.Forms.Label resultLabel; 16 17 private System.Windows.Forms.TextBox firstTextBox; 18 private System.Windows.Forms.TextBox secondTextBox; 19 20 private System.Windows.Forms.Button addButton; 21 private System.Windows.Forms.Button subtractButton; 22 private System.Windows.Forms.Button biggerButton; 23 private System.Windows.Forms.Button smallerButton; 24 private System.Windows.Forms.Button equalButton; 25 26 private System.ComponentModel.Container components = null ; 27 28 // declare a reference Web service 29 private localhost.HugeInteger remoteInteger; 30 31 private char [] zeroes = { '0' }; 32
22. UsingHugeIntegerService.cs 33 // default constructor 34 public UsingHugeIntService() 35 { 36 InitializeComponent(); 37 38 // instantiate remoteInteger 39 remoteInteger = new localhost.HugeInteger(); 40 } 41 42 // Visual Studio .NET generated code 43 44 [STAThread] 45 static void Main() 46 { 47 Application.Run( new UsingHugeIntService() ); 48 49 } // end Main 50 51 // checks whether two numbers user input are equal 52 protected void equalButton_Click( 53 object sender, System.EventArgs e ) 54 { 55 // make sure HugeIntegers do not exceed 100 digits 56 if ( CheckSize( firstTextBox, secondTextBox ) ) 57 return ; 58 59 // call Web-service method to determine 60 // whether integers are equal 61 if ( remoteInteger.EqualTo( 62 firstTextBox.Text, secondTextBox.Text ) ) 63 64 resultLabel.Text = 65 firstTextBox.Text.TrimStart( zeroes ) + 66 " is equal to " + 67 secondTextBox.Text.TrimStart( zeroes ); Instantiate remoteInteger to be a new HugeInteger object Call HugeInteger Web method EqualTo remotely
23. UsingHugeIntegerService.cs 68 else 69 resultLabel.Text = 70 firstTextBox.Text.TrimStart( zeroes ) + 71 " is NOT equal to " + 72 secondTextBox.Text.TrimStart( zeroes ); 73 74 } // end method equalButton_Click 75 76 // checks whether first integer input 77 // by user is smaller than second 78 protected void smallerButton_Click( 79 object sender, System.EventArgs e ) 80 { 81 // make sure HugeIntegers do not exceed 100 digits 82 if ( CheckSize( firstTextBox, secondTextBox ) ) 83 return ; 84 85 // call Web-service method to determine whether first 86 // integer is smaller than second 87 if ( remoteInteger.Smaller( 88 firstTextBox.Text, secondTextBox.Text ) ) 89 90 resultLabel.Text = 91 firstTextBox.Text.TrimStart( zeroes ) + 92 " is smaller than " + 93 secondTextBox.Text.TrimStart( zeroes ); 94 else 95 resultLabel.Text = 96 firstTextBox.Text.TrimStart( zeroes ) + 97 " is NOT smaller than " + 98 secondTextBox.Text.TrimStart( zeroes ); 99 100 } // end method smallerButton_Click 101 Call HugeInteger Web method Smaller remotely
24. UsingHugeIntegerService.cs 102 // checks whether first integer input 103 // by user is bigger than second 104 protected void biggerButton_Click( 105 object sender, System.EventArgs e ) 106 { 107 // make sure HugeIntegers do not exceed 100 digits 108 if ( CheckSize( firstTextBox, secondTextBox ) ) 109 return ; 110 111 // call Web-service method to determine whether first 112 // integer is larger than the second 113 if ( remoteInteger.Bigger( firstTextBox.Text, 114 secondTextBox.Text ) ) 115 116 resultLabel.Text = 117 firstTextBox.Text.TrimStart( zeroes ) + 118 " is larger than " + 119 secondTextBox.Text.TrimStart( zeroes ); 120 else 121 resultLabel.Text = 122 firstTextBox.Text.TrimStart( zeroes ) + 123 " is NOT larger than " + 124 secondTextBox.Text.TrimStart( zeroes ); 125 126 } // end method biggerButton_Click 127 128 // subtract second integer from first 129 protected void subtractButton_Click( 130 object sender, System.EventArgs e ) 131 { 132 // make sure HugeIntegers do not exceed 100 digits 133 if ( CheckSize( firstTextBox, secondTextBox ) ) 134 return ; 135 Call HugeInteger Web method Bigger remotely
25. UsingHugeIntegerService.cs 136 // perform subtraction 137 try 138 { 139 string result = remoteInteger.Subtract( 140 firstTextBox.Text, 141 secondTextBox.Text ).TrimStart( zeroes ); 142 143 resultLabel.Text = ( ( result == "" ) ? "0" : result ); 144 } 145 146 // if WebMethod throws an exception, then first 147 // argument was smaller than second 148 catch ( SoapException ) 149 { 150 MessageBox.Show( 151 "First argument was smaller than the second" ); 152 } 153 154 } // end method subtractButton_Click 155 156 // adds two integers input by user 157 protected void addButton_Click( 158 object sender, System.EventArgs e ) 159 { 160 // make sure HugeInteger does not exceed 100 digits 161 // and is not situation where both integers are 100 162 // digits long--result in overflow 163 if ( firstTextBox.Text.Length > 100 || 164 secondTextBox.Text.Length > 100 || 165 ( firstTextBox.Text.Length == 100 && 166 secondTextBox.Text.Length == 100 ) ) 167 { Call HugeInteger Web method Subtract remotely
26. UsingHugeIntegerService.cs 168 MessageBox.Show( "HugeIntegers must not be more " 169 + "than 100 digitsBoth integers cannot be of" 170 + " length 100: this causes an overflow" , 171 "Error" , MessageBoxButtons. OK , 172 MessageBoxIcon. Information ); 173 174 return ; 175 } 176 177 // perform addition 178 resultLabel.Text = remoteInteger.Add( firstTextBox.Text, 179 secondTextBox.Text ).TrimStart( zeroes ).ToString(); 180 181 } // end method addButton_Click 182 183 // determines whether size of integers is too big 184 private bool CheckSize( TextBox first, TextBox second ) 185 { 186 if ( first.Text.Length > 100 || second.Text.Length > 100 ) 187 { 188 MessageBox.Show( "HugeIntegers must be less than 100" 189 + " digits" , "Error" , MessageBoxButtons. OK , 190 MessageBoxIcon. Information ); 191 192 return true ; 193 } 194 195 return false ; 196 197 } // end method CheckSize 198 199 } // end class UsingHugeIntegerService Call HugeInteger Web method Add remotely
28. BlackjackService.asmx.cs 1 // Fig. 21.14: BlackjackService.asmx.cs 2 // Blackjack Web Service which manipulates a deck of cards. 3 4 using System; 5 using System.Collections; 6 using System.ComponentModel; 7 using System.Data; 8 using System.Diagnostics; 9 using System.Web; 10 using System.Web.Services; 11 12 namespace BlackjackWebService 13 { 14 [ WebService( 15 Namespace = "http://www.deitel.com/csphtp1/ch21/" , 16 Description = "A Web service that provides methods " + 17 "to manipulate a deck of cards." ) ] 18 public class BlackjackService : System.Web.Services.WebService 19 { 20 21 // Visual Studio .NET generated code 22 23 // deal new card 24 [ WebMethod( EnableSession = true , 25 Description = "Deal a new card from the deck." ) ] 26 public string DealCard() 27 { 28 string card = "2 2" ; 29 Method DealCard with WebMethod attribute which allows client applications to invoke it Property EnableSession is set to true allowing this method to maintain session information
29. BlackjackService.asmx.cs 30 // get client's deck 31 ArrayList deck = ( ArrayList ) Session[ "deck" ]; 32 card = ( string ) deck[ 0 ]; 33 deck.RemoveAt( 0 ); 34 return card; 35 36 } // end method DealCard 37 38 [ WebMethod( EnableSession = true , 39 Description = "Create and shuffle a deck of cards." ) ] 40 public void Shuffle() 41 { 42 Random randomObject = new Random(); 43 44 ArrayList deck = new ArrayList(); 45 46 // generate all possible cards 47 for ( int i = 2 ; i < 15 ; i++ ) { 48 for ( int j = 0 ; j < 4 ; j++ ) { 49 deck.Add( i + " " + j ); 50 } 51 } 52 53 // swap each card with another card randomly 54 for ( int i = 0 ; i < deck.Count; i++ ) 55 { 56 int newIndex = randomObject.Next( deck.Count ); 57 object temporary = deck[ i ]; 58 deck[ i ] = deck[ newIndex ]; 59 deck[ newIndex ] = temporary; 60 } 61 62 // add this deck to user's session state 63 Session[ "deck" ] = deck; 64 } Retrieve the deck variable from the Session object. Cast the resulting object to an ArrayList and assign local variable deck to reference it Set card to be the first object in deck (cast to a string ) Remove the first object from deck Initialize deck to a new ArrayList object Generate all possible cards and add them to deck Swap each card with a random card from the deck Assign the Session variable deck to reference ArrayList deck
30. BlackjackService.asmx.cs 65 66 // computes value of hand 67 [ WebMethod ( Description = "Compute a " + 68 "numerical value for the current hand." ) ] 69 public int CountCards( string dealt ) 70 { 71 // split string containing cards 72 char [] tab = { '' }; 73 string [] cards = dealt.Split( tab ); 74 int total = 0 , face, aceCount = 0 ; 75 76 foreach ( string drawn in cards ) 77 { 78 // get face of card 79 face = 80 Int32.Parse( drawn.Substring( 81 0 , drawn.IndexOf( " " ) ) ); 82 83 switch ( face ) 84 { 85 // if ace, increment number of aces in hand 86 case 14 : 87 aceCount++; 88 break ; 89 90 // if Jack, Queen or King, add 10 to total 91 case 11 : case 12 : case 13 : 92 total += 10 ; 93 break ; 94 Use method Split to create a string array containing the individual cards (stored in dealt and separated by tab characters) Repeat loop for each member of cards If the card is in Ace, increment aceCount but do not add to total Add 10 to total if the card is a Jack, Queen or King
31. BlackjackService.asmx.cs 95 // otherwise, add value of face 96 default : 97 total += face; 98 break ; 99 100 } // end switch 101 102 } // end foreach 103 104 // if any aces, calculate optimum total 105 if ( aceCount > 0 ) 106 { 107 // if it is possible to count one ace as 11, and rest 108 // 1 each, do so; otherwise, count all aces as 1 each 109 if ( total + 11 + aceCount - 1 <= 21 ) 110 total += 11 + aceCount - 1 ; 111 else 112 total += aceCount; 113 } 114 115 return total; 116 117 } // end method CountCards 118 119 } // end class BlackjackService 120 121 } // end namespace BlackjackWebService Otherwise, add the value of the card to total If it is possible to count one ace as 11, do so; otherwise, count each ace as 1
32. Blackjack.cs 1 // Fig. 21.15: Blackjack.cs 2 // Blackjack game that uses the Blackjack Web service. 3 4 using System; 5 using System.Drawing; 6 using System.Collections; 7 using System.ComponentModel; 8 using System.Windows.Forms; 9 using System.Data; 10 using System.Net; 11 12 // game that uses Blackjack Web Service 13 public class Blackjack : System.Windows.Forms.Form 14 { 15 private System.Windows.Forms.PictureBox pictureBox1; 16 private System.Windows.Forms.PictureBox pictureBox2; 17 private System.Windows.Forms.PictureBox pictureBox3; 18 private System.Windows.Forms.PictureBox pictureBox4; 19 private System.Windows.Forms.PictureBox pictureBox5; 20 private System.Windows.Forms.PictureBox pictureBox6; 21 private System.Windows.Forms.PictureBox pictureBox7; 22 private System.Windows.Forms.PictureBox pictureBox8; 23 private System.Windows.Forms.PictureBox pictureBox9; 24 private System.Windows.Forms.PictureBox pictureBox10; 25 private System.Windows.Forms.PictureBox pictureBox11; 26 private System.Windows.Forms.PictureBox pictureBox12; 27 private System.Windows.Forms.PictureBox pictureBox13; 28 private System.Windows.Forms.PictureBox pictureBox14; 29 private System.Windows.Forms.PictureBox pictureBox15; 30 private System.Windows.Forms.PictureBox pictureBox16; 31 private System.Windows.Forms.PictureBox pictureBox17; 32 private System.Windows.Forms.PictureBox pictureBox18; 33 private System.Windows.Forms.PictureBox pictureBox19; 34 private System.Windows.Forms.PictureBox pictureBox20; 35 private System.Windows.Forms.PictureBox pictureBox21;
33. Blackjack.cs 36 private System.Windows.Forms.PictureBox pictureBox22; 37 38 private System.Windows.Forms.Button dealButton; 39 private System.Windows.Forms.Button hitButton; 40 private System.Windows.Forms.Button stayButton; 41 42 private System.ComponentModel.Container components = null ; 43 44 private localhost.BlackjackService dealer; 45 private string dealersCards, playersCards; 46 private ArrayList cardBoxes; 47 private int playerCard, dealerCard; 48 49 // labels displaying game status, dealer and player 50 private System.Windows.Forms.Label dealerLabel; 51 private System.Windows.Forms.Label playerLabel; 52 private System.Windows.Forms.Label statusLabel; 53 54 public enum GameStatus : 55 int { PUSH , LOSE , WIN , BLACKJACK }; 56 57 public Blackjack() 58 { 59 InitializeComponent(); 60 61 dealer = new localhost.BlackjackService(); 62 63 // allow session state 64 dealer.CookieContainer = new CookieContainer(); 65 66 cardBoxes = new ArrayList(); 67 68 // put PictureBoxes into cardBoxes 69 cardBoxes.Add( pictureBox1 ); 70 cardBoxes.Add( pictureBox2 ); Instantiate a new BlackjackService object Instantiate dealer ’s CookieContainer property to allow the Web service to maintain session state information
35. Blackjack.cs 103 // deals cards to dealer while dealer's total is 104 // less than 17, then computes value of each hand 105 // and determines winner 106 protected void stayButton_Click( 107 object sender, System.EventArgs e ) 108 { 109 stayButton.Enabled = false ; 110 hitButton.Enabled = false ; 111 dealButton.Enabled = true ; 112 DealerPlay(); 113 } 114 115 // process dealers turn 116 private void DealerPlay() 117 { 118 // while value of dealer's hand is below 17, 119 // dealer must take cards 120 while ( dealer.CountCards( dealersCards ) < 17 ) 121 { 122 dealersCards += "" + dealer.DealCard(); 123 DisplayCard( dealerCard, "" ); 124 dealerCard++; 125 MessageBox.Show( "Dealer takes a card" ); 126 } 127 128 int dealersTotal = dealer.CountCards( dealersCards ); 129 int playersTotal = dealer.CountCards( playersCards ); 130 131 // if dealer busted, player wins 132 if ( dealersTotal > 21 ) 133 { 134 GameOver( GameStatus. WIN ); 135 return ; 136 } 137 Call method DealerPlay to process the dealer’s turn when the user wishes to stay While the dealer’s hand totals less then 17, the dealer must take cards If dealer went over 21, players wins
36. Blackjack.cs 138 // if dealer and player have not exceeded 21, 139 // higher score wins; equal scores is a push. 140 if ( dealersTotal > playersTotal ) 141 GameOver( GameStatus. LOSE ); 142 else if ( playersTotal > dealersTotal ) 143 GameOver( GameStatus. WIN ); 144 else 145 GameOver( GameStatus. PUSH ); 146 147 } // end method DealerPlay 148 149 // deal another card to player 150 protected void hitButton_Click( 151 object sender, System.EventArgs e ) 152 { 153 // get player another card 154 string card = dealer.DealCard(); 155 playersCards += "" + card; 156 DisplayCard( playerCard, card ); 157 playerCard++; 158 159 int total = dealer.CountCards( playersCards ); 160 161 // if player exceeds 21, house wins 162 if ( total > 21 ) 163 GameOver( GameStatus.LOSE ); 164 If neither the dealer nor the player have went over 21, higher score wins; equal scores result in a push Deal the player a card as requested If player went over 21, the house wins
37. Blackjack.cs 165 // if player has 21, they cannot take more cards 166 // the dealer plays 167 if ( total == 21 ) 168 { 169 hitButton.Enabled = false ; 170 DealerPlay(); 171 } 172 173 } // end method hitButton_Click 174 175 // deal two cards each to dealer and player 176 protected void dealButton_Click( 177 object sender, System.EventArgs e ) 178 { 179 string card; 180 181 // clear card images 182 foreach ( PictureBox cardImage in cardBoxes ) 183 cardImage.Image = null ; 184 185 // clear status from previous game 186 statusLabel.Text = "" ; 187 188 // shuffle cards 189 dealer.Shuffle(); 190 191 // deal two cards to player 192 playersCards = dealer.DealCard(); 193 DisplayCard( 11 , playersCards ); 194 card = dealer.DealCard(); 195 DisplayCard( 12 , card ); 196 playersCards += "" + card; 197 If the player has 21, the player cannot take more cards; dealer’s turn Clear the PictureBox es containing the card images Shuffle the cards by calling BlackjackService method Shuffle Deal two cards to player
38. Blackjack.cs 198 // deal two cards to dealer, only display face 199 // of first card 200 dealersCards = dealer.DealCard() ; 201 DisplayCard( 0 , dealersCards ); 202 card = dealer.DealCard(); 203 DisplayCard( 1 , "" ); 204 dealersCards += "" + card; 205 206 stayButton.Enabled = true ; 207 hitButton.Enabled = true ; 208 dealButton.Enabled = false ; 209 210 int dealersTotal = dealer.CountCards( dealersCards ); 211 int playersTotal = dealer.CountCards( playersCards ); 212 213 // if hands equal 21, it is a push 214 if ( dealersTotal == playersTotal && 215 dealersTotal == 21 ) 216 GameOver( GameStatus. PUSH ); 217 218 // if player has 21 player wins with blackjack 219 else if ( playersTotal == 21 ) 220 GameOver( GameStatus. BLACKJACK ); 221 222 // if dealer has 21, dealer wins 223 else if ( dealersTotal == 21 ) 224 GameOver( GameStatus. LOSE ); 225 226 dealerCard = 2 ; 227 playerCard = 13 ; 228 229 } // end method dealButton_Click 230 Deal two cards to dealer but only display the face of the first one If both hands equal 21, it is a push If only the player has 21, the player wins If only the dealer has 21, the dealer wins
39. Blackjack.cs 231 // displays card represented by cardValue in 232 // PictureBox with number card 233 public void DisplayCard( int card, string cardValue ) 234 { 235 // retrieve appropriate PictureBox from ArrayList 236 PictureBox displayBox = ( PictureBox ) cardBoxes[ card ]; 237 238 // if string representing card is empty, 239 // set displayBox to display back of card 240 if ( cardValue == "" ) 241 { 242 displayBox.Image = 243 Image.FromFile( "blackjack_imagescardback.png" ); 244 return ; 245 } 246 247 // retrieve face value of card from cardValue 248 int faceNumber = Int32.Parse( cardValue.Substring( 0 , 249 cardValue.IndexOf( " " ) ) ); 250 251 string face = faceNumber.ToString(); 252 253 // retrieve the suit of the card from cardValue 254 string suit = cardValue.Substring( 255 cardValue.IndexOf( " " ) + 1 ); 256 257 char suitLetter; 258 259 // determine if suit is other than clubs 260 switch ( Convert.ToInt32( suit ) ) 261 { 262 // suit is clubs 263 case 0 : 264 suitLetter = 'c' ; 265 break ; If cardValue is an empty string , display the back of the card image Retrieve face and suit of card from cardValue
40. Blackjack.cs 266 267 // suit is diamonds 268 case 1 : 269 suitLetter = 'd' ; 270 break ; 271 272 // suit is hearts 273 case 2 : 274 suitLetter = 'h' ; 275 break ; 276 277 // else suit is spades 278 default : 279 suitLetter = 's' ; 280 break ; 281 } 282 283 // set displayBox to display appropriate image 284 displayBox.Image = Image.FromFile( 285 "blackjack_images" + face + suitLetter + ".png" ); 286 287 } // end method DisplayCard 288 289 // displays all player cards and shows 290 // appropriate game status message 291 public void GameOver( GameStatus winner ) 292 { 293 char [] tab = { '' }; 294 string [] cards = dealersCards.Split( tab ); 295 296 for ( int i = 0 ; i < cards.Length; i++ ) 297 DisplayCard( i, cards[ i ] ); 298 Display all of dealer’s cards
41. Blackjack.cs 299 // push 300 if ( winner == GameStatus. PUSH ) 301 statusLabel.Text = "It's a tie!" ; 302 303 // player loses 304 else if ( winner == GameStatus. LOSE ) 305 statusLabel.Text = "You Lose Try Again!" ; 306 307 // player wins 308 else if ( winner == GameStatus. WIN ) 309 statusLabel.Text = "You Win!" ; 310 311 // player has won with blackjack 312 else 313 statusLabel.Text = "BlackJack!" ; 314 315 stayButton.Enabled = false ; 316 hitButton.Enabled = false ; 317 dealButton.Enabled = true ; 318 319 } // end method GameOver 320 321 } // end class Blackjack Display appropriate message in statusLabel
45. Reservation.asmx.cs 1 // Fig. 21.16: Reservation.asmx.cs 2 // Airline reservation Web Service. 3 4 using System; 5 using System.Data; 6 using System.Diagnostics; 7 using System.Web; 8 using System.Web.Services; 9 using System.Data.OleDb; 10 11 namespace AirlineReservation 12 { 13 // performs reservation of a seat 14 [ WebService( Namespace = "http://www.deitel.com/csphtp1/ch21/" , 15 Description = "Service that enables a user to " + 16 "reserve a seat on a plane." ) ] 17 public class Reservation : System.Web.Services.WebService 18 { 19 private System.Data.OleDb.OleDbCommand 20 oleDbSelectCommand1; 21 private System.Data.OleDb.OleDbCommand 22 oleDbInsertCommand1; 23 private System.Data.OleDb.OleDbCommand 24 oleDbUpdateCommand1; 25 private System.Data.OleDb.OleDbCommand 26 oleDbDeleteCommand1; 27 private System.Data.OleDb.OleDbConnection 28 oleDbConnection1; 29 private System.Data.OleDb.OleDbDataAdapter 30 oleDbDataAdapter1; 31 32 // Visual Studio .NET generated code 33
46. Reservation.asmx.cs 34 // checks database to determine whether 35 // matching seat is available 36 [ WebMethod ( Description = "Method to reserve seat." ) ] 37 public bool Reserve( string seatType, string classType ) 38 { 39 OleDbDataReader dataReader; 40 41 // try database connection 42 try 43 { 44 // open database connection 45 oleDbConnection1.Open(); 46 47 // set and execute SQL query 48 oleDbDataAdapter1.SelectCommand.CommandText = 49 "SELECT Number FROM Seats WHERE Type = '" + 50 seatType + "' AND Class = '" + classType + 51 "' AND Taken = '0'" ; 52 dataReader = 53 oleDbDataAdapter1.SelectCommand.ExecuteReader(); 54 55 // if there were results, seat is available 56 if ( dataReader.Read() ) 57 { 58 string seatNumber = dataReader.GetString( 0 ); 59 60 dataReader.Close(); 61 Set a query to find seats of the specified criteria. Execute query. If Read method returned true, then query returned result(s) Retrieve the first string in the row (the seat number)
47. Reservation.asmx.cs 62 // update first available seat to be taken 63 oleDbDataAdapter1.UpdateCommand.CommandText = 64 "Update Seats Set Taken = '1' WHERE Number = '" 65 + seatNumber + "'" ; 66 oleDbDataAdapter1.UpdateCommand.ExecuteNonQuery(); 67 68 return true ; 69 70 } // end if 71 dataReader.Close(); 72 } 73 catch ( OleDbException ) // if connection problem 74 { 75 return false ; 76 } 77 finally 78 { 79 oleDbConnection1.Close(); 80 } 81 82 // no seat was reserved 83 return false ; 84 85 } // end method Reserve 86 87 } // end class Reservation 88 89 } // end namespace AirlineReservation Set a query that updates the seat numbered seatNumber to be taken. Execute query.
48. 21.6 Using Web Forms and Web Services Fig. 21.17 Airline Web Service in design view.
51. TicketReservation.aspx.cs 1 // Fig. 21.19: TicketReservation.aspx.cs 2 // Making a Reservation using a Web Service. 3 4 using System; 5 using System.Collections; 6 using System.ComponentModel; 7 using System.Data; 8 using System.Drawing; 9 using System.Web; 10 using System.Web.SessionState; 11 using System.Web.UI; 12 using System.Web.UI.WebControls; 13 using System.Web.UI.HtmlControls; 14 15 namespace MakeReservation 16 { 17 // allows visitors to select seat type to reserve, and 18 // then make reservation 19 public class TicketReservation : System.Web.UI.Page 20 { 21 protected System.Web.UI.WebControls.DropDownList 22 seatList; 23 protected System.Web.UI.WebControls.DropDownList 24 classList; 25 26 protected System.Web.UI.WebControls.Button 27 reserveButton; 28 protected System.Web.UI.WebControls.Label Label1; 29 30 private localhost.Reservation agent = 31 new localhost.Reservation(); 32
52. TicketReservation.aspx.cs 33 private void Page_Load( 34 object sender, System.EventArgs e ) 35 { 36 if ( IsPostBack ) 37 { 38 seatList.Visible = false ; 39 classList.Visible = false ; 40 reserveButton.Visible = false ; 41 Label1.Visible = false ; 42 } 43 } 44 45 // Visual Studio .NET generated code 46 47 // calls Web Service to try to reserve specified seat 48 public void reserveButton_Click ( 49 object sender, System.EventArgs e ) 50 { 51 // if Web-service method returned true, signal success 52 if ( agent.Reserve( seatList.SelectedItem.Text, 53 classList.SelectedItem.Text ) ) 54 Response.Write( "Your reservation has been made." 55 + " Thank you." ); 56 57 // Web-service method returned false, so signal failure 58 else 59 Response.Write( "This seat is not available, " + 60 "please hit the back button on your browser " + 61 "and try again." ); 62 63 } // end method reserveButton_Click 64 65 } // end class TicketReservation 66 67 } // end namespace MakeReservation
55. TemperatureServer.asmx.cs 1 // Fig. 21.20: TemperatureServer.asmx.cs 2 // TemperatureServer Web Service that extracts weather 3 // information from a Web page. 4 5 using System; 6 using System.Collections; 7 using System.ComponentModel; 8 using System.Data; 9 using System.Diagnostics; 10 using System.Web; 11 using System.Web.Services; 12 using System.IO; 13 using System.Net; 14 15 namespace TemperatureWebService 16 { 17 [ WebService( Namespace = "http://www.deitel.com/csphtp1/ch21/" , 18 Description = "A Web service that provides information " + 19 "from the National Weather Service." ) ] 20 public class TemperatureServer : 21 System.Web.Services.WebService 22 { 23 // Visual Studio .NET generated code 24 25 [ WebMethod( EnableSession = true , Description = 26 "Method to read information from the weather service." ) ] 27 public void UpdateWeatherConditions() 28 { 29 // create WebClient to get access to Web page 30 WebClient myClient = new WebClient(); 31 ArrayList cityList = new ArrayList(); 32
56. TemperatureServer.asmx.cs 33 // get StreamReader for response so we can read page 34 StreamReader input = new StreamReader( 35 myClient.OpenRead( 36 "http://iwin.nws.noaa.gov/iwin/us/" + 37 "traveler.html" ) ); 38 39 string separator = "TAV12" ; 40 41 // locate first horizontal line on Web page 42 while ( !input.ReadLine().StartsWith( 43 separator ) ) ; // do nothing 44 45 // day format and night format 46 string dayFormat = 47 "CITY WEA HI/LO WEA " + 48 "HI/LO" ; 49 string nightFormat = 50 "CITY WEA LO/HI WEA " + 51 "LO/HI" ; 52 string inputLine = "" ; 53 54 // locate header that begins weather information 55 do 56 { 57 inputLine = input.ReadLine(); 58 } while ( !inputLine.Equals( dayFormat ) && 59 !inputLine.Equals( nightFormat ) ); 60 61 // get first city's data 62 inputLine = input.ReadLine(); 63
57. TemperatureServer.asmx.cs 64 while ( inputLine.Length > 28 ) 65 { 66 // create CityWeather object for city 67 CityWeather weather = new CityWeather( 68 inputLine.Substring( 0 , 16 ), 69 inputLine.Substring( 16 , 7 ), 70 inputLine.Substring( 23 , 7 ) ); 71 72 // add to List 73 cityList.Add( weather ); 74 75 // get next city's data 76 inputLine = input.ReadLine(); 77 } 78 79 // close connection to NWS server 80 input.Close(); 81 82 // add city list to user session 83 Session.Add( "cityList" , cityList ); 84 85 } // end UpdateWeatherConditions 86 87 // gets all city names 88 [ WebMethod( EnableSession = true , Description = 89 "Method to retrieve a list of cities." ) ] 90 public string [] Cities() 91 { 92 ArrayList cityList = ( ArrayList ) Session[ "cityList" ]; 93 string [] cities= new string [ cityList.Count ]; 94
58. TemperatureServer.asmx.cs 95 // retrieve names for cities 96 for ( int i = 0 ; i < cityList.Count; i++ ) 97 { 98 CityWeather weather = ( CityWeather ) cityList[ i ]; 99 100 cities[ i ] = weather.CityName; 101 } 102 103 return cities; 104 105 } // end method Cities 106 107 // gets all city descriptions 108 [ WebMethod( EnableSession = true , Description = "Method" + 109 " to retrieve weather descriptions for a " + 110 "list of cities." )] 111 public string [] Descriptions() 112 { 113 ArrayList cityList = ( ArrayList ) Session[ "cityList" ]; 114 string [] descriptions= new string [ cityList.Count ]; 115 116 // retrieve weather descriptions for all cities 117 for ( int i = 0 ; i < cityList.Count; i++ ) 118 { 119 CityWeather weather = ( CityWeather )cityList[ i ]; 120 121 descriptions[ i ] = weather.Description; 122 } 123 124 return descriptions; 125 126 } // end method Descriptions 127
59. TemperatureServer.asmx.cs 128 // obtains each city temperature 129 [ WebMethod( EnableSession = true , Description = "Method " + 130 "to retrieve the temperature for a list of cities." ) ] 131 public string [] Temperatures() 132 { 133 ArrayList cityList = ( ArrayList ) Session[ "cityList" ]; 134 string [] temperatures= new string [ cityList.Count ]; 135 136 // retrieve temperatures for all cities 137 for ( int i = 0 ; i < cityList.Count; i++ ) 138 { 139 CityWeather weather = ( CityWeather )cityList[ i ]; 140 temperatures[ i ] = weather.Temperature; 141 } 142 143 return temperatures; 144 145 } // end method Temperatures 146 147 } // end class TemperatureServer 148 149 } // end namespace TemperatureWebService
60. CityWeather.cs 1 // Fig. 21.21: CityWeather.cs 2 // Class representing the weather information for one city. 3 4 using System; 5 6 namespace TemperatureWebService 7 { 8 public class CityWeather 9 { 10 private string cityName; 11 private string temperature; 12 private string description; 13 14 public CityWeather( 15 string city, string information, string degrees ) 16 { 17 cityName = city; 18 description = information; 19 temperature = degrees; 20 } 21 22 // city name 23 public string CityName 24 { 25 get 26 { 27 return cityName; 28 } 29 } 30
61. CityWeather.cs 31 // city temperature 32 public string Temperature 33 { 34 get 35 { 36 return temperature; 37 } 38 } 39 40 // forecast description 41 public string Description 42 { 43 get 44 { 45 return description; 46 } 47 } 48 49 } // end class CityWeather 50 } // end namespace TemperatureWebService
62. Client.cs 1 // Fig. 21.22: Client.cs 2 // Class that displays weather information that it receives 3 // from a Web service. 4 5 using System; 6 using System.Drawing; 7 using System.Collections; 8 using System.ComponentModel; 9 using System.Windows.Forms; 10 using System.Net; 11 12 namespace TemperatureClient 13 { 14 public class Client : System.Windows.Forms.Form 15 { 16 private System.Windows.Forms.Label label1; 17 private System.Windows.Forms.Label label2; 18 private System.Windows.Forms.Label label3; 19 private System.Windows.Forms.Label label4; 20 private System.Windows.Forms.Label label5; 21 private System.Windows.Forms.Label label6; 22 private System.Windows.Forms.Label label7; 23 private System.Windows.Forms.Label label8; 24 private System.Windows.Forms.Label label9; 25 private System.Windows.Forms.Label label10; 26 private System.Windows.Forms.Label label11; 27 private System.Windows.Forms.Label label12; 28 private System.Windows.Forms.Label label13; 29 private System.Windows.Forms.Label label14; 30 private System.Windows.Forms.Label label15; 31 private System.Windows.Forms.Label label16; 32 private System.Windows.Forms.Label label17; 33 private System.Windows.Forms.Label label18; 34 private System.Windows.Forms.Label label19; 35 private System.Windows.Forms.Label label20;
70. Equation.cs 68 69 set 70 { 71 } 72 } 73 74 // left operand get and set property 75 public int Left 76 { 77 get 78 { 79 return left; 80 } 81 82 set 83 { 84 left = value ; 85 } 86 } 87 88 // right operand get and set property 89 public int Right 90 { 91 get 92 { 93 return right; 94 } 95 96 set 97 { 98 right = value ; 99 } 100 } 101
71. Equation.cs 102 // get and set property of result of applying 103 // operation to left and right operands 104 public int Result 105 { 106 get 107 { 108 return result; 109 } 110 111 set 112 { 113 result = value ; 114 } 115 } 116 117 // get and set property for operation 118 public string Operation 119 { 120 get 121 { 122 return operation; 123 } 124 125 set 126 { 127 operation = value ; 128 } 129 } 130 131 } // end class Equation
72. Generator.asmx.cs 1 // Fig. 21.24: Generator.asmx.cs 2 // Web Service to generate random equations based on a 3 // specified operation and difficulty level. 4 5 using System; 6 using System.Collections; 7 using System.ComponentModel; 8 using System.Data; 9 using System.Diagnostics; 10 using System.Web; 11 using System.Web.Services; 12 13 namespace EquationGenerator 14 { 15 [ WebService( Namespace = "http://www.deitel.com/csphtp1/ch21" , 16 Description = "A Web service that generates questions " + 17 "based on the specified mathematical operation and " + 18 "level of difficulty chosen." ) ] 19 public class Generator : System.Web.Services.WebService 20 { 21 22 // Visual Studio .NET generated code 23 24 [ WebMethod ( Description = 25 "Method that generates a random equation." ) ] 26 public Equation GenerateEquation( string operation, 27 int level ) 28 { 29 // find maximum and minimum number to be used 30 int maximum = ( int ) Math.Pow( 10 , level ), 31 minimum = ( int ) Math.Pow( 10 , level - 1 ); 32
73. Generator.asmx.cs 33 Random random = new Random(); 34 35 // create equation consisting of two random numbers 36 // between minimum and maximum parameters 37 Equation equation = new Equation( 38 random.Next( minimum, maximum ), 39 random.Next( minimum, maximum ), operation ); 40 41 return equation; 42 43 } // end method GenerateEquation 44 45 } // end class Generator 46 47 } // end namespace EquationGenerator
74. 21.8 User Defined Types in Web Services Fig. 21.25 Returning an object from a Web-service method. (Part 1) Create a subtraction exercise Make exercise of user skill level 2
75. 21.8 User Defined Types in Web Services Fig. 21.25 Returning an object from a Web-service method. (Part 2)