Tutorial by Examples: c

Transform tr = GetComponent<Transform>().Find("NameOfTheObject"); GameObject go = tr.gameObject; Find returns null if none is found ProsConsLimited, well defined search scopeStrings are weak references
Like normal HTML elements, it is possible for $scopes to have their own events. $scope events can be subscribed to using the following manner: $scope.$on('my-event', function(event, args) { console.log(args); // { custom: 'data' } }); If you need unregister an event listener, the $on func...
ALTER TABLE fish_data.fish DROP PRIMARY KEY; ALTER TABLE fish_data.fish MODIFY COLUMN fish_id DECIMAL(20,0) NOT NULL PRIMARY KEY; An attempt to modify the type of this column without first dropping the primary key would result in an error.
Formatting a JavaScript date in modern browsers In modern browsers (*), Date.prototype.toLocaleDateString() allows you to define the formatting of a Date in a convenient manner. It requires the following format : dateObj.toLocaleDateString([locales [, options]]) The locales parameter should be...
It is good practice to combine JS files together and minify them. For larger project there could be hundreds of JS files and it adds unnecessary latency to load each file separately from the server. For angular minification it is required to to have all functions annotated. That in necessary for An...
Sometimes it's useful to be able to extend a class with new functions. For example let's suppose that a string should be converted to a camel case string. So we need to tell TypeScript, that String contains a function called toCamelCase, which returns a string. interface String { toCamelCase()...
In explicit wait, you expect for a condition to happen. For example you want to wait until an element is clickable. Here is a demonstration of a few common problems. Please note: In all of these examples you can use any By as a locator, such as classname, xpath, link text, tag name or cssSelector ...
In Racket, we use recursion very frequently. Here is an example of a function that sums all of the numbers from zero to the parameter, n. (define (sum n) (if (zero? n) 0 (+ n (sum (sub1 n))))) Note that there are many helpful convenience based functions used here, such as ...
# list gem sources: gem sources -l # remove default gem source: gem sources -r https://rubygems.org/ # add other gem sources: gem sources -a https://ruby.taobao.org/
Overall the easiest way to work with JSON is to have a case class mapping directly to the JSON (same fields name, equivalent types, etc.). case class Person( name: String, age: Int, hobbies: Seq[String], pet: Pet ) case class Pet( name: String, `type`: String ) // these...
It is very easy to pass information between threads using the MVar a type and its accompanying functions in Control.Concurrent: newEmptyMVar :: IO (MVar a) -- creates a new MVar a newMVar :: a -> IO (MVar a) -- creates a new MVar with the given value takeMVar :: MVar a -> IO a -- retrieve...
Summary: MVVM is an architectural pattern that is represented by three distinct components, the Model, View and ViewModel. In order to understand these three layers, it is necessary to briefly define each, followed by an explanation of how they work together. Model is the layer that drives the bus...
In VBA, Strings can be declared with a specific length; they are automatically padded or truncated to maintain that length as declared. Public Sub TwoTypesOfStrings() Dim FixedLengthString As String * 5 ' declares a string of 5 characters Dim NormalString As String Debug.Print Fi...
The JavaScript coding convention is to place the starting bracket of blocks on the same line of their declaration: if (...) { } function (a, b, ...) { } Instead of in the next line: if (...) { } function (a, b, ...) { } This has been adopted to avoid semicolon insertion ...
The practice of replacing an object with a test double that verifies expectations, for instance asserting that a method has been called, is referred to as mocking. Lets assume we have SomeService to test. class SomeService { private $repository; public function __construct(Repository $r...
Since arrays are reference types, it is possible to have multiple variables pointing to the same array object. Dim array1() As Integer = {1, 2, 3} Dim array2() As Integer = array1 array1(0) = 4 Console.WriteLine(String.Join(", ", array2)) ' Writes "4, 2, 3"
If we want to replace only the first occurrence in a line, we use sed as usual: $ cat example aaaaabbbbb aaaaaccccc aaaaaddddd $ sed 's/a/x/' example xaaaabbbbb xaaaaccccc xaaaaddddd But what if we want to replace all occurrences? We just add the g pattern flag at the end: $ sed 's/a/x/...
A form gives the user a way to change data in your application, in a structured way. To mutate a simple array of data, we create a form using a form builder: use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\F...
A custom form type is a class which defines a reusable form component. Custom form components can be nested to create complicated forms. Instead of creating a form in the controller using a form builder, you can use your own type to make the code more readable, reusable and maintanable. Create a c...
manifest.json { "name": "Hello Page", "description": "Add 'Hello' to the current page.", "version": "1.0", "permissions": [ "activeTab" ], "background": { "scripts": [&quo...

Page 371 of 826