The document provides an overview of a JavaScript crash course, including topics that will be covered such as core language syntax, strings, regular expressions, functions, and objects. It also advertises customized Java EE training courses developed and taught by Marty Hall on various technologies including servlets, JSP, JSF, Struts, Ajax, GWT, Spring and more. The training is available both at public venues and customized on-site versions at organizations.
The document discusses different approaches to using JavaScript libraries, including plug-and-play widgets, libraries that require some coding, and writing raw JavaScript from scratch. It then examines popular open-source JavaScript libraries like Prototype, jQuery, Yahoo UI, and Dojo, comparing their features, functionality, and widgets. The ideal library should have a robust core feature set along with user interface widgets, active development and support, and good documentation.
This document provides an introduction and overview of JavaScript, including data types, variables, operators, control structures, the Document Object Model (DOM), and debugging techniques. It discusses JavaScript syntax, functions, scopes, arrays, and common language features. It also covers how to include JavaScript in HTML documents, both inline and via external files. The DOM is explained as a way for JavaScript to programmatically access and modify elements in an HTML document.
The document discusses various security vulnerabilities in Ajax applications including CSRF, login CSRF, JavaScript hijacking, XSS, and history stealing. It provides examples of how these attacks can be carried out and emphasizes the importance of validating and sanitizing user input to prevent scripts from being executed maliciously on a site. The document also recommends techniques for protecting against these attacks, such as using authentication tokens and disabling client-side script evaluation for untrusted sources.
This document discusses the Model-View-Controller (MVC) architecture and how to implement it using servlets and JSP. It begins with an overview of MVC and the benefits of combining servlets and JSP. It then covers implementing MVC with RequestDispatcher to forward requests from servlets to JSP pages, and how to handle relative URLs and share data between the servlet and JSP using request, session, and application scopes. It provides examples of using beans to represent data and accessing bean properties in JSP.
This document is a presentation about JavaScript that covers what JavaScript is, where it came from, and what it can do. It introduces JavaScript as a scripting language that is easy to use and learn and runs in web browsers. The presentation explains that JavaScript is unrelated to Java but borrows some naming conventions. It provides overviews of JavaScript basics like variables, operators, and functions, as well as more advanced topics like objects, events, and DOM manipulation.
This document is a lecture on JavaScript that discusses core concepts like statements, objects, arrays, functions, events, validation, frameworks, libraries, debugging tools, and compression tools. It provides an overview and references for further reading on topics like the JavaScript language, DOM manipulation, events, validation with regular expressions, and popular JavaScript frameworks and libraries.
The document discusses different approaches to using JavaScript libraries, including plug-and-play widgets, libraries that require some coding, and writing raw JavaScript from scratch. It then examines popular open-source JavaScript libraries like Prototype, jQuery, Yahoo UI, and Dojo, comparing their features, functionality, and widgets. The ideal library should have a robust core feature set along with user interface widgets, active development and support, and good documentation.
This document provides an introduction and overview of JavaScript, including data types, variables, operators, control structures, the Document Object Model (DOM), and debugging techniques. It discusses JavaScript syntax, functions, scopes, arrays, and common language features. It also covers how to include JavaScript in HTML documents, both inline and via external files. The DOM is explained as a way for JavaScript to programmatically access and modify elements in an HTML document.
The document discusses various security vulnerabilities in Ajax applications including CSRF, login CSRF, JavaScript hijacking, XSS, and history stealing. It provides examples of how these attacks can be carried out and emphasizes the importance of validating and sanitizing user input to prevent scripts from being executed maliciously on a site. The document also recommends techniques for protecting against these attacks, such as using authentication tokens and disabling client-side script evaluation for untrusted sources.
This document discusses the Model-View-Controller (MVC) architecture and how to implement it using servlets and JSP. It begins with an overview of MVC and the benefits of combining servlets and JSP. It then covers implementing MVC with RequestDispatcher to forward requests from servlets to JSP pages, and how to handle relative URLs and share data between the servlet and JSP using request, session, and application scopes. It provides examples of using beans to represent data and accessing bean properties in JSP.
This document is a presentation about JavaScript that covers what JavaScript is, where it came from, and what it can do. It introduces JavaScript as a scripting language that is easy to use and learn and runs in web browsers. The presentation explains that JavaScript is unrelated to Java but borrows some naming conventions. It provides overviews of JavaScript basics like variables, operators, and functions, as well as more advanced topics like objects, events, and DOM manipulation.
This document is a lecture on JavaScript that discusses core concepts like statements, objects, arrays, functions, events, validation, frameworks, libraries, debugging tools, and compression tools. It provides an overview and references for further reading on topics like the JavaScript language, DOM manipulation, events, validation with regular expressions, and popular JavaScript frameworks and libraries.
There's plenty of material (documentation, blogs, books) out there that'll help
you write a site using Django... but then what? You've still got to test,
deploy, monitor, and tune the site; failure at deployment time means all your
beautiful code is for naught.
This document discusses best practices for organizing code and setting up architecture for larger frontend projects with multiple developers. It covers choosing technology stacks, code organization, coding guidelines, responsive design approaches, performance optimization, and workflows.
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...Matt Raible
JavaScript MVC Frameworks are all the rage these days. They’ve taken the web development world by storm. This session explores the various features of the three hottest JavaScript MVC frameworks: AngularJS, Ember.js and React.js. It also compares client-side templating vs. server-side templating and how well each framework supports Isomorphic JavaScript (code that can run both client-side and server-side). Finally, it ranks each framework on 10 different criteria using Yevgeniy Brikman’s framework scorecard.
Video on InfoQ: https://www.infoq.com/presentations/comparing-angular-ember-react
This document provides an overview of using WordPress and AJAX. It discusses loading scripts and styles properly, using JavaScript localization to capture dynamic PHP content, page detection techniques, the wp_ajax action for handling AJAX requests, and the WP_Ajax_Response class for returning XML responses from AJAX callbacks. It also provides an example of building an AJAX registration form plugin with classes for handling the form, scripts, and styles.
The document introduces Ruby on Rails and provides an overview of its features and benefits. It summarizes the speaker's experience with web development over time, introduces MVC and ORM concepts, and demonstrates Rails through a live coding example. Key advantages of Rails highlighted include its convention over configuration approach, use of Ruby as a dynamic scripting language, and ability to rapidly develop database-backed web applications.
Server Side JavaScript on the JVM - Project Avatar - QCon London March 2014David Delabassee
The document discusses Project Avatar, which aims to run server-side JavaScript (Node.js) applications on the Java Virtual Machine (JVM). It introduces Avatar.js, which provides 95% compatibility with Node.js modules and libraries while allowing access to Java frameworks and libraries. Project Avatar builds on this with additional features like integrated messaging, database access via a modeling framework, and support for REST, WebSocket and server-sent events. It allows building event-driven JavaScript services that leverage Java EE capabilities on the JVM.
Phobos is a lightweight JavaScript web application framework that allows all application logic to be written in JavaScript. It runs on the Java platform and supports full-featured IDE development. Phobos integrates JavaScript and Java libraries and allows JavaScript code to be run across client, server, and database tiers for a unified programming model.
The document discusses developing your own PHP framework and provides tips on when it makes sense. It summarizes common issues with existing frameworks like CakePHP and Zend Framework. It also outlines how to take a broader view when designing a framework, including using a model-view-controller push or pull approach and implementing hierarchical model-view-controller. The document provides examples of how to structure controllers for a master, group, and element to implement this pattern.
I've written a lot of Django code in my career, some slow, and some fast; my aim is to share a few of the techniques you can use to go from 300ms response times to 30ms. We'll travel up and down the stack, looking to identify, monitor and solve performance issues, while dodging those which just aren't worth solving.
Full video is available at: https://skillsmatter.com/skillscasts/6628-django-performance-recipes
This document discusses using a proxy server to render single page applications for search engines and legacy browsers. It introduces the concept of a server-side backbone that runs the same backbone application code on both the client and server. This allows rendering the initial HTML on the server to avoid problems with robots and speeds up loading for users. It also discusses some of the challenges in implementing this approach like emulating the DOM and browser APIs on the server. Overall it presents server-side rendering as a way to solve crawlability and legacy browser support problems for single page apps.
The document provides information about JavaScript including:
- JavaScript is a scripting language that adds interactivity to HTML pages and is used for client-side scripting.
- It can dynamically update HTML content, react to user events, validate form data, and detect the visitor's browser.
- JavaScript code can be embedded directly in HTML pages or placed in external .js files and included using script tags.
- The document discusses JavaScript variables, data types, operators, functions, and common uses of JavaScript in web pages.
Tools and Tips for Moodle Developers - #mootus16Dan Poltawski
This document provides tools and tips for Moodle developers. It discusses various debugging techniques for PHP and JavaScript code using print statements and log functions. It also covers profiling performance, running automated tests with PHPUnit and Behat, linting code quality, and testing email functionality and accessibility. The Moodle Development Kit (MDK) and moodle-plugin-ci project are introduced to help integrate development tasks and testing into continuous integration workflows.
HTML 5 is the latest version of the HTML standard. It includes several new elements and features to improve structure and behavior. Some key changes include new semantic elements like <article>, <aside>, <header>, and <footer>; built-in support for audio and video; the <canvas> element for drawing graphics; and forms with new input types. HTML 5 aims to simplify HTML and separate structure and presentation, making code cleaner and pages more accessible. It is developed jointly by the WHATWG and W3C organizations.
Progressive Downloads and Rendering - take #2Stoyan Stefanov
HighLoad++ presentation including:
- single stream data URIs and MHTML
- in CSS and <img> tags
- lazy evaluation, lazy JS and lazy HTML experiment
- browser chrome search preload
- Amazon's post-loaded content
- Google instant's chunks
This document provides an overview of server-side technologies PHP. It begins with an introduction to PHP that describes what PHP is, what PHP files are, and what PHP can do. It then covers PHP features, syntax, variables, operators, conditions and loops, functions, string manipulation, and arrays. The document also includes sample code examples for each topic. It aims to teach the fundamentals of PHP for developing dynamic web applications.
The document discusses the Django web application framework. It describes Django as a high-level Python framework that encourages rapid development and clean design. It outlines Django's architecture, which follows an MVT pattern with models, views, templates, and a URL dispatcher. It also discusses Django's modules, like forms, administration, caching, and signals. An example project is provided to demonstrate starting a project, adding an app with a model, and exploring the admin interface.
This document provides an introduction and overview of PHP MVC frameworks and tutorials. It first discusses why MVC architecture is used and what MVC stands for. It then demonstrates how to build a simple PHP MVC application with basic View, Model, and Controller classes. Finally, it mentions that there are many PHP MVC frameworks to choose from and lists some of the most popular options.
Why and when you need end-to-end tests, a spooky story with a 15 years software beast, and how to develop concise, maintainable functional tests using Groovy, Spock and Geb.
This is an introductory talk we delivered at Universidad Europea de Madrid for the International Week of Technological Innovation. We introduce concepts such as accessibility and performance in modern web development, current browser market state and evolution, and some approaches to introduce CSS3.
This document provides instructions for installing MapServer and PHP MapScript on Linux. It describes downloading and compiling several required libraries - GD, PROJ.4, GEOS, GDAL, CURL and PostGIS. It then provides steps to compile and configure MapServer without installing, and to set up PHP to support MapScript by copying files and editing configurations. Finally it describes testing the MapScript installation with info.phtml and a demo PHP application.
Ritzhaupt was teaching an online computer programming course and was facing challenges with increasing student confusion and questions. He designed the course to have students develop an ePortfolio demonstrating their skills over the semester. However, as the course reached the more challenging web programming module, students were struggling significantly more than expected. Ritzhaupt would need to address this rising difficulty to prevent failing the course and damaging his career.
There's plenty of material (documentation, blogs, books) out there that'll help
you write a site using Django... but then what? You've still got to test,
deploy, monitor, and tune the site; failure at deployment time means all your
beautiful code is for naught.
This document discusses best practices for organizing code and setting up architecture for larger frontend projects with multiple developers. It covers choosing technology stacks, code organization, coding guidelines, responsive design approaches, performance optimization, and workflows.
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...Matt Raible
JavaScript MVC Frameworks are all the rage these days. They’ve taken the web development world by storm. This session explores the various features of the three hottest JavaScript MVC frameworks: AngularJS, Ember.js and React.js. It also compares client-side templating vs. server-side templating and how well each framework supports Isomorphic JavaScript (code that can run both client-side and server-side). Finally, it ranks each framework on 10 different criteria using Yevgeniy Brikman’s framework scorecard.
Video on InfoQ: https://www.infoq.com/presentations/comparing-angular-ember-react
This document provides an overview of using WordPress and AJAX. It discusses loading scripts and styles properly, using JavaScript localization to capture dynamic PHP content, page detection techniques, the wp_ajax action for handling AJAX requests, and the WP_Ajax_Response class for returning XML responses from AJAX callbacks. It also provides an example of building an AJAX registration form plugin with classes for handling the form, scripts, and styles.
The document introduces Ruby on Rails and provides an overview of its features and benefits. It summarizes the speaker's experience with web development over time, introduces MVC and ORM concepts, and demonstrates Rails through a live coding example. Key advantages of Rails highlighted include its convention over configuration approach, use of Ruby as a dynamic scripting language, and ability to rapidly develop database-backed web applications.
Server Side JavaScript on the JVM - Project Avatar - QCon London March 2014David Delabassee
The document discusses Project Avatar, which aims to run server-side JavaScript (Node.js) applications on the Java Virtual Machine (JVM). It introduces Avatar.js, which provides 95% compatibility with Node.js modules and libraries while allowing access to Java frameworks and libraries. Project Avatar builds on this with additional features like integrated messaging, database access via a modeling framework, and support for REST, WebSocket and server-sent events. It allows building event-driven JavaScript services that leverage Java EE capabilities on the JVM.
Phobos is a lightweight JavaScript web application framework that allows all application logic to be written in JavaScript. It runs on the Java platform and supports full-featured IDE development. Phobos integrates JavaScript and Java libraries and allows JavaScript code to be run across client, server, and database tiers for a unified programming model.
The document discusses developing your own PHP framework and provides tips on when it makes sense. It summarizes common issues with existing frameworks like CakePHP and Zend Framework. It also outlines how to take a broader view when designing a framework, including using a model-view-controller push or pull approach and implementing hierarchical model-view-controller. The document provides examples of how to structure controllers for a master, group, and element to implement this pattern.
I've written a lot of Django code in my career, some slow, and some fast; my aim is to share a few of the techniques you can use to go from 300ms response times to 30ms. We'll travel up and down the stack, looking to identify, monitor and solve performance issues, while dodging those which just aren't worth solving.
Full video is available at: https://skillsmatter.com/skillscasts/6628-django-performance-recipes
This document discusses using a proxy server to render single page applications for search engines and legacy browsers. It introduces the concept of a server-side backbone that runs the same backbone application code on both the client and server. This allows rendering the initial HTML on the server to avoid problems with robots and speeds up loading for users. It also discusses some of the challenges in implementing this approach like emulating the DOM and browser APIs on the server. Overall it presents server-side rendering as a way to solve crawlability and legacy browser support problems for single page apps.
The document provides information about JavaScript including:
- JavaScript is a scripting language that adds interactivity to HTML pages and is used for client-side scripting.
- It can dynamically update HTML content, react to user events, validate form data, and detect the visitor's browser.
- JavaScript code can be embedded directly in HTML pages or placed in external .js files and included using script tags.
- The document discusses JavaScript variables, data types, operators, functions, and common uses of JavaScript in web pages.
Tools and Tips for Moodle Developers - #mootus16Dan Poltawski
This document provides tools and tips for Moodle developers. It discusses various debugging techniques for PHP and JavaScript code using print statements and log functions. It also covers profiling performance, running automated tests with PHPUnit and Behat, linting code quality, and testing email functionality and accessibility. The Moodle Development Kit (MDK) and moodle-plugin-ci project are introduced to help integrate development tasks and testing into continuous integration workflows.
HTML 5 is the latest version of the HTML standard. It includes several new elements and features to improve structure and behavior. Some key changes include new semantic elements like <article>, <aside>, <header>, and <footer>; built-in support for audio and video; the <canvas> element for drawing graphics; and forms with new input types. HTML 5 aims to simplify HTML and separate structure and presentation, making code cleaner and pages more accessible. It is developed jointly by the WHATWG and W3C organizations.
Progressive Downloads and Rendering - take #2Stoyan Stefanov
HighLoad++ presentation including:
- single stream data URIs and MHTML
- in CSS and <img> tags
- lazy evaluation, lazy JS and lazy HTML experiment
- browser chrome search preload
- Amazon's post-loaded content
- Google instant's chunks
This document provides an overview of server-side technologies PHP. It begins with an introduction to PHP that describes what PHP is, what PHP files are, and what PHP can do. It then covers PHP features, syntax, variables, operators, conditions and loops, functions, string manipulation, and arrays. The document also includes sample code examples for each topic. It aims to teach the fundamentals of PHP for developing dynamic web applications.
The document discusses the Django web application framework. It describes Django as a high-level Python framework that encourages rapid development and clean design. It outlines Django's architecture, which follows an MVT pattern with models, views, templates, and a URL dispatcher. It also discusses Django's modules, like forms, administration, caching, and signals. An example project is provided to demonstrate starting a project, adding an app with a model, and exploring the admin interface.
This document provides an introduction and overview of PHP MVC frameworks and tutorials. It first discusses why MVC architecture is used and what MVC stands for. It then demonstrates how to build a simple PHP MVC application with basic View, Model, and Controller classes. Finally, it mentions that there are many PHP MVC frameworks to choose from and lists some of the most popular options.
Why and when you need end-to-end tests, a spooky story with a 15 years software beast, and how to develop concise, maintainable functional tests using Groovy, Spock and Geb.
This is an introductory talk we delivered at Universidad Europea de Madrid for the International Week of Technological Innovation. We introduce concepts such as accessibility and performance in modern web development, current browser market state and evolution, and some approaches to introduce CSS3.
This document provides instructions for installing MapServer and PHP MapScript on Linux. It describes downloading and compiling several required libraries - GD, PROJ.4, GEOS, GDAL, CURL and PostGIS. It then provides steps to compile and configure MapServer without installing, and to set up PHP to support MapScript by copying files and editing configurations. Finally it describes testing the MapScript installation with info.phtml and a demo PHP application.
Ritzhaupt was teaching an online computer programming course and was facing challenges with increasing student confusion and questions. He designed the course to have students develop an ePortfolio demonstrating their skills over the semester. However, as the course reached the more challenging web programming module, students were struggling significantly more than expected. Ritzhaupt would need to address this rising difficulty to prevent failing the course and damaging his career.
This document provides instructions on how to disassemble and clean the carburetor of a gas-powered push mower. It outlines 3 key steps: 1) removing the carburetor bowl by unscrewing it and removing any debris, 2) removing the floats and pivot bar, and 3) removing the mixing cover by unscrewing it and sliding it off. Warnings are provided to wear gloves when handling gasoline and dispose of it properly due to its flammable nature. Reassembly is described as the reverse of the disassembly steps.
This document provides instructions for installing XAMPP server on Fedora Core 5 Linux. It describes downloading and installing VMware Server to create a virtual machine for Fedora Core 5. It then outlines installing Fedora Core 5 in the virtual machine, including partitioning disks and setting the root password. Additional steps include installing a minimal desktop environment, downloading a package from FreshRPMs to enable additional repositories, and preparing to install XAMPP server for local web development and testing. The goal is to have a fully functional and secure test web server environment using XAMPP on Fedora Core 5 in a virtual machine.
This document provides an overview of a full-day tutorial on HDF5 and netCDF-4. The tutorial will cover the HDF5 and netCDF-4 data models, programming interfaces, and optimization features. It will demonstrate how to use HDF5 for efficient data storage and I/O, including techniques like chunking, compression and parallel I/O. The tutorial will also show how netCDF-4 implements the netCDF data model using the HDF5 file format to provide scalable I/O. The goal is to equip participants with the skills needed to effectively use HDF5 and netCDF-4 on high-performance computing clusters.
This document outlines a tutorial agenda that is split into two parts. Part 1 covers getting started with RESTful applications, standard responses, response generators, and exception handlers. Part 2 covers request handlers, jQuery and jQueryUI, and a pair-programming challenge, as well as discussing more advanced topics and answering questions.
The document discusses advanced features of the AjaxTags Library including autocomplete textboxes that populate associated values in other textboxes. It provides an example of an autocomplete textbox that populates a secondary textbox with a linked Spanish word when an English animal is selected. The server-side code returns an XML list with names and values to map selections to the secondary field. Training courses are also advertised on Ajax, Java EE and other technologies.
The document summarizes a JavaScript crash course presentation. It introduces core JavaScript language syntax topics like variables, operators, conditionals, loops, functions and objects. It also discusses embedding JavaScript in HTML using <script> tags and loading external JavaScript files. The document provides references to online JavaScript tutorials and specifications as well as books on JavaScript best practices. It recommends the Firebug plugin for interactive testing of JavaScript in Firefox.
The document provides an overview of the Prototype JavaScript framework and its support for Ajax functionality. It discusses topics like installing Prototype, the Ajax.Request, Ajax.Updater, and Ajax.PeriodicalUpdater objects, handling JSON data, and comparing Prototype's Ajax support to other libraries like jQuery, Dojo and Ext JS. It also provides examples of using Prototype for Ajax requests and updating HTML elements.
The document provides an overview of the Prototype JavaScript framework and its support for Ajax functionality. It discusses topics like installing Prototype, the Ajax.Request, Ajax.Updater, and Ajax.PeriodicalUpdater objects, handling JSON data, and comparing Prototype's Ajax support to other libraries like jQuery, Dojo and Ext JS. It also provides examples of using Prototype for Ajax requests and updating HTML elements.
The document provides an overview of servlet basics, including:
- The main job of a servlet is to read data from the client request, generate a response, and send data back to the client.
- A simple "Hello World" servlet is presented that generates plain text. Another example generates HTML output.
- Helper classes can be used to avoid duplicating code across servlets.
- Servlets are given URLs either through the @WebServlet annotation or by mapping in the web.xml file.
- The servlet life cycle and debugging strategies are briefly discussed. Advanced topics like the service method are also covered.
The document discusses using jQuery for Ajax support. It introduces the $.ajax function for making Ajax requests with jQuery and describes some of its basic syntax and options. Examples are provided to demonstrate using $.ajax to make an Ajax request and update a web page by retrieving data from a JSP page.
Microsoft PowerPoint - <b>jQuery</b>-1-Ajax.pptxtutorialsruby
1. The document discusses jQuery, an open-source JavaScript library for DOM manipulation and Ajax. It provides an overview of jQuery's capabilities including DOM manipulation, events, effects and animations.
2. The document covers how to install jQuery and its browser compatibility. It also summarizes jQuery's selector syntax for selecting DOM elements.
3. An example is given demonstrating how to randomly change the background colors of HTML headings using jQuery by adding and removing CSS classes on click events.
The document discusses using jQuery for Ajax support. It introduces the $.ajax function for making Ajax requests with jQuery and describes some of its basic syntax and options. Examples are provided to demonstrate using $.ajax to make an Ajax request and update the page based on the response.
The document discusses using jQuery for Ajax support. It introduces the $.ajax function for making Ajax requests with jQuery and describes some of its basic syntax and options. Examples are provided to demonstrate using $.ajax to make an Ajax request and update the page based on the response.
The document summarizes jQuery UI tabs that can be used to create static tabbed panels on a webpage. Key points include:
1) The tabs() function can be called on a div container to turn it into a tabbed panel with static content.
2) HTML includes a ul list of tabs links and divs for each tab's content.
3) Clicking tabs changes the visible content div using anchor hrefs that match the div IDs.
The document provides an overview and examples of using the jQuery UI library to add rich interfaces to web applications. It discusses widgets like tabbed panels, accordion panels, and date pickers. It covers downloading and installing jQuery UI, and provides code examples for creating static and dynamic tabbed panels, accordion panels, and using the date picker widget.
Microsoft PowerPoint - <b>jQuery</b>-3-UI.pptxtutorialsruby
The document provides an overview and examples of using the jQuery UI library to add rich interfaces to web applications. It discusses widgets like tabbed panels, accordion panels, and date pickers. It covers downloading and installing jQuery UI, and provides code examples for creating static and dynamic tabbed panels and accordion panels using jQuery UI.
The document provides an overview and examples of using the jQuery UI library to add rich interfaces to web applications. It discusses widgets like tabbed panels, accordion panels, and date pickers. It covers downloading and installing jQuery UI, and provides code examples for creating static and dynamic tabbed panels and accordion panels using jQuery UI.
This document discusses Ajax and provides code examples for implementing basic Ajax functionality. It begins with an overview of Ajax and its motivation, then describes the basic Ajax process including defining a request object in JavaScript, initiating a request, and handling the response. It provides JavaScript and HTML code examples to send a GET request, handle the response, and display returned data.
This document provides an overview of servlets and JavaServer Pages (JSP) technology. It discusses what servlets and JSP are, how they are used to dynamically generate web pages, and their advantages over traditional CGI. It also provides information on installing Tomcat and Eclipse, deploying and running web applications from Eclipse, and creating new web applications in Eclipse.
This document discusses Domain Specific Languages (DSLs) and their use in JavaScript. It begins by defining DSLs and providing examples of domain-specific lexicons. It then covers internal and external DSLs, and examples of JavaScript DSLs like JSSpec (for testing) and ActiveRecord.js (for object-relational mapping). The document concludes by discussing lessons learned from building DSLs in JavaScript, such as its lack of namespaces being a challenge but prototypal inheritance and object literals providing opportunities.
The document provides an overview of creating and testing Google Web Toolkit (GWT) projects in Eclipse. It describes generating a new GWT web application project in Eclipse, editing the auto-generated HTML and Java files, and testing the project in hosted mode within Eclipse and local web mode in a browser. It also briefly discusses deploying the project to a web server.
The document provides an overview of creating and testing Google Web Toolkit (GWT) projects in Eclipse. It describes generating a new GWT web application project in Eclipse, editing the auto-generated HTML and Java files, and testing the project in hosted mode within Eclipse and local web mode in a browser. It also briefly outlines the general development and deployment process for GWT projects.
The document discusses different ways to invoke Java code from JSP pages, including JSP expressions, scriptlets, and declarations. It provides examples of each and explains how they correspond to code in the generated servlet class. Expressions output a value, scriptlets can contain multiple statements, and declarations define fields and methods in the servlet class. The document also compares using JSP pages versus servlets for similar tasks and recommends limiting Java code in JSP pages.
This document discusses the JavaServer Pages (JSP) 2.0 Expression Language (EL) and how it simplifies accessing Java code from JSP pages. It motivates the use of EL by explaining how it provides a more concise syntax for accessing scoped variables, bean properties, and collection elements compared to traditional JSP scripting elements. It also describes how to set up a JSP 2.0 compliant web application and activate the EL. The document provides examples of using the EL to access scoped variables and bean properties in JSP pages.
This document provides a help and tutorial for TopStyle Pro version 3.11. It covers getting started with TopStyle, editing style sheets and HTML/XHTML, working with colors, previews, validation, site management, reports, mappings, customization, and third-party integration. It also includes appendices on CSS basics and tips, TopStyle tips and tricks, style sheet resources, keyboard shortcuts, and regular expressions.
TopStyle Help & <b>Tutorial</b>tutorialsruby
This document provides a table of contents for the TopStyle Pro Help & Tutorial, which teaches how to use the TopStyle software for editing style sheets and HTML/XHTML documents. It lists over 50 sections that provide explanations and instructions for features like creating and opening files, editing styles, working with colors, previews, validation, site management, reports and customizing the software. The document was created by Giampaolo Bellavite from the online help provided with TopStyle version 3.11.
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>tutorialsruby
This document provides the course outline for IMD 210 Fundamentals of Scripting Languages at The Art Institute of Atlanta during the Spring 2005 quarter. The course focuses on integrating programming concepts with interface design using scripting languages like JavaScript and CSS. It will cover topics like DOM, CSS layout, JavaScript variables, conditionals, and events. Students will complete 4 assignments including redesigning existing websites, and there will be weekly quizzes, a midterm, and final exam. The course is worth 4 credits and meets once a week for class and lab.
This document provides the course outline for IMD 210 Fundamentals of Scripting Languages at The Art Institute of Atlanta during the Spring 2005 quarter. The course focuses on integrating programming concepts with interface design using scripting languages like JavaScript and CSS. It will cover topics like DOM, CSS layout, JavaScript variables, conditionals, and events. Students will complete 4 assignments including redesigning existing websites, and there will be weekly quizzes, a midterm, and final exam. The course is worth 4 credits and meets once a week for class and lab.
The group aims to bridge gaps between peer-to-peer database architectures and scaling multimedia information retrieval. They develop a probabilistic multimedia database system with abstraction layers for applications and researchers. They also research challenges of peer-to-peer networks for distributed data management. Both lines are supported by the MonetDB platform to exploit custom hardware and adaptive query optimization. The goal is a modular solution linking theoretical optimal solutions to application demands under resource limitations.
Standardization and Knowledge Transfer – INS0tutorialsruby
The group aims to bridge gaps between peer-to-peer database architectures and scaling multimedia information retrieval. They develop a probabilistic multimedia database system with abstraction layers and a flexible model. They also research challenges of peer-to-peer networks for distributed data management. Both lines are supported by the MonetDB platform to exploit custom hardware and adaptive query optimization. The goal is a modular solution linking theoretical optimal solutions to application demands under resource limitations.
This document provides an introduction to converting HTML documents to XHTML, including the basic syntax changes needed like making all tags lowercase and closing all tags. It provides examples of correct XHTML markup for different tags. It also explains the new DOCTYPE declaration and shows a sample well-formed XHTML document incorporating all the discussed changes. Resources for learning more about XHTML are listed at the end.
This document provides an introduction to converting HTML documents to XHTML, including the basic syntax changes needed like making all tags lowercase and closing all tags. It provides examples of correct XHTML markup for different tags. It also explains the new DOCTYPE declaration and shows a sample well-formed XHTML document incorporating all the discussed changes. Resources for learning more about XHTML are listed at the end.
XHTML is a markup language that provides structure and semantics to web pages. It is based on XML and is more strict than HTML. XHTML pages must have a document type definition, html and head tags, and a body where the visible content goes. Common XHTML tags include paragraphs, lists, links, images, and divisions to logically separate content. While XHTML provides structure, CSS is used to style pages and control visual presentation by defining rules for tags. CSS rules are defined in external style sheets to keep presentation separate from structure and content.
XHTML is a markup language that provides structure and semantics to web pages. It is based on XML and is more strict than HTML. XHTML pages must have a document type definition, html and head tags, and a body where the visible content goes. Common XHTML tags include paragraphs, lists, links, images, and divisions to logically separate content. While XHTML provides structure, CSS is used to style pages and control visual presentation through rules that target specific XHTML elements.
This document discusses how to create and use external cascading style sheets (CSS) in Dreamweaver. It provides steps to:
1. Open the CSS Styles tab in Dreamweaver and create a new external CSS stylesheet using a sample text style.
2. Save the stylesheet and link it to a new HTML page to style elements like headings, text sizes, and boxes.
3. Edit existing styles by selecting a tag in the CSS Styles panel and modifying properties directly, or by clicking the tag and using the pencil icon to edit in a window. This allows customizing styles globally across all linked pages.
This document provides an overview of how to create and use cascading style sheets (CSS) in Dreamweaver. It describes the different types of style sheets, including external and internal style sheets. It outlines the steps to create an external style sheet in Dreamweaver using the CSS Styles panel and provides instructions for linking the external style sheet to an HTML page. The document demonstrates how to experiment with predefined styles and how to edit, add, and delete styles in the CSS stylesheet.
This document appears to be a weekly update from an intro to computer science course. It includes summaries of classmates' demographics, comfort levels, and prior experience. It also discusses time spent on problem sets and recommends upcoming courses in CS51 and CS61. Finally, it recommends reading on TCP/IP, HTTP, XHTML, CSS, PHP, SQL and using the bulletin board for questions.
This document appears to be a weekly update from an intro to computer science course. It includes summaries of classmates' demographics, comfort levels, and prior experience. It also discusses time spent on problem sets and recommends upcoming courses in CS51 and CS61. Finally, it recommends reading on topics like TCP/IP, HTTP, XHTML, CSS, PHP, SQL and using bulletin boards, and includes images related to these topics.
The document discusses how to use Cascading Style Sheets (CSS) with Corvid Servlet Runtime templates to control formatting and layout. CSS allows separating design from content, making templates simpler and easier to maintain. It also enables adapting appearance for different devices. The document provides examples of using CSS classes to style template elements and explains how to set up a demo system using the included CSS and templates.
The document discusses how to use Cascading Style Sheets (CSS) with Corvid Servlet Runtime templates to control formatting and layout. CSS allows separating design from content, making templates simpler and easier to maintain. It also enables customization of appearance for different devices. The document provides examples of how to apply CSS classes and rules to Corvid template elements to control fonts, colors, positioning and more.
The document provides an introduction to CSS and how it works with HTML to control the presentation and styling of web page content. It explains basic CSS concepts like selectors, properties and values, and how CSS rules are used to target specific HTML elements and style them. Examples are given of common CSS properties and selectors and how they can be used to style elements and format the layout of web pages.
The document introduces CSS and how it works with HTML to separate content from presentation, allowing the styling of web pages through rules that target HTML elements. It explains CSS syntax and various selectors like type, class, ID, and descendant selectors. Examples are provided of how CSS can be used to style properties like color, font, padding, and layout of elements on a page.
Cascading Style Sheets (CSS) allow users to define how HTML elements are presented on a page. CSS enables changing the appearance and layout of an entire website by editing just one CSS file. CSS uses selectors to apply styles to HTML elements via properties and values. Styles can be defined internally in HTML or externally in CSS files. CSS can control text formatting, colors, spacing, positioning and more to achieve visual consistency across web pages.
Cascading Style Sheets (CSS) allow users to define how HTML elements are presented on a page. CSS enables changing the appearance and layout of an entire website by editing just one CSS file. CSS uses selectors to apply styles to HTML elements via properties and values. Styles can be defined internally in HTML or externally in CSS files. CSS can control text formatting, colors, spacing, positioning and more to achieve visual consistency across web pages.
Ivanti’s Patch Tuesday breakdown goes beyond patching your applications and brings you the intelligence and guidance needed to prioritize where to focus your attention first. Catch early analysis on our Ivanti blog, then join industry expert Chris Goettl for the Patch Tuesday Webinar Event. There we’ll do a deep dive into each of the bulletins and give guidance on the risks associated with the newly-identified vulnerabilities.
Programming Foundation Models with DSPy - Meetup SlidesZilliz
Prompting language models is hard, while programming language models is easy. In this talk, I will discuss the state-of-the-art framework DSPy for programming foundation models with its powerful optimizers and runtime constraint system.
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
Taking AI to the Next Level in Manufacturing.pdfssuserfac0301
Read Taking AI to the Next Level in Manufacturing to gain insights on AI adoption in the manufacturing industry, such as:
1. How quickly AI is being implemented in manufacturing.
2. Which barriers stand in the way of AI adoption.
3. How data quality and governance form the backbone of AI.
4. Organizational processes and structures that may inhibit effective AI adoption.
6. Ideas and approaches to help build your organization's AI strategy.
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.
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
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).
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.
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
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.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
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.
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
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxSitimaJohn
Ocean Lotus cyber threat actors represent a sophisticated, persistent, and politically motivated group that poses a significant risk to organizations and individuals in the Southeast Asian region. Their continuous evolution and adaptability underscore the need for robust cybersecurity measures and international cooperation to identify and mitigate the threats posed by such advanced persistent threat groups.
3. Books
• JavaScript the Definitive Guide
– By David Flanagan, O Reilly. The only really complete reference
Flanagan O’Reilly
on the JavaScript language. Thorough and well-written.
• Makes the global variable blunder when covering Ajax.
• JavaScript: The Good Parts
– By Douglas Crockford (of JSON and YUI fame), O’Reilly
– Outstanding advanced guide to best practices in core JavaScript,
especially functions, objects, and regular expressions. Very short.
p y , j , g p y
• Does not cover Ajax at all. No DOM scripting. “The K&R of JS”.
• Pro JavaScript Techniques
– By John Resig (of jQ y fame), APress
y g ( jQuery ),
– Excellent guide to best practices; not a thorough reference
• Does not make the global variable blunder when covering Ajax.
• DOM Scripting
p g
– By Jeremy Keith, FriendsOf Press
– Focuses on manipulating DOM and CSS
7 • Makes the global variable blunder when briefly covering Ajax.
Online References
• JavaScript tutorial (language syntax)
• http://www w3schools com/js/
http://www.w3schools.com/js/
• http://developer.mozilla.org/en/docs/
Core_JavaScript_1.5_Guide
• JavaScript API references (builtin objects)
• http://www.w3schools.com/jsref/
• http://www.devguru.com/technologies/ecmascript/
QuickRef/
• http://www.devguru.com/technologies/JavaScript/
• http://www.javascriptkit.com/jsref/
• http://developer.mozilla.org/en/docs/
Core_JavaScript_1.5_Reference
• HTML DOM reference (with JavaScript Examples)
• http://www.w3schools.com/htmldom/dom_reference.asp
• Official ECMAScript specification
• http://www.ecma-international.org/publications/standards/
8
Ecma-262.htm
5. Loading Scripts
• script with src
• <script src="my-script.js" type="text/javascript"></script>
– Purpose
• To define functions, objects, and variables.
• Functions will later be triggered by buttons, other user
events, inline script tags with body content, etc.
• script with body content
• <script type="text/javascript">JavaScript code</script>
– Purpose
p
• To directly invoke code that will run as page loads
– E.g., to output HTML content built by JavaScript
• Don’t use this approach for defining functions or for doing
Don t
things that could be done in external files.
– Slower (no browser caching) and less reusable
11
Example (phish.js)
function getMessage() {
var amount = Math round(Math random() * 100000);
Math.round(Math.random()
var message =
"You won $" + amount + "!n" +
"To collect your winnings, send y
y g , your credit cardn" +
"and bank details to oil-minister@phisher.com.";
return(message);
“alert” pops up dialog box
}
function showWinnings1() {
alert(getMessage());
} “document.write” iinserts text into page at current llocation
“d t it ” t t ti t t t ti
function showWinnings2() {
document.write( <h1><blink>
document write("<h1><blink>" + getMessage() +
"</blink></h1>");
}
12
6. Example (loading-scripts.html)
<!DOCTYPE ...><html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Loading Scripts</title>
...
Loads script from previous page
<script src="./scripts/phish.js"
type="text/javascript"></script>
</head>
<body>
Calls showWinnings1 when user presses
... button. Puts result in dialog box.
<input type="button" value="How Much Did You Win?"
onclick='showWinnings1()'/>
...
<script type="text/javascript">showWinnings2()</script>
...
</body></html>
/ / Calls showWinnings2 when page is loaded in
browser. Puts result at this location in page.
13
Example (Results)
14
8. Variables
• Introduce with “var”
– For global variables (!) and local variables.
– No “var” for function arguments
• You do not declare types
– Some people say JavaScript is “untyped” language, but
really it is “dynamically typed” language
y y y yp g g
– JavaScript is very liberal about converting types
• There are only two scopes
– Global scope
• Be very careful with this when using Ajax.
• Can cause race conditions
conditions.
– Function (lexical) scope
17 – There is not block scope as in Java
Operators and Statements
• Almost same set of operators as Java
– + (addition and String concatenation) -, * /
concatenation), *,
– &&, ||, ++, --, etc
– The == comparison is more akin to Java's "equals"
– The === operator (less used) is like Java s ==
Java's
• Statements
– Semicolons are technically optional
• But highly recommended
– Consider
• return x
• return
x
• They are not identical! The second one returns, then evaluates
x. You should act as though semicolons are required as in Java.
• Comments
– Same as in Java (/* ... */ and // ...)
18
9. Conditionals and Simple Loops
• if/else
– Almost identical to Java except test can be converted to
true/false instead of strict true/false
• “false”: false, null undefined "" (empty string), 0 NaN
false : false null, undefined, string) 0,
• “true”: anything else (including the string “false”)
• Basic for loop
– Identical to Java except for variable declarations
• for(var i=0; i<someVal; i++) { doLoopBody(); }
• while loop
– Same as Java except test can be converted to boolean
• while(someTest) { doLoopBody(); }
• do/while loop
19
– Same as Java except test can be converted to boolean
Array Basics
• One-step array allocation
– var primes = [2, 3, 5, 7, 11, 13];
– var names = ["Joe", "Jane", "John", "Juan"];
• No trailing comma after last element (see later slide)
• Two-step array allocation
– var names = new Array(4);
y( );
names[0] = "Joe";
...
names[3] = "Juan";
Juan ;
• Indexed at 0 as in Java
– for(var i=0; i<names.length; i++) {
o (va 0; a es. e gt ; )
doSomethingWith(names[i]);
}
20
10. Other Conditionals and Loops
• switch
– Differs from Java in two ways
• The “case” can be an expression
• Values need not be ints (compared with ===)
)
• for/in loop
– On surface, looks similar to Java for/each loop, but
• For arrays, values are array indexes, not array values
– Use this loop for objects (to see property names), not arrays!
Fails with Prototype or other extended arrays
• For objects, values are the property names
– var names = ["Joe", "Jane", "John", "Juan"];
for(var i in names) {
doSomethingWith(names[i]);
}
21
More on Arrays
• Arrays can be sparse
– var names = new A
Array();
()
names[0] = "Joe";
names[100000] = "Juan";
• Arrays can be resized
– Regardless of how arrays is created, you can do:
• myArray.length = someNewLength;
• myArray[anyNumber] = someNewValue;
• myArray.push(someNewValue)
– These are legal regardless of which way myArray was made
g g y y y
• Arrays have methods
– push, pop, join, reverse, sort, concat, slice, splice, etc.
• See API reference
• Regular objects can be treated like arrays
22 – You can use numbers (indexes) as properties
11. Arrays Example
function arrayLoops() {
var names =
["Joe", "Jane", "John"];
printArray1(names);
printArray2(names);
names.length = 6;
printArray1(names);
printArra 1(names)
printArray2(names);
}
function printArray1(array) {
for(var i=0; i<array.length; i++) {
console.log("[printArray1] array[%o] is %o", i, array[i]);
}
}
console.log is a printf-like way to print output in Firebug
function printArray2(array) { Console window. For testing/debugging only.
for(var i in array) {
console.log("[printArray2] array[%o] is %o", i, array[i]);
} Direct call for interactive testing in Firebug console.
} (Cut/paste all code into console command line.)
23
arrayLoops();
Array Performance
Time to create and sum array of 16 million random numbers
9
8
7
6
5
4
3
2
1
0
JavaScript:
p
Firefox 3 JavaScript:
Google Chrome Java: 1.6_0_10
Note: Internet Explorer 7 was more than 10 times slower than Firefox, so times are not shown here.
24 Source code for benchmarks is in downloadable Eclipse project at coreservlets.com.
13. String Basics
• You can use double or single quotes
– var names = [ Joe , 'Jane', "John", 'Juan'];
["Joe" Jane John Juan ];
• You can access length property
– E.g., "foobar".length returns 6
• N b
Numbers can b converted to strings
be t dt t i
– Automatic conversion during concatenations.
String need not be first as in Java
• var val = 3 + "abc" + 5; // Result is "3abc5"
abc 3abc5
– Conversion with fixed precision
• var n = 123.4567;
var val = n.toFixed(2); // Result is 123.46 (not 123.45)
( ); ( )
• Strings can be compared with ==
– "foo" == 'foo' returns true
• Strings can be converted to numbers
– var i = parseInt("37 blah"); // Result is 37 – ignores blah
– var d = parseFloat("6.02 blah"); // Ignores blah
27
Core String Methods
• Simple methods similar to Java
– charAt, indexOf, lastIndexOf, substring, toLowerCase,
toUpperCase
• Methods that use regular expressions
– match, replace, search, split
• HTML methods
– anchor, big, bold, fixed, fontcolor, fontsize, italics, link,
small, strike, sub, sup
• "test".bold().italics().fontcolor("red") returns
'<font color="red"><i><b>test</b></i></font>'
– These are technically nonstandard methods, but supported
y pp
in all major browsers
• But I prefer to construct HTML strings explicitly anyhow
28
14. Regular Expressions
• You specify a regexp with /pattern/
– N with a String as in Java
Not i h S i i J
• Most special characters same as in Java/Unix/Perl
– ^, $, .
, , – beginning, end of string, any one char
g g, g, y
– – escape what would otherwise be a special character
– *, +, ? – 0 or more, 1 or more, 0 or 1 occurrences
– {n}, {n }
{n} {n,} – exactly n, n or more occurrences
n
– [] – grouping
– s, S – whitespace, non-whitespace
– w,
w W – word char (letter or number), non-word char
number) non word
• Modifiers
– /pattern/g – do global matching (find all matches, not just first one)
– /pattern/i – do case-insensitive matching
– /pattern/m – do multiline matching
29
Regular Expression: Examples
30
16. Overview
• Not similar to Java
–J S i f
JavaScript functions very diff
i different f
from J
Java methods
h d
• Main differences from Java
– You can have global functions
• Not just methods (functions as part of objects)
– You don’t declare return types or argument types
– Caller can supply any number of arguments
• Regardless of how many arguments you defined
– Functions are first-class datatypes
• Y can pass f
You functions around, store them in arrays, etc.
ti d t th i t
– You can create anonymous functions (closures)
• Critical for Ajax
• These are equivalent
– function foo(...) {...}
33
– var foo = function(...) {...}
Passing Functions: Example
function third(x) {
return(x / 3);
}
function triple(x) {
return(x * 3);
( )
}
function nineTimes(x) {
return(x * 9);
etu ( );
}
Function as argument.
function operate(f) {
var nums = [1, 2, 3];
for(var i=0; i<nums.length; i++) {
var num = nums[i];
console.log( Operation
console log("Operation on %o is %o ",
%o.
num, f(num));
}
34
}
17. Anonymous Functions
• Anonymous functions (or closures) let you
capture local variables inside a function
– You can't do Ajax without this!
• Basic anonymous function
– operate(function(x) { return(x * 20); });
• Outputs 20, 40, 60
• The "operate" function defined on previous page
• Anonymous f
function with captured data
– function someFunction(args) {
var val = someCalculation(args);
return(function(moreArgs) {
doSomethingWith(val, moreArgs);
});
}
var f1 = someFunction(args1);
var f2 = someFunction(args2);
f1(args3); // Uses one copy of "val"
35
f2(args3); // Uses a different copy of "val"
Anonymous Functions: Example
function multiplier(m) {
return(function(x)
{ return(x * m); });
}
function operate2() {
var nums = [1, 2, 3];
var functions =
[multiplier(1/3), multiplier(3), multiplier(9)];
for(var i=0; i<functions.length; i++) {
for(var j=0; j<nums.length; j++) {
var f = functions[i];
var num = nums[j];
console.log("Operation on %o is %o.",
g p
num, f(num));
}
}
36 }
18. Optional Args: Summary
• Fixed number of optional args
– Functions can always be called with any number of args
– Compare typeof args to "undefined"
– See next page and upcoming convertString function
• Arbitrary args
– Discover number of args with arguments length
arguments.length
– Get arguments via arguments[i]
– See next page and upcoming longestString function
• Optional args via anonymous object
– Caller always supplies same number of arguments, but
one of the arguments is an anonymous (JSON) object
f th t i bj t
• This object has optional fields
37 – See later example in “Objects” section
Optional Args: Details
• You can call any function with any number
of arguments
f
– If called with fewer args, extra args equal "undefined"
• You can use typeof arg == "undefined" for this
undefined
– You can also use boolean comparison if you are sure that no real
value could match (e.g., 0 and undefined both return true for !arg)
• Use comments to indicate optional args
– function foo(arg1, arg2, /* Optional */ arg3) {...}
– If called with extra args, you can use “arguments” array
• R
Regardless of d fi d variables, arguments.length t ll
dl f defined i bl t l th tells
you how many arguments were supplied, and arguments[i]
returns the designated argument
• Use comments to indicate extra args
– function bar(arg1, arg2 /* varargs */) { ... }
38
19. Optional Arguments
function convertString(numString, /* Optional */ base) {
if (typeof base == "undefined") {
undefined )
base = 10;
}
var num = parseInt(numString, base);
console.log("%s base %o equals %o base 10.",
numString, base, num);
}
39
Varargs
function longestString(/* varargs */) {
var longest = "";;
for(var i=0; i<arguments.length; i++) {
var candidateString = arguments[i];
if (candidateString length > longest length) {
(candidateString.length longest.length)
longest = candidateString;
}
}
return(longest);
}
longestString("a", "bb", "ccc", "dddd");
// Returns "dddd"
40
21. Objects: Example
(Circle Class)
function Circle(radius) {
this.radius
this radius = radius;
this.getArea =
function() {
return(Math.PI * this.radius * this.radius);
};
}
var c = new Circle(10);
c.getArea(); // Returns 31 1 92
() 314.1592...
43
The prototype Property
• In previous example
–E
Every new Circle got its own copy of radius
Ci l i f di
• Fine, since radius has per-Circle data
– Every new Circle got its own copy of getArea function
• Wasteful since function definition never changes
• Class-level properties
– Classname prototype propertyName = value;
Classname.prototype.propertyName
• Methods
– Classname.prototype.methodName = function() {...};
• Just a special case of class-level properties
– This is legal anywhere, but it is best to do it in constructor
• Pseudo-Inheritance
Pseudo Inheritance
– The prototype property can be used for inheritance
44
– But complex. See later section on Prototype library
22. Objects: Example
(Updated Circle Class)
function Circle(radius) {
this.radius
this radius = radius;
Circle.prototype.getArea =
function() {
return(Math.PI * this.radius * this.radius);
};
}
var c = new Circle(10);
c.getArea(); // Returns 31 1 92
() 314.1592...
45
Rolling Your Own Namespace
• Idea
–HHave related f
l d functions that do not use object properties
i h d bj i
– You want to group them together and call them with
Utils.func1, Utils.func2, etc.
• Grouping is a syntactic convenience. Not real methods.
• Helps to avoid name conflicts when mixing JS libraries
– Similar to static methods in Java
• Syntax
– Assign functions to properties of an object, but do not
define a constructor. E.g.,
constructor E g
• var Utils = {}; // Or "new Object()", or make function Utils
Utils.foo = function(a, b) { … };
Utils.bar function(c) { … }
Util b = f ti ( ) };
var x = Utils.foo(val1, val2);
46
var y = Utils.bar(val3);
23. Static Methods: Example (Code)
var MathUtils = {};
MathUtils.fact = function(n) {
if (n <= 1) {
return(1);
} else {
return(n * MathUtils.fact(n-1));
}
};
MathUtils.log10 = function(x) {
return(Math.log(x)/Math.log(10));
( g( ) g( ))
};
47
Namespaces in Real
Applications
• Best practices in large projects
– In many (most?) large projects, all global variables
(including functions!) are forbidden due to the possibility
of name collisions from pieces made by different authors.
– So, these primitive namespaces play the role of Java’s
packages. Much weaker, but still very valuable.
• Fancy variation: repeat the name
• var MyApp = {};
• MyApp foo = function foo( ) { … };
MyApp.foo foo(…)
• MyApp.bar = function bar(…) { … };
– The name on the right does not become a global name.
The l d t
Th only advantage is for debugging
i f d b i
• Firebug and other environments will show the name when
48
you print the function object.
24. JSON (JavaScript Object Notation)
• Idea
– A simple textual representation of JavaScript objects
– Main applications
• One time use objects (rather than reusable classes)
One-time-use
• Objects received via strings
• Directly in JavaScript
– var someObject =
{ property1: value1,
property2: value2,
... };
• In a string (e.g., when coming in on network)
– Surround object representation in parens
– Pass to the builtin “eval” function
49
JSON: Example
var person =
{ firstName: 'Brendan',,
lastName: 'Eich',
bestFriend: { firstName: 'Chris',
lastName: 'Wilson' },
greeting: function() {
return("Hi, I am " + this.firstName +
" " + this.lastName + ".");
}
};
50
25. Using JSON for Optional
Arguments
• Idea
– Caller always supplies same number of arguments, but
one of the arguments is an anonymous (JSON) object
• This object has optional fields
– This approach is widely used in Prototype, Scriptaculous,
and other JavaScript libraries
• Example (a/b: required, c/d/e/f: optional)
– someFunction(1.2, 3.4, {c: 4.5, f: 6.7});
– someFunction(1.2, 3 4
someFunction(1 2 3.4, {c: 4.5, d: 6.7, e: 7.8});
45 6 7 7 8});
– someFunction(1.2, 3.4, {c: 9.9, d: 4.5, e: 6.7, f: 7.8});
– someFunction(1.2, 3.4);
( , );
51
Using JSON for Optional
Arguments: Example Code
function sumNumbers(x, y, extraParams) {
var result = x + y;
if (isDefined(extraParams)) {
if (isTrue(extraParams.logInput)) {
console.log("Input: x=%s, y=%s", x, y);
}
if (isDefined(extraParams.extraOperation)) {
result = extraParams.extraOperation(result);
}
}
return(result)
}
function isDefined(value) {
return(typeof value != "undefined");
}
function isTrue(value) {
return(isDefined(value) && (value == true))
52 }
26. Using JSON for Optional
Arguments: Example Results
53
Internet Explorer and Extra
Commas
• Firefox tolerates trailing commas in both
arrays and JSON
d
• var nums = [1, 2, 3, ];
• var obj = { firstName: "Joe", lastName: "Hacker", };
Joe , Hacker ,
• IE will crash in both cases.
– And, since it is not technically legal anyway, you should
write it without commas after the final element:
• var nums = [1, 2, 3];
• var obj = { firstName: "Joe", lastName: "Hacker"};
Joe , Hacker };
– This issue comes up moderately often, especially when
building JavaScript data on the server, as we will do in
upcoming lectures.
i l t
54