Tutorial by Examples

Suppose we want to receive a function as a parameter, we can do it like this: function foo(otherFunc: Function): void { ... } If we want to receive a constructor as a parameter: function foo(constructorFunc: { new() }) { new constructorFunc(); } function foo(constructorWithParams...
The current version of JQuery Mobile is 1.4.5 and can be downloaded here: https://jquerymobile.com/ Download the zip file and extract all files. Create a library (or lib) folder inside of your application (inside the www folder). Create a jquery-mobile folder inside the lib folder (I've named ...
local Class = {} -- objects and classes will be tables local __meta = {__index = Class} -- ^ if an instance doesn't have a field, try indexing the class function Class.new() -- return setmetatable({}, __meta) -- this is shorter and equivalent to: local new_instance = {} setmetatabl...
The internal keyword is an access modifier for types and type members. Internal types or members are accessible only within files in the same assembly usage: public class BaseClass { // Only accessible within the same assembly internal static int x = 0; } The difference between dif...
bsort :: Ord a => [a] -> [a] bsort s = case bsort' s of t | t == s -> t | otherwise -> bsort t where bsort' (x:x2:xs) | x > x2 = x2:(bsort' (x:xs)) | otherwise = x:(bsort' (x2:xs)) bsort' s = s
The type constructor for lists in the Haskell Prelude is []. The type declaration for a list holding values of type Int is written as follows: xs :: [Int] -- or equivalently, but less conveniently, xs :: [] Int Lists in Haskell are homogeneous sequences, which is to say that all elements mus...
To process lists, we can simply pattern match on the constructors of the list type: listSum :: [Int] -> Int listSum [] = 0 listSum (x:xs) = x + listSum xs We can match more values by specifying a more elaborate pattern: sumTwoPer :: [Int] -> Int sumTwoPer [] = 0 sumTwoPer (x1...
pip doesn't current contain a flag to allow a user to update all outdated packages in one shot. However, this can be accomplished by piping commands together in a Linux environment: pip list --outdated --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U This command takes all pa...
pip doesn't current contain a flag to allow a user to update all outdated packages in one shot. However, this can be accomplished by piping commands together in a Windows environment: for /F "delims= " %i in ('pip list --outdated --local') do pip install -U %i This command takes all pa...
pip assists in creating requirements.txt files by providing the freeze option. pip freeze > requirements.txt This will save a list of all packages and their version installed on the system to a file named requirements.txt in the current folder.
pip assists in creating requirements.txt files by providing the freeze option. pip freeze --local > requirements.txt The --local parameter will only output a list of packages and versions that are installed locally to a virtualenv. Global packages will not be listed.
Class composition allows explicit relations between objects. In this example, people live in cities that belong to countries. Composition allows people to access the number of all people living in their country: class Country(object): def __init__(self): self.cities=[] ...
Access the nth element of a list (zero-based): list = [1 .. 10] firstElement = list !! 0 -- 1 Note that !! is a partial function, so certain inputs produce errors: list !! (-1) -- *** Exception: Prelude.!!: negative index list !! 1000 -- *** Exception: Prelude.!!: inde...
To make artisan migrate a fresh database before running tests, use DatabaseMigrations. Also if you want to avoid middleware like Auth, use WithoutMiddleware. <?php use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\DatabaseMigrations; class ExampleTest ...
The steps of overload resolution are: Find candidate functions via name lookup. Unqualified calls will perform both regular unqualified lookup as well as argument-dependent lookup (if applicable). Filter the set of candidate functions to a set of viable functions. A viable function for whi...
really_neat.info name = Really Neat Module description = Provides a really neat page for your site core = 7.x really_neat.module <?php /** * @file * Hook implementation and shared functions for the Really Neat Module. */ /** * Implements hook_menu(). */ function really_nea...
Recursion can be defined as: A method that calls itself until a specific condition is met. An excellent and simple example of recursion is a method that will get the factorial of a given number: public int Factorial(int number) { return number == 0 ? 1 : n * Factorial(number - 1); } ...
In the timeline of any DisplayObject that is attached as a descendant of the display tree, you can utilise the root property. This property points to the main timeline in the case of no custom document class, or the document class if you do define one. Because root is typed DisplayObject, the compi...
Enums are iterable: class Color(Enum): red = 1 green = 2 blue = 3 [c for c in Color] # [<Color.red: 1>, <Color.green: 2>, <Color.blue: 3>]
The jsonlite package is a fast JSON parser and generator optimized for statistical data and the web. The two main functions used to read and write JSON are fromJSON() and toJSON() respecitively, and are designed to work with vectors, matrices and data.frames, and streams of JSON from the web. Creat...

Page 306 of 1336