Tutorial by Examples: er

Array References are scalars ($) which refer to Arrays. my @array = ("Hello"); # Creating array, assigning value from a list my $array_reference = \@array; These can be created more short-hand as follows: my $other_array_reference = ["Hello"]; Modifying / Using array ref...
The URLRequestMethod class contains constants for the various request types you can make. These constants are to be allocated to URLRequest's method property: var request:URLRequest = new URLRequest('http://someservice.com'); request.method = URLRequestMethod.POST; Note that only GET and POST...
If you need to roll for a true or false in an "x% chance" situation, use: function roll(chance:Number):Boolean { return Math.random() >= chance; } Used like: var success:Boolean = roll(0.5); // True 50% of the time. var again:Boolean = roll(0.25); // True 25% of the time. ...
Value Type (where T : struct) The built-in primitive data types, such as char, int, and float, as well as user-defined types declared with struct, or enum. Their default value is new T() : default(int) // 0 default(DateTime) // 0001-01-01 12:00:00 AM default(char) // '...
2.2 func removeCharactersNotInSetFromText(text: String, set: Set<Character>) -> String { return String(text.characters.filter { set.contains( $0) }) } let text = "Swift 3.0 Come Out" var chars = Set([Character]("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLKMNOPQRSTUVWXYZ&...
The first step in optimizing for speed is finding the slowest sections of code. The Timer VBA function returns the number of seconds elapsed since midnight with a precision of 1/256th of a second (3.90625 milliseconds) on Windows based PCs. The VBA functions Now and Time are only accurate to a secon...
std::sort, found in the standard library header algorithm, is a standard library algorithm for sorting a range of values, defined by a pair of iterators. std::sort takes as the last parameter a functor used to compare two values; this is how it determines the order. Note that std::sort is not stable...
A series is a one-dimension data structure. It's a bit like a supercharged array, or a dictionary. import pandas as pd s = pd.Series([10, 20, 30]) >>> s 0 10 1 20 2 30 dtype: int64 Every value in a series has an index. By default, the indices are integers, running fro...
function isEven(n:Number):Boolean { return ((n & 1) == 0); } Examples: isEven(1); // false isEven(2); // true isEven(1.1); // false isEven(1.2); // false isEven(2.1); // true isEven(2.2); // true
function isOdd(n:Number):Boolean { return ((n & 1) == 1); } Examples: isOdd(1); // true isOdd(2); // false isOdd(1.1); // true isOdd(1.2); // true isOdd(2.1); // false isOdd(2.2); // false
Imagine the following XML: <root> <element>hello</element> <another> hello </another> <example>Hello, <nested> I am an example </nested>.</example> </root> The following XPath expression: //*[text() = 'hel...
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...
We can bind a class as a Singleton: public function register() { App::singleton('my-database', function() { return new Database(); }); } This way, the first time an instance of 'my-database' will be requested to the service container, a new instance will be created. Al...
Solution 1: $('#parent').prepend($('#child')); Solution 2: $('#child').prependTo($('#parent')); Both solutions are prepending the element #child (adding at the beginning) to the element #parent. Before: <div id="parent"> <span>other content</span> </di...
Solution 1: $('#parent').append($('#child')); Solution 2: $('#child').appendTo($('#parent')); Both solutions are appending the element #child (adding at the end) to the element #parent. Before: <div id="parent"> <span>other content</span> </div> <d...
Equality For basic equality testing, the equal operator == is used. For more comprehensive checks, use the identical operator ===. The identical operator works the same as the equal operator, requiring its operands have the same value, but also requires them to have the same data type. For exampl...
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...
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...
julia> sub2ind((3,3), 1, 1) 1 julia> sub2ind((3,3), 1, 2) 4 julia> sub2ind((3,3), 2, 1) 2 julia> sub2ind((3,3), [1,1,2], [1,2,1]) 3-element Array{Int64,1}: 1 4 2

Page 74 of 417