Tutorial by Examples

To remove an attribute from an element you can use the function .removeAttr(attributeName). For example: $('#home').removeAttr('title'); This will remove title attribute from the element with ID home.
attr() gets/sets the HTML attribute using the DOM functions getAttribute() and setAttribute(). prop() works by setting the DOM property without changing the attribute. In many cases the two are interchangeable, but occasionally one is needed over the other. To set a checkbox as checked: $('#tosAcc...
$q is a built-in service which helps in executing asynchronous functions and using their return values(or exception) when they are finished with processing. $q is integrated with the $rootScope.Scope model observation mechanism, which means faster propagation of resolution or rejection into your m...
(.) lets us compose two functions, feeding output of one as an input to the other: (f . g) x = f (g x) For example, if we want to square the successor of an input number, we can write ((^2) . succ) 1 -- 4 There is also (<<<) which is an alias to (.). So, (+ 1) <<&lt...
Control.Category defines (>>>), which, when specialized to functions, is -- (>>>) :: Category cat => cat a b -> cat b c -> cat a c -- (>>>) :: (->) a b -> (->) b c -> (->) a c -- (>>>) :: (a -> b) -> (b -> c) -> (a -> c...
The ng-pattern directive accepts an expression that evaluates to a regular expression pattern and uses that pattern to validate a textual input. Example: Lets say we want an <input> element to become valid when it's value (ng-model) is a valid IP address. Template: <input type="tex...
The angular.identity function returns the first argument passed to it. angular.identity(argument) This function is useful for functional programming, you can provide this function as a default in case an expected function was not passed. Examples: angular.identity(42) // 42 var mutate = f...
The angular.forEach accepts an object and an iterator function. It then runs the iterator function over each enumerable property/value of the object. This function also works on arrays. Like the JS version of Array.prototype.forEach The function does not iterate over inherited properties (prototype...
Google App scripts are of three types. Standalone Bound to Google Apps Web Apps Standalone script Standalone scripts are not bound to any Google apps i.e Docs, Sheets or Forms etc. Standalone script can either be created by visiting script.google.com or by connecting Google app script with ...
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
#include <stdio.h> #include <threads.h> #include <stdlib.h> struct my_thread_data { double factor; }; int my_thread_func(void* a) { struct my_thread_data* d = a; // do something with d printf("we found %g\n", d->factor); // return an succes...
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.
In Insert mode, press <C-r> and then % to insert the filename. This technique is applicable to all registers. For e.g. if in insert mode, you want to paste the current search pattern, you can type <C-r> and then /.
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...

Map

Map applies a function to every element of a list: map: (a -> b) (listof a) -> (listof b) > (map (lambda (x) (* x 2)) (list 1 2 3 4 5) (list 2 4 6 8 10) > (map sqrt (list 1 4 9)) (list 1 2 3) > (map (lambda (x) (if (even? x) "even" "odd")) (list 1 2 3))...
Fold Right successively applies a two-argument function to every element in a list from left to right starting with a base value: foldr: (a b -> b) b (listof a) -> b > (foldr + 0 (list 1 2 3 4)) 10 > (foldr string-append "" (list "h" "e" "l&quot...
When the first time view is requested, normally Angular makes XHR request to get that view. For mid-size projects, the view count can be significant and it can slow down the application responsiveness. The good practice is to pre-load all the views at once for small and mid size projects. For large...
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()...

Page 597 of 1336