Current file
You can get the name of the current PHP file (with the absolute path) using the __FILE__ magic constant. This is most often used as a logging/debugging technique.
echo "We are in the file:" , __FILE__ , "\n";
Current directory
To get the absolute path to the di...
Detailed instructions on getting openerp set up or installed in Debian/Ubuntu.
To install from source code, we need Python 2.7, Git and a PostgreSQL database:
$ sudo apt-get install git python-pip python2.7-dev -y
$ sudo apt-get install postgresql -y
$ sudo su -c "createuser -s $(whoami)&qu...
To round a value to the nearest multiple of x:
function roundTo(value:Number, to:Number):Number {
return Math.round(value / to) * to;
}
Example:
roundTo(8, 5); // 10
roundTo(17, 3); // 18
List all the existing remotes associated with this repository:
git remote
List all the existing remotes associated with this repository in detail including the fetch and push URLs:
git remote --verbose
or simply
git remote -v
We can use the Service Container as a Registry by binding an instance of an object in it and get it back when we'll need it:
// Create an instance.
$john = new User('John');
// Bind it to the service container.
App::instance('the-user', $john);
// ...somewhere and/or in another class...
...
chrome.runtime.getManifest() returns the extension's manifest in a form of a parsed object.
This method works both on content scripts and all extension pages, it requires no permissions,
Example, obtaining the extension's version string:
var version = chrome.runtime.getManifest().version;
This method will work on modern versions of Arch, CentOS, CoreOS, Debian, Fedora, Mageia, openSUSE, Red Hat Enterprise Linux, SUSE Linux Enterprise Server, Ubuntu, and others. This wide applicability makes it an ideal as a first approach, with fallback to other methods if you need to also identify o...
C++11
Deriving a class may be forbidden with final specifier. Let's declare a final class:
class A final {
};
Now any attempt to subclass it will cause a compilation error:
// Compilation error: cannot derive from final class:
class B : public A {
};
Final class may appear anywhere in cl...
Addition + and subtraction - operations can be used to combine delegate instances. The delegate contains a list of the assigned delegates.
using System;
using System.Reflection;
using System.Reflection.Emit;
namespace DelegatesExample {
class MainClass {
private delegate void MyD...
This example will show you how to quickly get a hello world Aurelia application up and running using the Aurelia CLI.
Prerequisites
The Aurelia CLI is a Node.js based application, so make sure you install it first before proceeding. You will need Node.js 4.4.7 or later.
You will also need a Git c...
A commonly used CSS/Javascript library is Bootstrap. To install it into your Aurelia CLI driven application first you need to install it using Npm.
npm install bootstrap --save
Because Bootstrap has a hard dependency on jQuery, we need to make sure we also have jQuery installed:
npm install jqu...
You should use caution when using setState in an asynchronous context. For example, you might try to call setState in the callback of a get request:
class MyClass extends React.Component {
constructor() {
super();
this.state = {
user: {}
};
}
...
Stateless components are getting their philosophy from functional programming. Which implies that: A function returns all time the same thing exactly on what is given to it.
For example:
const statelessSum = (a, b) => a + b;
let a = 0;
const statefulSum = () => a++;
As you can see fro...
Create project using STS (Spring Starter Project) or Spring Initializr (at https://start.spring.io ).
Add a Web Dependency in your pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId&...
$scope.$emit
Using $scope.$emit will fire an event name upwards through the scope hierarchy and notify to the $scope.The event life cycle starts at the scope on which $emit was called.
Working wireframe :
$scope.$broadcast
Using $scope.$broadcast will fire an event down the $scope. We can list...
updateState by key can be used to create a stateful DStream based on upcoming data. It requires a function:
object UpdateStateFunctions {
def updateState(current: Seq[Double], previous: Option[StatCounter]) = {
previous.map(s => s.merge(current)).orElse(Some(StatCounter(current)))
}
...