Tutorial by Examples: f

Starter code to create and remove a full page canvas that responds to resize events via javascript. var canvas; // Global canvas reference var ctx; // Global 2D context reference // Creates a canvas function createCanvas () { const canvas = document.createElement(&q...
Many times when working with the canvas you will need to have a canvas to hold some intrum pixel data. It is easy to create an offscreen canvas, obtain a 2D context. An offscreen canvas will also use the available graphics hardware to render. The following code simply creates a canvas and fills it ...
This example will show you how to create a simple animation using the canvas and the 2D context. It is assumed you know how to create and add a canvas to the DOM and obtain the context // this example assumes ctx and canvas have been created const textToDisplay = "This is an example that uses...
Think about a situation where we need to callback a function with arguments. std::function used with std::bind gives a very powerful design construct as shown below. class A { public: std::function<void(int, const std::string&)> m_CbFunc = nullptr; void foo() { ...
The $_FILES["FILE_NAME"]['error'] (where "FILE_NAME" is the value of the name attribute of the file input, present in your form) might contain one of the following values: UPLOAD_ERR_OK - There is no error, the file uploaded with success. UPLOAD_ERR_INI_SIZE - The uploaded fi...
Assumptions for this example: You have a class, foo.bar.Baz. You'd like to create a run configuration that runs the main method. It's in a module called fooBar. In your gradle file: idea { workspace.iws.withXml { provider -> // I'm not actually sure why this is necessar...
XML pre-defines five general entities that can be used without declaring them: & " ' < > They are associated with the names amp, quot, apos, lt and gt. <?xml version="1.0"?> <entities> & is an ampersand. " is a quote. ' is...
It is possible to define one's own general entities. The declaration occurs in the DTD subset, with a name and the associated replacement text. It can then be used in the document using the entity reference syntax &...;, either in text, or in attribute values. <?xml version="1.0"?...
The HasFlag() method can be used to check if a flag is set. Module Module1 <Flags> Enum Material Wood = 1 Plastic = 2 Metal = 4 Stone = 8 End Enum Sub Main() Dim houseMaterials As Material = Material.Wood Or Material.Stone ...
${parameter:-word} If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted. $ unset var $ echo "${var:-XX}" # Parameter is unset -> expansion XX occurs XX $ var="" # Parameter is null ...
The semantics for this are similar to that of default value substitution, but instead of substituting a default value, it errors out with the provided error message. The forms are ${VARNAME?ERRMSG} and ${VARNAME:?ERRMSG}. The form with : will error our if the variable is unset or empty, whereas the ...
1. URLByDeletingPathExtension: If the receiver represents the root path, this property contains a copy of the original URL. If the URL has multiple path extensions, only the last one is removed. 2. URLByAppendingPathExtension: Returns a new URL made by appending a path extension to the original U...
The figure contains all the plot elements. The main way to create a figure in matplotlib is to use pyplot. import matplotlib.pyplot as plt fig = plt.figure() You can optionally supply a number, which you can use to access a previously-created figure. If a number is not supplied, the last-create...
To create a JAR containing all of its dependencies, it is possible to use the built-in descriptor format jar-with-dependencies. The following example configures an execution of the Assembly Plugin bound to the package phase, using this built-in descriptor and declaring a main class of com.example: ...
Shortest match: $ a='I am a string' $ echo "${a#*a}" m a string Longest match: $ echo "${a##*a}" string
Shortest match: $ a='I am a string' $ echo "${a%a*}" I am Longest match: $ echo "${a%%a*}" I
In [15]: df = pd.DataFrame({"A":[1,1,2,3,1,1],"B":[5,4,3,4,6,7]}) In [21]: df Out[21]: A B 0 1 5 1 1 4 2 2 3 3 3 4 4 1 6 5 1 7 To get unique values in column A and B. In [22]: df["A"].unique() Out[22]: array([1, 2, 3]) In [23]: df[&qu...
Creates a image representing a linear gradient of colors. linear-gradient( 0deg, red, yellow 50%, blue); This creates a gradient going from bottom to top, with colors starting at red, then yellow at 50%, and finishing in blue.
For checking whether some object is of a certain class, the (binary) instanceof operator can be used since PHP version 5. The first (left) parameter is the object to test. If this variable is not an object, instanceof always returns false. If a constant expression is used, an error is thrown. The ...
You can use buffers to work with multiple files. When you open a file using :e path/to/file it opens in a new buffer (the command means edit the file). New buffer that holds a temporary copy of the file. You can go to previous buffer with :bp[rev] and next buffer with :bn[ext]. You can go to a...

Page 92 of 457