Tutorial by Examples: and

3 You can use rem defined by the font-size of your html tag to style elements by setting their font-size to a value of rem and use em inside the element to create elements that scale with your global font-size. HTML: <input type="button" value="Button"> <input type=...
This is a minimalist Hello World example that uses only the most basic Android tools. Requirements and assumptions Oracle JDK 1.7 or later Android SDK Tools (just the command line tools) This example assumes Linux. You may have to adjust the syntax for your own platform. Setting up the And...
Node.js has 3 basic ways to handle exceptions/errors: try-catch block error as the first argument to a callback emit an error event using eventEmitter try-catch is used to catch the exceptions thrown from the synchronous code execution. If the caller (or the caller's caller, ...) used try/ca...
Screen shot: Option 1 (pure adb) The shell adb command allows us to execute commands using a device's built-in shell. The screencap shell command captures the content currently visible on a device and saves it into a given image file, e.g. /sdcard/screen.png: adb shell screencap /sdcard/screen.png...
You may want to nest cached fragments inside other cached fragments. This is called Russian doll caching. The advantage of Russian doll caching is that if a single product is updated, all the other inner fragments can be reused when regenerating the outer fragment. As explained in the previous sec...
A has_and_belongs_to_many association creates a direct many-to-many connection with another model, with no intervening model. For example, if your application includes assemblies and parts, with each assembly having many parts and each part appearing in many assemblies, you could declare the models...
Rails have very easy way to get first and last record from database. To get the first record from users table we need to type following command: User.first It will generate following sql query: SELECT `users`.* FROM `users` ORDER BY `users`.`id` ASC LIMIT 1 And will return following recor...
GCD will guarantee that your singleton only gets instantiated once, even if called from multiple threads. Insert this into any class for a singleton instance called shared. + (instancetype)shared { // Variable that will point to the singleton instance. The `static` // modifier makes it ...
The Java language provides 4 operators that perform bitwise or logical operations on integer or boolean operands. The complement (~) operator is a unary operator that performs a bitwise or logical inversion of the bits of one operand; see JLS 15.15.5.. The AND (&) operator is a binary operat...
The following examples can be tested on https://ellie-app.com/m9vmQ8NcMc/0. import Html exposing (..) import Json.Decode payload = """ [ { "bark": true, "tag": "dog", "name": "Zap", "playful": true } , { "w...
The map operation is a useful tool when working with arrays and vectors, but it can also be used to deal with Option values in a functional way. fn main() { // We start with an Option value (Option<i32> in this case). let some_number = Some(9); // Let's do some consecutive ...
Circle To create a circle, define an element with an equal width and height (a square) and then set the border-radius property of this element to 50%. HTML <div class="circle"></div> CSS .circle { width: 50px; height: 50px; background: rgb(246, 156, 85); ...
A closure can be defined with a typealias. This provides a convenient type placeholder if the same closure signature is used in multiple places. For example, common network request callbacks or user interface event handlers make great candidates for being "named" with a type alias. public...
In most cases you want to define several border properties (border-width, border-style and border-color) for all sides of an element. Instead of writing: border-width: 1px; border-style: solid; border-color: #000; You can simply write: border: 1px solid #000; These shorthands are also ava...
Changing some CSS attribute will trigger the browser to synchronously calculate the style and layout, which is a bad thing when you need to animate at 60fps. DON'T Animate with left and top trigger layout. #box { left: 0; top: 0; transition: left 0.5s, top 0.5s; position: absolute; ...
import random probability = 0.3 if random.random() < probability: print("Decision with probability 0.3") else: print("Decision with probability 0.7")
A subprogram (which defines a procedure), can be either a subroutine or a function; it is said to be an internal subprogram if it is called or invoked from the same program or subprogram that contains it, as follows program my_program ! declarations ! executable statements, ! among which...
A subprogram is said to be external when it is not contained in the main program, nor in a module or antoher subprogram. In particular it can be defined by means of a programming language other than Fortran. When an external subprogram is invoked, the compiler cannot access to its code, so all the ...
When an exception is thrown from within a Future, you can (should) use recover to handle it. For instance, def runFuture: Future = Future { throw new FairlyStupidException } val itWillBeAwesome: Future = runFuture ...will throw an Exception from within the Future. But seeing as we can predic...
If the file does not contain a header row, File: 1;str_data;12;1.4 3;str_data;22;42.33 4;str_data;2;3.44 2;str_data;43;43.34 7; str_data; 25; 23.32 you can use the keyword names to provide column names: df = pandas.read_csv('data_file.csv', sep=';', index_col=0, ski...

Page 40 of 153