Tutorial by Examples: e

1. Switch to a frame by Index. Here we are switching to index 1. Index refers to the order of frames on the page. This should be used as a last resort, as frame id or names are much more reliable. driver.SwitchTo().Frame(1); 2. Switch to a frame by Name driver.SwitchTo().Frame("Name_Of_Fr...
Some devices connected through a serial port send data to your program at a constant rate (streaming data) or send data at unpredictable intervals. You can configure the serial port to execute a function automatically to handle data whenever it arrives. This is called the "callback function&quo...
Set a convenience method in your base model namespace Base; class Model extends \Phalcon\Mvc\Model { public function sanitize($attr, $filterName) { $filter = $this->getDI()->get('filter'); $this->$attr = $filter->sanitize($this->$attr, $filterName); ...
Scala has a powerful type-inference mechanism built-in to the language. This mechanism is termed as 'Local Type Inference': val i = 1 + 2 // the type of i is Int val s = "I am a String" // the type of s is String def squared(x : Int) = x*x // the return type ...
The Scala compiler can also deduce type parameters when polymorphic methods are called, or when generic classes are instantiated: case class InferedPair[A, B](a: A, b: B) val pairFirstInst = InferedPair("Husband", "Wife") //type is InferedPair[String, String] // Equiv...
There are scenarios in which Scala type-inference does not work. For instance, the compiler cannot infer the type of method parameters: def add(a, b) = a + b // Does not compile def add(a: Int, b: Int) = a + b // Compiles def add(a: Int, b: Int): Int = a + b // Equivalent expression, compiles ...
#include <SPI.h> #define CSPIN 1 void setup() { pinMode(CSPIN, OUTPUT); // init chip select pin as an output digitalWrite(CSPIN, 1); // most slaves interpret a high level on CS as "deasserted" SPI.begin(); SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MO...
#include <Servo.h> Servo srv; void setup() { srv.attach(9); // Attach to the servo on pin 9 } To use a servo, you need to call attach() function first. It starts generating a PWM signal controlling a servo on a specified pin. On boards other than Arduino Mega, use of Servo lib...
Returns the number of characters of the given String Considerations If a number is given instead a String, the result will be the length of the String representing the given number. I.e. If we execute length(12345) the result will be the same as length("12345"), that is 5 If...
To assign a value to a previously declared variable, use the assignment operator, =: a = 6; b = "Foo"; As an alternative to independent declaration and assignment, it is possible to perform both steps in one statement: var a = 6; let b = "Foo"; It is in this syntax that...
Here are some example on how to add new filters/functions to twig,the synax for adding Twig_Functions are the same as the Twig_Filter ones, just change the keywords accordingly <?php $twig = new Twig_Environment($loader); /* You can chain a global function */ $twig->addFilter(ne...
You can group all your custom functions/filters/tests/... inside a custom Twig_Extension class: ProjectTwigExtension class ProjectTwigExtension extends Twig_Extension { public function getFunctions() { return array( new Twig_SimpleFunction('twig_function_name', array($...
OneGet was originally a product from the Open Source Technology Center at Microsoft. Not only is it inspired by open-source Linux package managers, OneGet itself is also open source. It's now part of PowerShell As opposed to Unix based package managers (such as apt-get, yum, or dpkg), Windows allow...
Atomic variables can be accessed concurrently between different threads without creating race conditions. /* a global static variable that is visible by all threads */ static unsigned _Atomic active = ATOMIC_VAR_INIT(0); int myThread(void* a) { ++active; // increment active race fr...
Here is a workaround to temporary reset your password for your account. Login to your hosting panel and use the database tool that is available (probably PHPmyAdmin). Load the appropriate database and then go to the jos_users table. (The database prefix might be different for your case). ...
Creation To create a Custom Setting, go to: Classic Setup > Develop > Custom Settings > New Lightning Setup > Custom Code > Custom Settings > New Create your setting (see the Remarks later in this document for the differences between Hierarchy & List custom settings). You...
Custom Setting Custom Setting Field Custom Setting Field Value When the field is checked the validation rule will be disabled, for the running user or in this example, their profile - The rule can also be disabled for a whole Salesforce org - Validation Rule AND( /* the below is the...
Explanation In this example a simple Trigger has been created to change the Close Date of an Opportunity, that's about to be inserted or updated, to a date 10 days in the future. The Apex Controller custom setting's checkbox field enables the code to be disabled at the user / profile / org level. ...
If you need to find the last day of the month, you can do complicated DateTime gymnastics or you can use the following method. Say you want to find the last day of February 2021. Do the following: Integer month = 2; Integer day = null; Integer year = 2021; // Create a new DateTime object for ...
To obtain an instance of an HTTP Request, class Illuminate\Http\Request need to be type hint either in the constructor or the method of the controller. Example code: <?php namespace App\Http\Controllers; /* Here how we illuminate the request class in controller */ use Illuminate\Http\Re...

Page 596 of 1191