Tutorial by Examples: f

To make a Haskell program executable you must provide a file with a main function of type IO () main :: IO () main = putStrLn "Hello world!" When Haskell is compiled it examines the IO data here and turns it into a executable. When we run this program it will print Hello world!. If y...
Output some information about a known remote: origin git remote show origin Print just the remote's URL: git config --get remote.origin.url With 2.7+, it is also possible to do, which is arguably better than the above one that uses the config command. git remote get-url origin
The static method Date.now returns the number of milliseconds that have elapsed since 1 January 1970 00:00:00 UTC. To get the number of milliseconds that have elapsed since that time using an instance of a Date object, use its getTime method. // get milliseconds using static method now of Date co...
In a Service Provider register method we can bind an interface to an implementation: public function register() { App::bind( UserRepositoryInterface::class, EloquentUserRepository::class ); } From now on, everytime the app will need an instance of UserRepositoryInterface, Larave...
from pandas_datareader import data # Only get the adjusted close. aapl = data.DataReader("AAPL", start='2015-1-1', end='2015-12-31', data_source='yahoo')['Adj Close'] >>> aapl.plot(title='AAPL Adj. C...
chrome.runtime.getManifest() returns the extension's manifest in a form of a parsed object. This method works both on content scripts and all extension pages, it requires no permissions, Example, obtaining the extension's version string: var version = chrome.runtime.getManifest().version;
Using the Control.Invoke() method you may move the execution of a method or function from a background thread to the thread that the control was created on, which is usually the UI (User Interface) thread. By doing so your code will be queued to run on the control's thread instead, which removes the...
# no error, even the subscript is out of range. julia> sub2ind((3,3), 3, 4) 12 One cannot determine whether a subscript is in the range of an array by comparing its index: julia> sub2ind((3,3), -1, 2) 2 julia> 0 < sub2ind((3,3), -1, 2) <= 9 true
The default namespace is the namespace corresponding to the absence of any prefix. It can be declared with the special xmlns attribute. <?xml version="1.0"?> <foo xmlns="http://www.example.com/my-namespace"> <!-- the element foo is in the namespace htt...
Elements and attributes behave differently with respect to default namespaces. This is often the source of confusion. An attribute whose name has no prefix lives in no namespace, also when a default namespace is in scope. <?xml version="1.0"?> <foo attr="value" xmlns=...
A namespace binding (special xmlns or xmlns:... attribute) is in scope for all the descendants of the enclosing element, including this element. <?xml version="1.0"?> <root> <my:element xmlns:my="http://www.example.com/ns1"> <!-- here, the prefix my...
C++11 Deriving a class may be forbidden with final specifier. Let's declare a final class: class A final { }; Now any attempt to subclass it will cause a compilation error: // Compilation error: cannot derive from final class: class B : public A { }; Final class may appear anywhere in cl...
You should use caution when using setState in an asynchronous context. For example, you might try to call setState in the callback of a get request: class MyClass extends React.Component { constructor() { super(); this.state = { user: {} }; } ...
Stateless components are getting their philosophy from functional programming. Which implies that: A function returns all time the same thing exactly on what is given to it. For example: const statelessSum = (a, b) => a + b; let a = 0; const statefulSum = () => a++; As you can see fro...
Recursion occurs when a function call causes that same function to be called again before the original function call terminates. For example, consider the well-known mathematical expression x! (i.e. the factorial operation). The factorial operation is defined for all nonnegative integers as follows:...
1) Use ng-repeat sparingly Using ng-repeat in views generally results in poor performance, particularly when there are nested ng-repeat's. This is super slow! <div ng-repeat="user in userCollection"> <div ng-repeat="details in user"> {{details}} </div...
First define the service (in this case it uses the factory pattern): .factory('dataService', function() { var dataObject = {}; var service = { // define the getter method get data() { return dataObject; }, // define the setter method ...
updateState by key can be used to create a stateful DStream based on upcoming data. It requires a function: object UpdateStateFunctions { def updateState(current: Seq[Double], previous: Option[StatCounter]) = { previous.map(s => s.merge(current)).orElse(Some(StatCounter(current))) } ...
mapWithState, similarly to updateState, can be used to create a stateful DStream based on upcoming data. It requires StateSpec: import org.apache.spark.streaming._ object StatefulStats { val state = StateSpec.function( (key: String, current: Option[Double], state: State[StatCounter]) =&g...
/** * @param n Number to be rounded. * @param precision Decimal places. * @return Rounded Number */ function roundDecimal(n:Number, precision:Number):Number { var factor:int = Math.pow(10, precision); return (Math.round(n * factor) / factor); } Examples: trace(0.9 - 1); // -0...

Page 75 of 457