Tutorial by Examples: c

Another common use of HTTP APIs is to delete an existing resource. This should usually be done using DELETE requests. If the deletion was successful, the server should return 200 OK; an appropriate error code if it was not. If our employee Charlie Smith has left the company and we now want to dele...
The last common use of HTTP APIs is to obtain a list of existing resources on the server. Lists like this should be obtained using GET requests, since they only retrieve data. The server should return 200 OK if it can supply the list, or an appropriate error code if not. Listing our employees, the...
A cross-origin request must be sent including the Origin header. This indicates from where the request originated. For example, a cross-origin request from http://example.com to http://example.org would look like this: GET /cors HTTP/1.1 Host: example.org Origin: example.com The server will us...
The response to a CORS request must include an Access-Control-Allow-Origin header, which dictates what origins are allowed to use the CORS resource. This header can take one of three values: An origin. Doing this permits requests from that origin only. The character *. This permits requests from...
Allowing user credentials or the user's session to be sent with a CORS request allows the server to persist user data across CORS requests. This is useful if the server needs to check if the user is logged in before providing data (for example, only performing an action if a user is logged in - this...
var app = {}; app.signUp = function(){ app.userName = $('#userName').val(); app.password = $('#password').val(); app.email = $('#form-email').val(); app.phoneNumber = $('#form-phone').val(); app.emailRegex = ...
Mostly you will use "normal variables": set(VAR TRUE) set(VAR "main.cpp") set(VAR1 ${VAR2}) But CMake does also know global "cached variables" (persisted in CMakeCache.txt). And if normal and cached variables of the same name exist in the current scope, normal var...
To update CocoaPods by simply installing the gem again [sudo] gem install cocoapods Or for a pre-release version [sudo] gem install cocoapods --pre
The most important use of ranges is to express a sequence Syntax: (begin..end) => this construct will include end value (begin...end) => this construct will exclude end value or Range.new(begin,end,exclude_end) => exclude_end is by default false Most important end value must be gr...
Sometimes you want to convert your enum to a String, there are two ways to do that. Assume we have: public enum Fruit { APPLE, ORANGE, STRAWBERRY, BANANA, LEMON, GRAPE_FRUIT; } So how do we convert something like Fruit.APPLE to "APPLE"? Convert using name() name() is an inte...
integer: 25 string: "25" float: 25.0 boolean: true null type: null
Static class properties that are defined with the public visibility are functionally the same as global variables. They can be accessed from anywhere the class is defined. class SomeClass { public static int $counter = 0; } // The static $counter variable can be read/written from anywhere...
When we want to count the number of items in an iterable, that meet some condition, we can use comprehension to produce an idiomatic syntax: # Count the numbers in `range(1000)` that are even and contain the digit `9`: print (sum( 1 for x in range(1000) if x % 2 == 0 and '9' in str...
Functionality in metaclasses can be changed so that whenever a class is built, a string is printed to standard output, or an exception is thrown. This metaclass will print the name of the class being built. class VerboseMetaclass(type): def __new__(cls, class_name, class_parents, class_dict)...
Like any other java program, every swing program starts with a main method. The main method is initiated by the main thread. However, Swing components need to be created and updated on the event dispatch thread (or short: EDT). To illustrate the dynamic between the main thread and the EDT take a loo...
In Java, we can convert between integer values and floating-point values. Also, since every character corresponds to a number in the Unicode encoding, char types can be converted to and from the integer and floating-point types. boolean is the only primitive datatype that cannot be converted to or f...
defmodule Processes do def receiver do receive do {:ok, val} -> IO.puts "Received Value: #{val}" _ -> IO.puts "Received something else" end end end iex(1)> pid = spawn(Processes, ...
Recursion can be used to receive multiple messages defmodule Processes do def receiver do receive do {:ok, val} -> IO.puts "Received Value: #{val}" _ -> IO.puts "Received something else" end...
For a function or subroutine to be useful it has to be referenced. A subroutine is referenced in a call statement call sub(...) and a function within an expression. Unlike in many other languages, an expression does not form a complete statement, so a function reference is often seen in an ass...
Computed GOTO allows branching of the program according to the value of an integer expression. GOTO (label_1, label_2,... label_n) scalar-integer-expression If scalar-integer-expression is equal to 1 the program continues at statement label label_1, if it is equal to 2 it goes to label_2 and so ...

Page 281 of 826