Tutorial by Examples: com

Class composition allows explicit relations between objects. In this example, people live in cities that belong to countries. Composition allows people to access the number of all people living in their country: class Country(object): def __init__(self): self.cities=[] ...
git blame <file> will show the file with each line annotated with the commit that last modified it.
Python has a variety of command-line switches which can be passed to py. These can be found by performing py --help, which gives this output on Python 3.4: Python Launcher usage: py [ launcher-arguments ] [ python-arguments ] script [ script-arguments ] Launcher arguments: -2 : Launch ...
The bisect command helps you to track down the changeset that introduced a bug. Reset the bisect state and mark the current revision as bad (it contains the bug!) hg bisect --reset hg bisect --bad Go back to a point where you think the bug isn't present hg update -r -200 Now...
Demo HTML <script type="x-template" id="form-template"> <label>{{inputLabel}} :</label> <input type="text" v-model="name" /> </script> <div id="app"> <h2>{{appName}}</h2> <form-co...
Future<Results> costlyQuery() { var completer = new Completer(); database.query("SELECT * FROM giant_table", (results) { // when complete completer.complete(results); }, (error) { completer.completeException(error); }); // this returns essentially im...
Components in Vue are like widgets. They allow us to write reusable custom elements with desired behavior. They are nothing but objects which can contain any/all of the options that the root or any Vue instance can contain, including an HTML template to render. Components consist of: HTML marku...
The command prompt comes pre-installed on all Windows NT, Windows CE, OS/2 and eComStation operating systems, and exists as cmd.exe, typically located in C:\Windows\system32\cmd.exe On Windows 7 the fastest ways to open the command prompt are: Press , type "cmd" and then press Enter....
GridViews allow commands to be sent from a GridView row. This is useful for passing row-specific information into an event handler as command arguments. To subscribe to a command event: <asp:GridView ID="GridView1" ... OnRowCommand="GridView1_RowCommand"> Buttons are t...
unsigned char a = 234; // 1110 1010b (0xEA) unsigned char b = ~a; // 0001 0101b (0x15) std::cout << "a = " << static_cast<int>(a) << ", b = " << static_cast<int>(b) << std::endl; Output a = 234, b = 21 Why A b...
Introduction The GNU Make (styled make) is a program dedicated to the automation of executing shell commands. GNU Make is one specific program that falls under the Make family. Make remains popular among Unix-like and POSIX-like operating systems, including those derived from the Linux kernel, Mac ...
1. Target a device by serial number Use the -s option followed by a device name to select on which device the adb command should run. The -s options should be first in line, before the command. adb -s <device> <command> Example: adb devices List of devices attached emulator-55...
In many other languages, if you run the following (Java example) if("asgdsrf" == 0) { //do stuff } ... you'll get an error. You can't just go comparing strings to integers like that. In Python, this is a perfectly legal statement - it'll just resolve to False. A common gotcha ...
<div tabindex="2">Second</div> <div tabindex="1">First</div> Positive values will insert the element at the tabbing order position of its respective value. Elements without preference (i.e. tabindex="0" or native elements such as button and a...
Let's add a custom operator to multiply a CGSize func *(lhs: CGFloat, rhs: CGSize) -> CGSize{ let height = lhs*rhs.height let width = lhs*rhs.width return CGSize(width: width, height: height) } Now this works let sizeA = CGSize(height:100, width:200) let sizeB = 1.1 * si...
Floating point types (float, double and long double) cannot precisely represent some numbers because they have finite precision and represent the values in a binary format. Just like we have repeating decimals in base 10 for fractions such as 1/3, there are fractions that cannot be represented fini...
Components are simply instances that implement the Ashley component class. import com.badlogic.ashley.core.Component; import com.badlogic.ashley.core.ComponentMapper; public class Position implements Component { public static final ComponentMapper<Position> Map = ...
Like lists and tuples, you can include a trailing comma in your dictionary. role = {"By day": "A typical programmer", "By night": "Still a typical programmer", } PEP 8 dictates that you should leave a space between the trailing comma and the closi...
the timedelta module comes in handy to compute differences between times: from datetime import datetime, timedelta now = datetime.now() then = datetime(2016, 5, 23) # datetime.datetime(2016, 05, 23, 0, 0, 0) Specifying time is optional when creating a new datetime object delta = now-then ...
Even though Python natively supports big integers, taking the nth root of very large numbers can fail in Python. x = 2 ** 100 cube = x ** 3 root = cube ** (1.0 / 3) OverflowError: long int too large to convert to float When dealing with such large integers, you will need to use a custom f...

Page 14 of 65