Tutorial by Examples: ect

5.2 Objects in lua are garbage collected. Sometimes, you need to free some resource, want to print a message or do something else when an object is destroyed (collected). For this, you can use the __gc metamethod, which gets called with the object as argument when the object is destroyed. You could...
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...
Support vector machines is a family of algorithms attempting to pass a (possibly high-dimension) hyperplane between two labelled sets of points, such that the distance of the points from the plane is optimal in some sense. SVMs can be used for classification or regression (corresponding to sklearn.s...
One of the uses of recursion is to navigate through a hierarchical data structure, like a file system directory tree, without knowing how many levels the tree has or the number of objects on each level. In this example, you will see how to use recursion on a directory tree to find all sub-directorie...
While RODBC is restricted to Windows computers with compatible architecture between R and any target RDMS, one of its key flexibilities is to work with Excel files as if they were SQL databases. require(RODBC) con = odbcConnectExcel("myfile.xlsx") # open a connection to the Excel file s...
The Python console adds a new function, help, which can be used to get information about a function or object. For a function, help prints its signature (arguments) and its docstring, if the function has one. >>> help(print) Help on built-in function print in module builtins: print(.....
In this example a custom LAMP project development environment is created with Vagrant. First of all you will need to install Virtual Box and Vagrant. Then, create a vagrant folder in your home directory, open your terminal and change the current directory to the new vagrant directory. Now, execute...
Log the realm file location using: NSLog(@"%@",[RLMRealmConfiguration defaultConfiguration].fileURL); The line above will print the location to Xcode's console. Copy the file path, go to Finder → Go → Go to Folder... (or ⌘+⇧+G)→ paste the path and hit Go.
The bisect command helps you to track down the changeset that introduced a bug. Reset the bisect state and mark the current revision as bad (it contains the bug!) hg bisect --reset hg bisect --bad Go back to a point where you think the bug isn't present hg update -r -200 Now...
Whereas Classes are more like blueprints, Objects are static (i.e. already instantiated): object Dog { def bark: String = "Raf" } Dog.bark() // yields "Raf" They are often used as a companion to a class, they allow you to write: class Dog(val name: String) { } ...
Using a custom inspector allows you to change the way a script is drawn in the Inspector. Sometimes you want to add extra information in the inspector for your script that isn't possible to do with a custom property drawer. Below is a simple example of a custom object that with using a custom inspe...
SELECT Name FROM Customers WHERE PhoneNumber IS NULL Selection with nulls take a different syntax. Don't use =, use IS NULL or IS NOT NULL instead.
It is now a best-practice to use Vector instead of List because the implementations have better performance Performance characteristics can be found here. Vector can be used wherever List is used. List creation List[Int]() // Declares an empty list of type Int List.empty[Int] // U...
Note that this deals with the creation of a collection of type Map, which is distinct from the map method. Map Creation Map[String, Int]() val m1: Map[String, Int] = Map() val m2: String Map Int = Map() A map can be considered a collection of tuples for most operations, where the first e...
We start off with $db, an instance of the PDO class. After executing a query we often want to determine the number of rows that have been affected by it. The rowCount() method of the PDOStatement will work nicely: $query = $db->query("DELETE FROM table WHERE name = 'John'"); $count = ...
Flash Player 10 introduced the Vector.<*> generic list type that was faster than the Array. However, this is not entirely true. Only the following Vector types are faster than the Array counterparts, due to the way they are implemented in Flash Player. Vector.<int> - Vector of 32-bit ...
UITextView has built in support to auto detect a variety of data. The data that is able to be auto-detected currently includes: enum { UIDataDetectorTypePhoneNumber = 1 << 0, UIDataDetectorTypeLink = 1 << 1, UIDataDetectorTypeAddress = 1 << 2, UID...
Electron ports HTML web applications to native applications for a range of devices, including creating native desktop applications. It's also very easy to get started! To begin, we must have electron, nodejs, npm, git and meteor installed. Familiarity with these tools is vital for working with Mete...
Let's download a Meteor Todos example project, using a Linux shell (command line) script, to test out Electrifying a project for the first time: Requirements for this section: Git apt-get install git-all There are many ways to install Git. Check them out here. git is a version control sys...
An interesting thing to note which may help optimize your applications is that primitives are actually also refcounted under the hood. Let's take a look at numbers; for all integers between -5 and 256, Python always reuses the same object: >>> import sys >>> sys.getrefcount(1) 7...

Page 23 of 99