Tutorial by Examples: alternative

For every infix operator, e.g. + there is a operator-function (operator.add for +): 1 + 1 # Output: 2 from operator import add add(1, 1) # Output: 2 even though the main documentation states that for the arithmetic operators only numerical input is allowed it is possible: from operator impo...
<link rel="alternate stylesheet" href="path/to/style.css" title="yourTitle"> Some browsers allow alternate style sheets to apply if they are offered. By default they will not be applied, but usually they can be changed through the browser settings: Firefox l...
<?php for ($i = 0; $i < 10; $i++): do_something($i); endfor; ?> <?php for ($i = 0; $i < 10; $i++): ?> <p>Do something in HTML with <?php echo $i; ?></p> <?php endfor; ?>
<?php while ($condition): do_something(); endwhile; ?> <?php while ($condition): ?> <p>Do something in HTML</p> <?php endwhile; ?>
<?php foreach ($collection as $item): do_something($item); endforeach; ?> <?php foreach ($collection as $item): ?> <p>Do something in HTML with <?php echo $item; ?></p> <?php endforeach; ?>
<?php switch ($condition): case $value: do_something(); break; default: do_something_else(); break; endswitch; ?> <?php switch ($condition): ?> <?php case $value: /* having whitespace before your cases will cause an error */ ?&g...
<?php if ($condition): do_something(); elseif ($another_condition): do_something_else(); else: do_something_different(); endif; ?> <?php if ($condition): ?> <p>Do something in HTML</p> <?php elseif ($another_condition): ?> <p>...
You can also use loop with curly brackets like this: if ( have_posts() ) { while ( have_posts() ) { the_post(); var_dump( $post ); } }
Set the MONGO_URL environment variable before starting your local Meteor app. Linux/MacOS Example: MONGO_URL="mongodb://some-mongo-host.com:1234/mydatabase" meteor or export MONGO_URL="mongodb://some-mongo-host.com:1234/mydatabase" meteor Windows Example Note: don't u...
PHP provides an alternative syntax for some control structures: if, while, for, foreach, and switch. When compared to the normal syntax, the difference is, that the opening brace is replaced by a colon (:) and the closing brace is replaced by endif;, endwhile;, endfor;, endforeach;, or endswitch;, ...
Related to Monads are F# computation expressions (CE). A programmer typically implements a CE to provide an alternative approach to chaining Monads, ie instead of this: let v = m >>= fun x -> n >>= fun y -> return_ (x, y) You can write this: let v = ce { let! x = m ...
Here are examples of how to use monotonic predicates instead of impure, non-monotonic constructs in your programs: dif/2 is meant to be used instead of non-monotonic constructs like (\=)/2 arithmetic constraints (CLP(FD), CLP(Q) and others) are meant to be used instead of moded arithmetic predi...
Let's say we have type ENUM('fish','mammal','bird') An alternative is type TINYINT UNSIGNED plus CREATE TABLE AnimalTypes ( type TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, name VARCHAR(20) NOT NULL COMMENT "('fish','mammal','bird')", PRIMARY KEY(type), INDEX(na...
Let's say we have type ENUM('fish','mammal','bird') An alternative is type VARCHAR(20) COMENT "fish, bird, etc" This is quite open-ended in that new types are trivially added. Comparison, and whether better or worse than ENUM: (same) INSERT: simply provide the string (worse?)...
The default for drawing markers is to use the stroke width of the calling element, but you can explicitly specify that markers be drawn using the unit system for the element the marker is being applied to by specifying markerUnits="userSpaceOnUse". Markers are drawn into a 3x3 markerUnits ...
Using Alternatives Many Linux distributions use the alternatives command for switching between different versions of a command. You can use this for switching between different versions of Java installed on a machine. In a command shell, set $JDK to the pathname of a newly installed JDK; e.g....
All libraries come with resources that are not necessary useful to your application. For example Google Play Services comes with translations for languages your own application don’t even support. You can configure the build.gradle file to specify which resource you want to keep. For example: de...
<svg width="600px" height="600px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <polyline points="10,10,50,40,80,30,120,90,130,10,180,50,250,100,300,10" fill="none" stroke="red" s...
<svg width="600px" height="400px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <line x1="10" y1="20" x2="300" y2="20" stroke="red" stroke-width="20"...
While the JavaScript tracking snippet described above ensures the script will be loaded and executed asynchronously on all browsers, it has the disadvantage of not allowing modern browsers to preload the script. The alternative async tracking snippet below adds support for preloading, which will pr...

Page 1 of 2