Tutorial by Examples

It is a good practice to provide expression string arguments as braced strings. The heading "Double Substitution" outlines important reasons behind the same. The expr command evaluates an operator-based expression string to calculate a value. This string is constructed from the arguments ...
To implement the equals method of an object easily you could use the EqualsBuilder class. Selecting the fields: @Override public boolean equals(Object obj) { if(!(obj instanceof MyClass)) { return false; } MyClass theOther = (MyClass) obj; EqualsBuilder builde...
To implement the hashCode method of an object easily you could use the HashCodeBuilder class. Selecting the fields: @Override public int hashCode() { HashCodeBuilder builder = new HashCodeBuilder(); builder.append(field1); builder.append(field2); builder.append(field3); ...
To implement the toString method of an object easily you could use the ToStringBuilder class. Selecting the fields: @Override public String toString() { ToStringBuilder builder = new ToStringBuilder(this); builder.append(field1); builder.append(field2); builder.append(field3...
When the view controller is presented within a tab bar controller, you can access the tab bar controller like this: Swift let tabBarController = viewController.tabBarController Objective-C UITabBarController *tabBarController = self.tabBarController; When the view controller is part on an n...
JavaScript has native conversion from Number to it's String representation for any base from 2 to 36. The most common representation after decimal (base 10) is hexadecimal (base 16), but the contents of this section work for all bases in the range. In order to convert a Number from decimal (base...
Parameters The first 4 parameters are passed in (in order) RCX, RDX, R8 and R9. XMM0 to XMM3 are used to pass floating point parameters. Any further parameters are passed on the stack. Parameters larger than 64bit are passed by address. Spill Space Even if the function uses less than 4 paramet...
The var_dump function allows you to dump the contents of a variable (type and value) for debugging. Example: $array = [3.7, "string", 10, ["hello" => "world"], false, new DateTime()]; var_dump($array); Output: array(6) { [0]=> float(3.7) [1]=> ...
If you want PHP to display runtime errors on the page, you have to enable display_errors, either in the php.ini or using the ini_set function. You can choose which errors to display, with the error_reporting (or in the ini) function, which accepts E_* constants, combined using bitwise operators. P...
Warning It is imperative that phpinfo is only used in a development environment. Never release code containing phpinfo into a production environment Introduction Having said that, it can be a useful tool in understanding the PHP environment (OS, configuration, versions, paths, modules) in which ...
C99 Added in the C standard version C99, _Bool is also a native C data type. It is capable of holding the values 0 (for false) and 1 (for true). #include <stdio.h> int main(void) { _Bool x = 1; _Bool y = 0; if(x) /* Equivalent to if (x == 1) */ { puts("T...
You can use gradle to have BuildConfig constants and res values on a per flavor basis. Just add the value to the flavor you want to support. android { defaultConfig { resValue "string", "app_name", "Full App" buildConfigField "boolean",...
To change PS1, you just have to change the value of PS1 shell variable. The value can be set in ~/.bashrc or /etc/bashrc file, depending on the distro. PS1 can be changed to any plain text like: PS1="hello " Besides the plain text, a number of backslash-escaped special characters are s...
To sort elements efficiently (all at once and with minimal DOM interruption), we need to: Find the elements Sort based on a set condition Insert back in the DOM <ul id='my-color-list'> <li class="disabled">Red</li> <li>Green</li> <li ...
Matlab supports synchronous and asynchronous communication with a serial port. It is important to chose the right communication mode. The choice will depend on: how the instrument you are communicating with behave. what other functions your main program (or GUI) will have to do aside from managi...
#include <stdio.h> int main(void) { /* define a small bit-field that can hold values from 0 .. 7 */ struct { unsigned int uint3: 3; } small; /* extract the right 3 bits from a value */ unsigned int value = 255 - 2; /* Binary 11111101 */ small.u...
You can convert a numeric string to various Java numeric types as follows: String to int: String number = "12"; int num = Integer.parseInt(number); String to float: String number = "12.0"; float num = Float.parseFloat(number); String to double: String double = "1...
namespace App\Controller; class PostsController extends AppController { public function initialize(){ parent::initialize(); // code that you want to run before every action } public function view($id) { //Your code here } }
The beforeFilter() method executes before any other method executes in the controller. First use the Event namespace before defining the class in your controller file. use Cake\Event\Event; In your controller, add the beforeFilter() method as shown below. public function beforeFilter(Event $ev...
Pass each variable to view at a time $this->set('color', 'pink'); $this->set('color', $color); Pass multiple variables to view together via compact() function $color1 = 'pink'; $color2 = 'red'; $this->set(compact('color1', 'color2'));

Page 440 of 1336