Tutorial by Examples: co

To determine the color and pixel depths of the screen: var pixelDepth = window.screen.pixelDepth, colorDepth = window.screen.colorDepth;
A common pitfall is confusing the equality comparison operators is and ==. a == b compares the value of a and b. a is b will compare the identities of a and b. To illustrate: a = 'Python is fun!' b = 'Python is fun!' a == b # returns True a is b # returns False a = [1, 2, 3, 4, 5] b = a ...
Standard Collections Java Collections framework A simple way to construct a List from individual data values is to use java.utils.Arrays method Arrays.asList: List<String> data = Arrays.asList("ab", "bc", "cd", "ab", "bc", "cd"); ...
Different from stored properties, computed properties are built with a getter and a setter, performing necessary code when accessed and set. Computed properties must define a type: var pi = 3.14 class Circle { var radius = 0.0 var circumference: Double { get { ret...
In order to compare the equality of custom classes, you can override == and != by defining __eq__ and __ne__ methods. You can also override __lt__ (<), __le__ (<=), __gt__ (>), and __ge__ (>). Note that you only need to override two comparison methods, and Python can handle the rest (== ...
Output buffering allows you to store any textual content (Text, HTML) in a variable and send to the browser as one piece at the end of your script. By default, php sends your content as it interprets it. <?php // Turn on output buffering ob_start(); // Print some output to the buffer (via...
ob_start(); $user_count = 0; foreach( $users as $user ) { if( $user['access'] != 7 ) { continue; } ?> <li class="users user-<?php echo $user['id']; ?>"> <a href="<?php echo $user['link']; ?>"> <?php echo $user...
<?php ob_start(); ?> <html> <head> <title>Example invoice</title> </head> <body> <h1>Invoice #0000</h1> <h2>Cost: £15,000</h2> ... </body> </html> <?php...
If you have already added a file to your Git repository and now want to stop tracking it (so that it won't be present in future commits), you can remove it from the index: git rm --cached <file> This will remove the file from the repository and prevent further changes from being tracked by...
<script src= "http://player.twitch.tv/js/embed/v1.js"></script> <div id="PLAYER_DIV_ID"></div> <script type="text/javascript"> var options = { width: 854, height: 480, video: "v53336925", };...
The following is how to properly use the java.util.Scanner class to interactively read user input from System.in correctly( sometimes referred to as stdin, especially in C, C++ and other languages as well as in Unix and Linux). It idiomatically demonstrates the most common things that are requested ...
Markdown supports adding inline code like this, obtained by wrapping text in backticks: `code here` Alternatively, you can put your inline code between <code> and </code> HTML tags. Consider the following markdown code: `This` is an inline code block! <code>This</code> is...
One use case for assertion is precondition and postcondition. This can be very useful to maintain invariant and design by contract. For a example a length is always zero or positive so this function must return a zero or positive value. #include <stdio.h> /* Uncomment to disable `assert()`...
You can overload all basic arithmetic operators: + and += - and -= * and *= / and /= & and &= | and |= ^ and ^= >> and >>= << and <<= Overloading for all operators is the same. Scroll down for explanation Overloading outside of class/struct: //operator...
You can overload all comparison operators: == and != > and < >= and <= The recommended way to overload all those operators is by implementing only 2 operators (== and <) and then using those to define the rest. Scroll down for explanation Overloading outside of class/struct: ...
You can overload type operators, so that your type can be implicitly converted into the specified type. The conversion operator must be defined in a class/struct: operator T() const { /* return something */ } Note: the operator is const to allow const objects to be converted. Example: struct ...
This method can be used to convert a formatted string representation of a date into a Date object. /** * Parses the date using the given format. * * @param formattedDate the formatted date string * @param dateFormat the date format which was used to create the string. ...
Sometimes we will need to run commands against a lot of files. This can be done using xargs. find . -type d -print | xargs -r chmod 770 The above command will recursively find all directories (-type d) relative to . (which is your current working directory), and execute chmod 770 on them. The -...
lscount returns a time bucketed count of matching documents in the LogStash index, according to the specified filter. A trivial use of this would be to check how many documents in total have been received in the 5 minutes, and alert if it is below a certain threshold. A Bosun alert for this might ...
To encode a string into a byte array, you can simply use the String#getBytes() method, with one of the standard character sets available on any Java runtime: byte[] bytes = "test".getBytes(StandardCharsets.UTF_8); and to decode: String testString = new String(bytes, StandardCharsets.U...

Page 11 of 248