class MyClass {
function my_init_method() {
// do something here
}
}
$obj = new MyClass();
add_action( 'init', array( $obj, 'my_init_method' ) );
Using a method of an object to hook a set of instructions. With the init hook, the set of instructions will be executed right...
n % 2 == 0 ? trace("n is even!") : trace("n is odd!");
// Assigning the evaluated expression to a variable
var message = n % 2 == 0 ? "n is even!" : "n is odd!";
trace(message);
Reference
"If", Haxe manual
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...
Pulls the code from a certain specified file into another file where the call was made.
E.g.
inside example.php
<h1>Hello World!</h1>
Inside page.php
// header code
get_template_part('example');
// rest of page code
Output:
// header code
<h1>Hello World</h1>
/...
Any middleware registered as routeMiddleware in app/Http/Kernel.php can be assigned to a route.
There are a few different ways to assign middleware, but they all do the same.
Route::get('/admin', 'AdminController@index')->middleware('auth', 'admin');
Route::get('admin/profile', ['using' => ...
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...
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:...
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 containing a single child, with some framing options. Frame have a default Xamarin.Forms.Layout.Padding of 20.
XAML
<Frame>
<Label Text="I've been framed!"
HorizontalOptions="Center"
VerticalOptions="Center" />
</Frame>
Code
var ...