Tutorial by Examples: er

CoffeeScript's existential operator ? check if the variable is null or undefined. 1. Check for null or undefined. alert "Hello CoffeeScript!" if myVar? javascript equivalent: if (typeof myVar !== "undefined" && myVar !== null) { alert("Hello CoffeeScript!&qu...
Makes a request only sending part of the form. The text1 value is set, but not text2, as the listener states. Bean.java @ManagedBean @ViewScoped public class Bean { private String text1; private String text2; public String getText1() { return text1; } pu...
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...
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...
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...
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...
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. ...
Sometimes we need to accept route params as well as access the HTTP Request params. We can still type hint the Requests class in laravel controller and achieve that as explained below E.g. We have a route that update a certain post like this (passing post id i route ) Route::put('post/{id}', 'Post...
import xlsxwriter # sample data chart_data = [ {'name': 'Lorem', 'value': 23}, {'name': 'Ipsum', 'value': 48}, {'name': 'Dolor', 'value': 15}, {'name': 'Sit', 'value': 8}, {'name': 'Amet', 'value': 32} ] # excel file path xls_file = 'chart.xlsx' # the workbook w...
Each signed integer type may be represented in any one of three formats; it is implementation-defined which one is used. The implementation in use for any given signed integer type at least as wide as int can be determined at runtime from the two lowest-order bits of the representation of value -1 ...
Resolving scoped services during application startup can be difficult, because there is no request and hence no scoped service. Resolving a scoped service during application startup via app.ApplicationServices.GetService<AppDbContext>() can cause issues, because it will be created in the sc...
Various websites provide online access to C++ compilers. Online compiler's feature set vary significantly from site to site, but usually they allow to do the following: Paste your code into a web form in the browser. Select some compiler options and compile the code. Collect compiler and/or pro...
Stream iterators are useful when we need to read a sequence or print formatted data from a container: // Data stream. Any number of various whitespace characters will be OK. std::istringstream istr("1\t 2 3 4"); std::vector<int> v; // Constructing stream iterators and copyi...
A defer statement consists of a block of code, which will be executed when a function returns and should be used for cleanup. As Swift's guard statements encourage a style of early return, many possible paths for a return may exist. A defer statement provides cleanup code, which then does not need ...

Page 214 of 417