Tutorial by Examples

>> img = imread('football.jpg'); Use imread to read image files into a matrix in MATLAB. Once you imread an image, it is stored as an ND-array in memory: >> size(img) ans = 256 320 3 The image 'football.jpg' has 256 rows and 320 columns and it has 3 color channels: Red, ...
A class or a structure may declare any function it's friend. If a function is a friend of a class, it may access all it's protected and private members: // Forward declaration of functions. void friend_function(); void non_friend_function(); class PrivateHolder { public: PrivateHolder(in...
Methods may declared as friends as well as functions: class Accesser { public: void private_accesser(); }; class PrivateHolder { public: PrivateHolder(int val) : private_value(val) {} friend void Accesser::private_accesser(); private: int private_value; }; void Access...
A whole class may be declared as friend. Friend class declaration means that any member of the friend may access private and protected members of the declaring class: class Accesser { public: void private_accesser1(); void private_accesser2(); }; class PrivateHolder { public: P...
In every applications life-cycle comes a day where it's components needs to be updated. Everyone knows the pain of updating every single dependency one-by-one. Well here you just need to issue the command: npm update (-g) If the "-g" is there then npm will update the global packages. ...
This is a protected and non-static method of the Object class. This method is used to perform some final operations or clean up operations on an object before it gets removed from the memory. According to the doc, this method gets called by the garbage collector on an object when garbage collecti...
Fast and short way to extract extension from file name in JavaScript will be: function get_extension(filename) { return filename.slice((filename.lastIndexOf('.') - 1 >>> 0) + 2); } It works correctly both with names having no extension (e.g. myfile) or starting with . dot (e.g. .h...
Fast and short way to format value of type Number as money, e.g. 1234567.89 => "1,234,567.89": var num = 1234567.89, formatted; formatted = num.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'); // "1,234,567.89" More advanced variant with support of any number o...
function assign(obj, prop, value) { if (typeof prop === 'string') prop = prop.split('.'); if (prop.length > 1) { var e = prop.shift(); assign(obj[e] = Object.prototype.toString.call(obj[e]) === '[object Object]' ? obj[e] ...
Use DOMContentLoaded when the <script> code interacting with DOM is included in the <head> section. If not wrapped inside the DOMContentLoaded callback, the code will throw errors like Cannot read something of null document.addEventListener('DOMContentLoaded', function(event) { ...
Here is an example of how to import a function that is defined in an unmanaged C++ DLL. In the C++ source code for "myDLL.dll", the function add is defined: extern "C" __declspec(dllexport) int __stdcall add(int a, int b) { return a + b; } Then it can be included into ...
""" ================================================================================ CREATE A 2 BY 2 GRID OF SUB-PLOTS WITHIN THE SAME FIGURE. ================================================================================ """ import matplotlib.pyplot as plt ...
""" ================================================================================ DRAW MULTIPLE LINES IN THE SAME PLOT ================================================================================ """ import matplotlib.pyplot as plt ...
JavaFX 8 The following example demonstrates how to add custom properties that can be styled from css to a custom Node. Here 2 DoublePropertys are added to the Rectangle class to allow setting the width and height from CSS. The following CSS could be used for styling the custom node: StyleableRe...
Objective-C supports a special type called `instancetype that can only be used as type returned by a method. It evaluates to the class of the receiving object. Consider the following class hierarchy: @interface Foo : NSObject - (instancetype)initWithString:(NSString *)string; @end @interf...
UCanAccess is a pure Java JDBC driver that allows us to read from and write to Access databases without using ODBC. It uses two other packages, Jackcess and HSQLDB, to perform these tasks. Once it has been set up*, we can work with data in .accdb and .mdb files using code like this: import java.sq...
It's important to know how CMake distinguishes between lists and plain strings. When you write: set(VAR "a b c") you create a string with the value "a b c". But when you write this line without quotes: set(VAR a b c) You create a list of three items instead: "a", &q...
You can create and configure build types in the module-level build.gradle file inside the android {} block. android { ... defaultConfig {...} buildTypes { release { minifyEnabled true proguardFiles getDefaultProguar...
Can be used to show/hide DOM elements. Similar to using if, except that visible will still build the element and set display:none. <div data-bind="visible: shouldShowMessage"> You will see this message only when "shouldShowMessage" holds a true value. </div> ...
Use the attr binding to apply any additional attributes to your element. Most commonly used for setting an href, src, or any data-attributes. <img data-bind="attr: { src: url, title: title }"/> var viewModel = { url: ko.observable("images/example.png"), title:...

Page 431 of 1336