// Java:
String phrase = persons
.stream()
.filter(p -> p.age >= 18)
.map(p -> p.name)
.collect(Collectors.joining(" and ", "In Germany ", " are of legal age."));
System.out.println(phrase);
// In Germany Max and Peter a...
CRTP is a powerful, static alternative to virtual functions and traditional inheritance that can be used to give types properties at compile time. It works by having a base class template which takes, as one of its template parameters, the derived class. This permits it to legally perform a static_c...
Subroutines are created by using the keyword sub followed by an identifier and a code block enclosed in braces.
You can access the arguments by using the special variable @_, which contains all arguments as an array.
sub function_name {
my ($arg1, $arg2, @more_args) = @_;
# ...
}
Sin...
You can pass data to a template in a custom variable.
In your views.py:
from django.views.generic import TemplateView
from MyProject.myapp.models import Item
class ItemView(TemplateView):
template_name = "item.html"
def items(self):
""" Get all Ite...
CMake generates build environments for nearly any compiler or IDE from a single project definition. The following examples will demonstrate how to add a CMake file to the cross-platform "Hello World" C++ code.
CMake files are always named "CMakeLists.txt" and should already exis...
Have you ever forgotten to add a trap to clean up a temporary file or do other work at exit?
Have you ever set one trap which canceled another?
This code makes it easy to add things to be done on exit one item at a time, rather than having one large trap statement somewhere in your code, which may...
In Bosun templates can reference other templates. For emails notifications, you might have a header template to show things you want in all alerts.
Header Template
template header {
body = `
<style>
td, th {
padding-right: 10px;
}
</style>
<p s...
Templates can be previewed and edited using the Rule Editor tab in Bosun. Use the Jump to links to select the alert you want to edit, then you can use the template button next to macro to switch between the alert an template sections of the configuration. If an alert has multiple instances you can u...
You can embed another template body into your template via {{template "mysharedtemplate" .}} to reuse shared components. Here is an example that creates a header template that can be reused at the top of all other template bodies. It also uses CSS to stylize the output so that it is easier...
It often is faster to use a generic template when first creating a new alert and only specialize the template when you need to display more information. The following template will display a subject with a numerical value, custom formatting, and description string and then a body with up to two grap...
This uses the Dropbox Java SDK to create a shared link for a file at the Dropbox path /test.txt:
try {
SharedLinkMetadata sharedLinkMetadata = client.sharing().createSharedLinkWithSettings("/test.txt");
System.out.println(sharedLinkMetadata.getUrl());
} catch (CreateSharedLinkW...
This returns information about a specific classifier ID you have trained. This includes information about its current status (i.e., if it is ready or not).
'use strict';
let watson = require('watson-developer-cloud');
var visualRecognition = watson.visual_recognition({
version: 'v3',
ap...
The examples below fill in a PhoneNumber for any Employee who is also a Customer and currently does not have a phone number set in the Employees Table.
(These examples use the Employees and Customers tables from the Example Databases.)
Standard SQL
Update using a correlated subquery:
UPDATE
...
The following Go file can be compiled into a continuous external collector that will query a MSSQL server database that uses the StackExchange.Exceptional schema. It will query multiple servers/databases for all exceptions since UTC 00:00 to convert the raw entries into a counter. It also uses the b...
The following demo features an <output> element's use of the [for] and [form] attributes. Keep in mind, <output> needs JavaScript in order to function. Inline JavaScript is commonly used in forms as this example demonstrates. Although the <input> elements are type="number"...