Tutorial by Examples: ti

// get some data from stackoverflow fetch("https://api.stackexchange.com/2.2/questions/featured?order=desc&sort=activity&site=stackoverflow") .then(resp => resp.json()) .then(json => console.log(json)) .catch(err => console.log(err));
Here is a full Activity class that places a Marker at the current location, and also moves the camera to the current position. There are a few thing going on in sequence here: Check Location permission Once Location permission is granted, call setMyLocationEnabled(), build the GoogleApiClient, ...
Following the logs is the less intrusive way to debug a live running application. This example reproduces the behavior of the traditional tail -f some-application.log on container 7786807d8084. docker logs --follow --tail 10 7786807d8084 This command basically shows the standard output of the co...
In this example, 2.13.2 is the latest version. We install it via bower, specifying the particular version as ember#2.13.2 and including the save flag to persist it to bower.json. As of writing this post the latest version is 2.13.2. From the command line, in the root of your app's directory, run: ...
Since Ember Data is an Ember CLI add-on we can install it just like any other add-on by using ember install. As of writing this post the latest version is 2.13.1. From the command line, in the root of your app's directory, run: ember install [email protected]
Ember CLI is a normal npm package. To update it we have to uninstall it and then install the version we want. As of writing this post the latest version is 2.13.2. From the command line run: npm uninstall -g ember-cli npm cache clean bower cache clean npm install -g [email protected] To verif...
public class Foo { private IBar _iBar; public IBar iBar { set { _iBar = value; } } public void DoStuff() { _iBar.DoSomething(); } } public interface IBar { void DoSomething(); }
public class Foo { private readonly IBar _iBar; public Foo(IBar iBar) { _iBar = iBar; } public void DoStuff() { _bar.DoSomething(); } } public interface IBar { void DoSomething(); }
Sometimes you want to do something with the exception you catch (like write to log or print a warning) and let it bubble up to the upper scope to be handled. To do so, you can rethrow any exception you catch: try { ... // some code here } catch (const SomeException& e) { std::cout &l...
A static class is lazily initialized on member access and lives for the duration of the application domain. void Main() { Console.WriteLine("Static classes are lazily initialized"); Console.WriteLine("The static constructor is only invoked when the class is first accessed&...
import pandas as pd import numpy as np np.random.seed(123) x = np.random.standard_normal(4) y = range(4) df = pd.DataFrame({'X':x, 'Y':y}) >>> df X Y 0 -1.085631 0 1 0.997345 1 2 0.282978 2 3 -1.506295 3
By default, all types in TypeScript allow null: function getId(x: Element) { return x.id; } getId(null); // TypeScript does not complain, but this is a runtime error. TypeScript 2.0 adds support for strict null checks. If you set --strictNullChecks when running tsc (or set this flag in you...
val num = 42d Print two decimal places for num using f println(f"$num%2.2f") 42.00 Print num using scientific notation using e println(f"$num%e") 4.200000e+01 Print num in hexadecimal with a println(f"$num%a") 0x1.5p5 Other format strings can be found ...
if ([object respondsToSelector:@selector(someOptionalMethodInProtocol:)]) { [object someOptionalMethodInProtocol:argument]; }
Oracle's CONNECT BY functionality provides many useful and nontrivial features that are not built-in when using SQL standard recursive CTEs. This example replicates these features (with a few additions for sake of completeness), using SQL Server syntax. It is most useful for Oracle developers findin...
Deleting files The unlink function deletes a single file and returns whether the operation was successful. $filename = '/path/to/file.txt'; if (file_exists($filename)) { $success = unlink($filename); if (!$success) { throw new Exception("Cannot delete $filename&qu...
for typescript 2.x: definitions from DefinitelyTyped are available via @types npm package npm i --save lodash npm i --save-dev @types/lodash but in case if you want use types from other repos then can be used old way: for typescript 1.x: Typings is an npm package that can automatically insta...
In Swift, we can exponentiate Doubles with the built-in pow() method: pow(BASE, EXPONENT) In the code below, the base (5) is set to the power of the exponent (2) : let number = pow(5.0, 2.0) // Equals 25
Any data structure that supports __getitem__ can have their nested structure formatted: person = {'first': 'Arthur', 'last': 'Dent'} '{p[first]} {p[last]}'.format(p=person) # 'Arthur Dent' Object attributes can be accessed using getattr(): class Person(object): first = 'Zaphod' la...
Lambda functions in C++ are syntactic sugar that provide a very concise syntax for writing functors. As such, equivalent functionality can be obtained in C++03 (albeit much more verbose) by converting the lambda function into a functor: // Some dummy types: struct T1 {int dummy;}; struct T2 {int ...

Page 83 of 505