switch (n % 2) {
case 0: trace("n is even!");
case 1: trace("n is odd!");
default: trace("I don't know!");
}
// Assigning the evaluated expression to a variable
var message = switch (n % 2) {
case 0: "n is even!";
case 1: "n ...
A loop is a control flow structure to definitely or indefinitely run a set of statement written only once in code, until a certain condition is met or the process is terminated.
Condition loops
These loops are repeated based on the state of their conditions.
For loops
For loops are usually run...
If different users need different datetime format then you may need to parse your incoming date string to actual date according to the format. In this case this snippet may help you.
public class DateTimeBinder : DefaultModelBinder
{
public override object BindModel(ControllerContext control...
In this example you'll learn how to share a file with other apps. We'll use a pdf file in this example although the code works with every other format as well.
The roadmap:
Specify the directories in which the files you want to share are placed
To share files we'll use a FileProvider, a class all...
When the command-line syntax for an application is simple, it is reasonable to do the command argument processing entirely in custom code.
In this example, we will present a series of simple case studies. In each case, the code will produce error messages if the arguments are unacceptable, and the...
This example shows how to use the Firebase Cloud Messaging(FCM) platform.
FCM is a successor of Google Cloud Messaging(GCM). It does not require C2D_MESSAGE permissions from the app users.
Steps to integrate FCM are as follows.
Create sample hello world project in Android Studio
Your Android...
This is a basic polymer element that show a list of names.
<link rel="import" href="../bower_components/polymer/polymer.html">
<dom-module id="basic-list">
<template>
<style>
</style>
<div>Name's list</div&g...
Professionally made web applications don't expose the internal details of the server environment to the user. When you place an order at your retailer, you don't see (or have to type) https://mydealer.com:8443/Dealerapp/entryPage.html, but just mydealer.com, although the app server needs all the det...
Angular 1 is at heart a DOM compiler. We can pass it HTML, either as a template or just as a regular web page, and then have it compile an app.
We can tell Angular to treat a region of the page as an expression using the {{ }} handlebars style syntax. Anything between the curly braces will be compi...
To start Alfresco:
Switch to the alfresco user
Change to the $ALFRESCO_HOME directory
Run ./alfresco.sh start
To stop Alfresco:
Switch to the alfresco user
Change to the $ALFRESCO_HOME directory
Run ./alfresco.sh start
There are many ways to backup an Alfresco system. It is important that you backup the database as well as the content store. You may also want to back up the Solr indices.
Assuming you installed using the binary installer, and everything lives in $ALRESCO_HOME, you can backup the database like this...
A behavior based animation allows you to specify that when a property changes the change should be animated over time.
ProgressBar {
id: progressBar
from: 0
to: 100
Behavior on value {
NumberAnimation {
duration: 250
}
}
}
In this example ...
int[string] aa = ["x": 5, "y": 6];
// The value can be set by its key:
aa["x"] = 7;
assert(aa["x"] == 7);
// if the key does not exist will be added
aa["z"] = 8;
assert(aa["z"] == 8);
Let's assume an associative array aa:
int[string] aa = ["x": 5, "y": 6];
Items can be removed by using .remove(), if key exits will be removed and remove returns true:
assert(aa.remove("x"));
if the given key does not exist remove does nothing and returns false:...
The StretchViewport is a Viewporttype, which supports a virtual screen size.
This allowes you to define a fixed (resolution independent) width and height.
The StretchViewport, as the name suggests, stretches the virtual screen, if the virtual aspect ratio does not match the real aspect ratio. The ...
Scala's implementation of type classes is rather verbose. One way to reduce the verbosity is to introduce so-called "Operation Classes". These classes will automatically wrap a variable/value when they are imported to extend functionality.
To illustrate this, let us first create a simple ...
An element capable of scrolling if it's Content requires.
ScrollView contains layouts and enables them to scroll offscreen. ScrollView is also used to allow views to automatically move to the visible portion of the screen when the keyboard is showing.
Note: ScrollViews should not be nested. In a...