Tutorial by Examples: co

A custom component that takes the type of a component as input and creates an instance of that component type inside itself. When the input is updated, the previously added dynamic component is removed and the new one added instead. @Component({ selector: 'dcl-wrapper', template: `<div #...
Concatenate strings with the + operator: s1 = "Hello" s2 = " " s3 = "World" puts s1 + s2 + s3 # => Hello World s = s1 + s2 + s3 puts s # => Hello World Or with the << operator: s = 'Hello' s << ' ' s << 'World' puts s # => ...
With any variadic function, the function must know how to interpret the variable arguments list. With the printf() or scanf() functions, the format string tells the function what to expect. The simplest technique is to pass an explicit count of the other arguments (which are normally all the same ...
angular .module('app') .controller('SampleController', SampleController) SampleController.$inject = ['$log', '$scope']; function SampleController($log, $scope){ $log.debug('*****SampleController******'); /* Your code below */ } Note: The .$inject will make sure your...
There are a couple different ways to protect your controller creation from minification. The first is called inline array annotation. It looks like the following: var app = angular.module('app'); app.controller('sampleController', ['$scope', '$http', function(a, b){ //logic here }]); The...
You may need to convert a Stream emitting Optional to a Stream of values, emitting only values from existing Optional. (ie: without null value and not dealing with Optional.empty()). Optional<String> op1 = Optional.empty(); Optional<String> op2 = Optional.of("Hello World");...
The function php_sapi_name() and the constant PHP_SAPI both return the type of interface (Server API) that is being used by PHP. They can be used to restrict the execution of a script to the command line, by checking whether the output of the function is equal to cli. if (php_sapi_name() === 'cli')...
interface IFoo { } class Foo : IFoo { } class Bar : IFoo { } var item0 = new Foo(); var item1 = new Foo(); var item2 = new Bar(); var item3 = new Bar(); var collection = new IFoo[] { item0, item1, item2, item3 }; Using OfType var foos = collection.OfType<Foo>(); // result: IEnum...
Strings are compared for equality using isEqualToString: The == operator just tests for object identity and does not compare the logical values of objects, so it can't be used: NSString *stringOne = @"example"; NSString *stringTwo = [stringOne mutableCopy]; BOOL objectsAreIdentical =...
There are two ways to connect to a MySQL/MariaDB server, depending on your infrastructure. Standard (TCP/IP) connection $dsn = 'mysql:dbname=demo;host=server;port=3306;charset=utf8'; $connection = new \PDO($dsn, $username, $password); // throw exceptions, when SQL error is caused $connection-...
Given a String: s = "something" there are several ways to convert it to a Symbol: s.to_sym # => :something :"#{s}" # => :something
Given a Symbol: s = :something The simplest way to convert it to a String is by using the Symbol#to_s method: s.to_s # => "something" Another way to do it is by using the Symbol#id2name method which is an alias for the Symbol#to_s method. But it's a method that is unique to the...
UIAlertView and UIActionSheet are Deprecated in iOS 8 and Later. So Apple introduced a new controller for AlertView and ActionSheet called UIAlertController , changing the preferredStyle, you can switch between AlertView and ActionSheet. There is no delegate method for it because all button events a...
If you have a value that never changes in your application, you can define a named constant and use it in place of a literal value. You can use Const only at module or procedure level. This means the declaration context for a variable must be a class, structure, module, procedure, or block, and can...
Rails provides several ways to organize your routes. Scope by URL: scope 'admin' do get 'dashboard', to: 'administration#dashboard' resources 'employees' end This generates the following routes get '/admin/dashboard', to: 'administration#dashboard' post '/admin/empl...
Simple record {-# LANGUAGE TemplateHaskell #-} import Control.Lens data Point = Point { _x :: Float, _y :: Float } makeLenses ''Point Lenses x and y are created. let p = Point 5.0 6.0 p ^. x -- returns 5.0 set x 10 p -- returns Point { _x = 10.0, _y = 6.0 } p & x +~ ...
Consider we have a class Animal which has a child class Dog class Animal { public Animal() { Console.WriteLine("In Animal's constructor"); } } class Dog : Animal { public Dog() { Console.WriteLine("In Dog's constructor"); } ...
select LastName, FirstName, from Person Returns message: Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from Person' at line 2. Getting a "1064 error" message from MySQL mean...
// decode NSString *string = [[NSString alloc] initWithData:utf8Data encoding:NSUTF8StringEncoding]; // encode NSData *utf8Data = [string dataUsingEncoding:NSUTF8StringEncoding]; Some supported encodings are: NSASCIIStringEncoding NSUTF8StringEnc...
In this example, we will look at a method for returning the last non-empty row in a column for a data set. This method will work regardless of empty regions within the data set. However caution should be used if merged cells are involved, as the End method will be "stopped" against a mer...

Page 20 of 248