Tutorial by Examples: e

Like an HTTP request, an HTTP response may include additional headers to modify or augment the response it provides. A full list of available headers is defined in §6.2 of the specification. The most commonly-used headers are: Server, which functions like a User-Agent request header for the serv...
As with request bodies, HTTP responses may contain a message body. This provides additional data that the client will process. Notably, 200 OK responses to a well-formed GET request should always provide a message body containing the requested data. (If there is none, 204 No Content is a more approp...
DELETE FROM `myTable` WHERE `someColumn` = 'something' The WHERE clause is optional but without it all rows are deleted.
A common problem is having a collection of items that all need to meet a certain criteria. In the example below we have collected two items for a diet plan and we want to check that the diet doesn't contain any unhealthy food. // First we create a collection $diet = collect([ ['name' => ...
You will often find yourself with a collection of data where you are only interested in parts of the data. In the example below we got a list of participants at an event and we want to provide a the tour guide with a simple list of names. // First we collect the participants $participants = colle...
Often you need to change the way a set of data is structured and manipulate certain values. In the example below we got a collection of books with an attached discount amount. But we much rather have a list of books with a price that's already discounted. $books = [ ['title' => 'The Pragma...
Collections also provide you with an easy way to do simple statistical calculations. $books = [ ['title' => 'The Pragmatic Programmer', 'price' => 20], ['title' => 'Continuous Delivery', 'price' => 30], ['title' => 'The Clean Coder', 'price' => 10], ] $min = col...
A web worker is a simple way to run scripts in background threads as the worker thread can perform tasks (including I/O tasks using xmlHttpRequest) without interfering with the user interface. Once created, a worker can send messages which can be different data types (except functions) to the JavaSc...
In Java, parent and child class both can have static methods with the same name. But in such cases implementation of static method in child is hiding parent class' implementation, it's not method overriding. For example: class StaticMethodTest { // static method and inheritance public stati...
use-fixtures allows to wrap each deftest in namespace with code that runs before and after test. It can be used for fixtures or stubbing. Fixtures are just functions that take test function and run it with other necessary steps (before/after, wrap). (ns myapp.test (require [clojure.test :refer ...
The text-transform property allows you to change the capitalization of text. Valid values are: uppercase, capitalize, lowercase, initial, inherit, and none CSS: .example1 { text-transform: uppercase; } .example2 { text-transform: capitalize; } .example3 { text-transform: lowerc...
Functions are defined with five components: The header, which includes the defn keyword, the name of the function. (defn welcome ....) An optional Docstring that explains and document what the function does. (defn welcome "Return a welcome message to the world" ...) Pa...
Scala can be used as a scripting language. To demonstrate, create HelloWorld.scala with the following content: println("Hello") Execute it with the command-line interpreter (the $ is the command line prompt): $ scala HelloWorld.scala Hello If you omit .scala (such as if you simply...
This is the easiest syntax to define a function: square(n) = n * n To call a function, use round brackets (without spaces in between): julia> square(10) 100 Functions are objects in Julia, and we can show them in the REPL as with any other objects: julia> square square (generic func...
Simple recursion Using recursion and the ternary conditional operator, we can create an alternative implementation of the built-in factorial function: myfactorial(n) = n == 0 ? 1 : n * myfactorial(n - 1) Usage: julia> myfactorial(10) 3628800 Working with trees Recursive functions are o...
A long-form syntax is available for defining multi-line functions. This can be useful when we use imperative structures such as loops. The expression in tail position is returned. For instance, the below function uses a for loop to compute the factorial of some integer n: function myfactorial(n) ...
Functions are objects in Julia. Like any other objects, they can be passed as arguments to other functions. Functions that accept functions are known as higher-order functions. For instance, we can implement an equivalent of the standard library's foreach function by taking a function f as the firs...
In Vue.js, every component instance has its own isolated scope, which means that if a parent component has a child component - the child component has its own isolated scope and the parent component has its own isolated scope. For any medium to large size app, following best practices conventions p...
Sometimes you will have a grid of subplots, and you want to have a single legend that describes all the lines for each of the subplots as in the following image. In order to do this, you will need to create a global legend for the figure instead of creating a legend at the axes level (which wil...
Deferred function calls serve a similar purpose to things like finally blocks in languages like Java: they ensure that some function will be executed when the outer function returns, regardless of if an error occurred or which return statement was hit in cases with multiple returns. This is useful f...

Page 353 of 1191