Tutorial by Examples: e

Some people recommend that you should apply various tests to a file before attempting to open it either to provide better diagnostics or avoid dealing with exceptions. For example, this method attempts to check if path corresponds to a readable file: public static File getValidatedFile(String path...
It is possible that the client browser does not support Javascript or have Javascript execution disabled, perhaps due to security reasons. To be able to tell users that a script is supposed to execute in the page, the <noscript> tag can be used. The content of <noscript> is displayed whe...
An unsigned JWT has the header value alg: none and an empty JWS (signature) component: eyJhbGciOiJub25lIn0 .eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ . The trailing dot indicates that the signature is empty. Header { "alg": &q...
A signed JWT includes a Base64 Url Safe encoded signature as the third component. The algorithm used to generate the signature is indicated in the header. eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9 .eyJzdWIiOiJKb2huIERvZSIsImFkbWluIjp0cnVlLCJpYXQiOjE0NzAzNTM5OTQsImV4cCI6MTQ3MDM1NzYyNywianRpIjoiNmU0MDRiY...
Detailed instructions on getting x++ set up or installed.
The term responsive web design was first coined by Ethan Marcotte in his famous article Responsive Web Design, published in 2010 in A List Apart. This Smashing Magazine article by Kayla Knight describes it as follows: Responsive Web design is the approach that suggests that design and developme...
Let's assume you have a file lyrics.txt which contains the following data: summer has come and passed the innocent can never last wake me up when september ends Read the entire file at a time By using file:read_file(File), you can read the entire file. It's an atomic operation: 1> file:re...
Write one line at a time Open a file with write mode and use io:format/2: 1> {ok, S} = file:open("fruit_count.txt", [write]). {ok,<0.57.0>} 2> io:format(S, "~s~n", ["Mango 5"]). ok 3> io:format(S, "~s~n", ["Olive 12"]). ok 4&gt...
This is a very simple program to create a PDF using iText 7 / Java: //Initialize writer PdfWriter writer = new PdfWriter(dest); //Initialize document PdfDocument pdfDoc = new PdfDocument(writer); Document doc = new Document(pdfDoc); //Add paragraph to the document doc.add(new Paragraph(&q...
Introduces the definition of an enumeration type. enum Direction { UP, LEFT, DOWN, RIGHT }; Direction d = UP; C++11 In C++11, enum may optionally be followed by class or struct to define a scoped enum. Furthermore, both scoped and unscoped enums can have their unde...
Only Oracle JDKs and JREs are available for Windows platforms. The installation procedure is straight-forward: Visit the Oracle Java Downloads page: Click on either the JDK button, the JRE button or the Server JRE button. Note that to develop using Java you need JDK. To know the difference betw...
When applied to a single-argument constructor, prevents that constructor from being used to perform implicit conversions. class MyVector { public: explicit MyVector(uint64_t size); }; MyVector v1(100); // ok uint64_t len1 = 100; MyVector v2{len1}; // ok, len1 is uint64_t int len2 ...
<?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"&g...
Sometimes you may need to convert a Set to an array, for example to be able to use Array.prototype methods like .filter(). In order to do so, use Array.from() or destructuring-assignment: var mySet = new Set([1, 2, 3, 4]); //use Array.from const myArray = Array.from(mySet); //use destructuring-a...
There are no build-in methods for intersection and difference in Sets, but you can still achieve that but converting them to arrays, filtering, and converting back to Sets: var set1 = new Set([1, 2, 3, 4]), set2 = new Set([3, 4, 5, 6]); const intersection = new Set(Array.from(set1).filter(x...
You can use a simple for-of loop to iterate a Set: const mySet = new Set([1, 2, 3]); for (const value of mySet) { console.log(value); // logs 1, 2 and 3 } When iterating over a set, it will always return values in the order they were first added to the set. For example: const set = new S...
Suppose you have a pojo class Person public class Person { public String name; public Person(String name) { this.name = name; } } And you want to parse it into a JSON array or a map of Person objects. Due to type erasure you cannot construct classes of List<Person&g...
If we have a file called Business.hs, we can define a Business module that can be import-ed, like so: module Business ( Person (..), -- ^ Export the Person type and all its constructors and field names employees -- ^ Export the employees function ) where -- begin types, function defin...
To export the type and all its constructors, one must use the following syntax: module X (Person (..)) where So, for the following top-level definitions in a file called People.hs: data Person = Friend String | Foe deriving (Show, Eq, Ord) isFoe Foe = True isFoe _ = False This module d...
Haskell supports importing a subset of items from a module. import qualified Data.Stream (map) as D would only import map from Data.Stream, and calls to this function would require D.: D.map odd [1..] otherwise the compiler will try to use Prelude's map function.

Page 639 of 1191