Tutorial by Examples: ti

Optional Parameters In TypeScript, every parameter is assumed to be required by the function. You can add a ? at the end of a parameter name to set it as optional. For example, the lastName parameter of this function is optional: function buildName(firstName: string, lastName?: string) { // ...
Boolean(...) will convert any data type into either true or false. Boolean("true") === true Boolean("false") === true Boolean(-1) === true Boolean(1) === true Boolean(0) === false Boolean("") === false Boolean("1") === true Boolean("0") === t...
In themes.xml: <style name="MyActivityTheme" parent="Theme.AppCompat"> <!-- Theme attributes here --> </style> In AndroidManifest.xml: <application android:icon="@mipmap/ic_launcher" android:label="@string/app_name" ...
Have required JavaScript and CSS files included in your index.html. You can do this by either using the CDN files availiable at the following paths: <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.12/css/jquery.dataTables.css"> <scr...
Channels are often used to implement timeouts. func main() { // Create a buffered channel to prevent a goroutine leak. The buffer // ensures that the goroutine below can eventually terminate, even if // the timeout is met. Without the buffer, the send on the channel // blocks fo...
Using the Android API 23 or higher, very often such situation can be seen: This situation is caused by the structural change of the Android API regarding getting the resources. Now the function: public int getColor(@ColorRes int id, @Nullable Theme theme) throws NotFoundException should ...
You can mix normal parameters and parameter arrays: public class LotteryTicket : IEnumerable{ public int[] LuckyNumbers; public string UserName; public void Add(string userName, params int[] luckyNumbers){ UserName = userName; Lottery = luckyNumbers; } } ...
package main import ( "log" "sync" "time" ) func main() { // The WaitGroup lets the main goroutine wait for all other goroutines // to terminate. However, this is no implicit in Go. The WaitGroup must // be explicitely incremented pr...
package main import ( "fmt" "time" ) // The pinger prints a ping and waits for a pong func pinger(pinger <-chan int, ponger chan<- int) { for { <-pinger fmt.Println("ping") time.Sleep(time.Second) ponge...
Operators such as +, -, ?? are a kind of function named using symbols rather than letters. They are invoked differently from functions: Prefix: -x Infix: x + y Postfix: x++ You can read more about basic operators and advanced operators in The Swift Programming Language.
MediaPlayer class can be used to control playback of audio/video files and streams. Creation of MediaPlayer object can be of three types: Media from local resource MediaPlayer mediaPlayer = MediaPlayer.create(context, R.raw.resource); mediaPlayer.start(); // no need to call prepare(); create...
Package can have init methods which are run only once before main. package usefull func init() { // init code } If you just want to run the package initialization without referencing anything from it use the following import expression. import _ "usefull"
Directives comes with the AngularJS library itself. A sample directive can be created as: angular.module('simpleDirective', []) .directive('helloData', function() { return { template: 'Hello, {{data}}' }; }); And can be used as: JS: angular.module('app', ['simpleDirective']) .con...
You can install Json.Net into your Visual Studio Project in 1 of 2 ways. Install Json.Net using the Package Manager Console. Open the Package Manager Console window in Visual Studio either by typing package manager console in the Quick Launch box and selecting it or by clicking View -> O...
The ROUND function rounds a value. The number of decimal places to round to is specified by a positive value in the num_digits parameter. A negative value for the num_digits will round the integer portion of the value left of the decimal point, e.g. to the nearest 10 (for -1) or to the nearest 1000 ...
The excel formula TRUNC is used to truncate a number to a given number of decimal places, specified by the optional num_digits parameter. If this parameter is defined as a negative value it will truncate the integer portion of the value. If the parameter is omitted then the default value is 0 which ...
The Excel function MROUND is used to round a number to an interval other than a power of 10. These examples show MROUND to the nearest quarter and to the nearest even number. Starting withMROUND(b,0.25)MROUND(b,2)23.9319521124.00242.7931353882.75221.9390306422.002213.7419373913.751416.7704741216.7...
You need to find out the IP address of the container running in the host so you can, for example, connect to the web server running in it. docker-machine is what is used on MacOSX and Windows. Firstly, list your machines: $ docker-machine ls NAME ACTIVE DRIVER STATE URL ...
Helpful when you want to grab a copy of a production database to play around with locally. mongodump --host some-mongo-host.com:1234 -d DATABASE_NAME -u DATABASE_USER -p DATABASE_PASSWORD This will create a local dump directory; within that directory you'll see a directory with your DATABASE_NAME...
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...

Page 89 of 505