Problem
There is a series of repeating elements in page that you need to know which one an event occurred on to do something with that specific instance.
Solution
Give all common elements a common class
Apply event listener to a class. this inside event handler is the matching selector elemen...
When expecting someone to reproduce an R code that has random elements in it, the set.seed() function becomes very handy.
For example, these two lines will always produce different output (because that is the whole point of random number generators):
> sample(1:10,5)
[1] 6 9 2 7 10
>...
Be aware that Microsoft Excel 2013 (and higher) uses Single Document
Interface (SDI) and that Excel 2010 (And below) uses Multiple Document
Interfaces (MDI).
This implies that for Excel 2013 (SDI), each workbook in a single instance of Excel contains its own ribbon UI:
Conversely for Excel...
A function is a block of code that will be called several times during the execution. Instead of writing the same piece of code again and again, one can write this code inside a function and call that function whenever it is needed.
A function :
Must be declared in a class or a module
Returns a...
Configuring your environment
RabbitMQ looks for an set of environment variables in /etc/rabbitmq/rabbitmq-env.conf. If it does not exist, it assumes default values. All values in rabbitmq-env.conf get exported to the environment the RabbitMQ server runs in with a RABBITMQ_ prefix; this prefix is no...
From the documentation :
In C#, arguments can be passed to parameters either by value or by
reference. Passing by reference enables function members, methods,
properties, indexers, operators, and constructors to change the value
of the parameters and have that change persist in the calling
e...
Option Strict On prevents three things from happening:
1. Implicit Narrowing Conversion Errors
It prevents you from assigning to a variable that has less precision or smaller capacity (a narrowing conversion) without an explicit cast. Doing so would result in data loss.
Dim d As Double = 123.4
...
Command line arguments parsing is Go is very similar to other languages. In you code you just access slice of arguments where first argument will be the name of program itself.
Quick example:
package main
import (
"fmt"
"os"
)
func main() {
progName := o...
Throughout the topics and examples here we'll see many declarations of variables, functions and so on.
As well as their name, data objects may have attributes. Covered in this topic are declaration statements like
integer, parameter :: single_kind = kind(1.)
which gives the object single_kind...
Using the document-ready event can have small performance drawbacks, with delayed execution of up to ~300ms. Sometimes the same behavior can be achieved by execution of code just before the closing </body> tag:
<body>
<span id="greeting"></span> world!
<sc...
When your command is made available to your application, you can use Laravel to schedule it to run at pre-defined intervals, just like you would a CRON.
In The app/Console/Kernel.php file you will find a schedule method that you can use to schedule your task.
<?php
namespace App\Console;
...
The scheduler can be run using the command:
php artisan schedule:run
The scheduler needs to be run every minute in order to work correctly. You can set this up by creating a cron job with the following line, which runs the scheduler every minute in the background.
* * * * * php /path/to/artisan...
The easiest method to bypass cache is to change the URL. This is used as a best practice when the URL contains a version or a checksum of the resource, e.g.
http://example.com/image.png?version=1
http://example.com/image.png?version=2
These two URLs will be cached separately, so even if …?versi...
If your team is following a rebase-based workflow, it may be a advantageous to setup git so that each newly created branch will perform a rebase operation, instead of a merge operation, during a git pull.
To setup every new branch to automatically rebase, add the following to your .gitconfig or .gi...
Use quasiquotes to create a Tree in a macro.
object macro {
def addCreationDate(): java.util.Date = macro impl.addCreationDate
}
object impl {
def addCreationDate(c: Context)(): c.Expr[java.util.Date] = {
import c.universe._
val date = q"new java.util.Date()" // this...
std::optional<float> divide(float a, float b) {
if (b!=0.f) return a/b;
return {};
}
Here we return either the fraction a/b, but if it is not defined (would be infinity) we instead return the empty optional.
A more complex case:
template<class Range, class Pred>
auto find_if...
void print_name( std::ostream& os, std::optional<std::string> const& name ) {
std::cout "Name is: " << name.value_or("<name missing>") << '\n';
}
value_or either returns the value stored in the optional, or the argument if there is nothing s...