Due to way that the float type is represented in computer memory, results of operations using this type can be inaccurate - some values are stored as approximations. Good examples of this are monetary calculations.
If high precision is necessary, other types should be used. e.g. Java 7 provides Big...
Display a two dimensional (2D) array on the axes.
import numpy as np
from matplotlib.pyplot import imshow, show, colorbar
image = np.random.rand(4,4)
imshow(image)
colorbar()
show()
The whole point of MVVM is to separate layers containing logic from the view layer.
On Android we can use the DataBinding Library to help us with this and make most of our logic Unit-testable without worrying about Android dependencies.
In this example I'll show the central components for a stupid...
typealias SuccessHandler = (NSURLSessionDataTask, AnyObject?) -> Void
This code block creates a type alias named SuccessHandler, just in the same way var string = "" creates a variable with the name string.
Now whenever you use SuccessHandler, for example:
func example(_ handler: S...
typealias Handler = () -> Void
typealias Handler = () -> ()
This block creates a type alias that works as a Void to Void function (takes in no parameters and returns nothing).
Here is a usage example:
var func: Handler?
func = {}
typealias Number = NSNumber
You can also use a type alias to give a type another name to make it easier to remember, or make your code more elegant.
typealias for Tuples
typealias PersonTuple = (name: String, age: Int, address: String)
And this can be used as:
func getPerson(for name: Strin...
The following command lists out the queries that are currently being run on the server
db.currentOp()
The output looks something similar to this
{
"inprog" : [
{
"opid" : "302616759",
"active" : true,
&...
It is used to duplicate a git repository from gerrit to anyway. Configuration file is $GERRIT_INSTALL/etc/replication.config.
Config file example to clone MyRepo from gerrit to backupServer
[remote "backup"]
url = ProjectUrlOnBackupServer/${name} #Example backup.some.org:/pub/git/${...
This plugin is mandatory to make Gerrit able to receive message from other services. As an example, it has to be install to use Sonar Gerrit plugin
Install jar file under plugins folder
Default configuration is sufficient
C++11 offers tools that enhance the functionality of RAII-encapsulated OpenGL objects. Without C++11 features like move semantics, such objects would have to be dynamically allocated if you want to pass them around, since they cannot be copied. Move support allows them to be passed back and forth li...
PermissionUtil is a simple and convenient way of asking for permissions in context. You can easily provide what should happen in case of all requested permissions granted (onAllGranted()), any request was denied (onAnyDenied()) or in case that a rational is needed (onRational()).
Anywhere in your A...
Closely correlated features may add variance to your model, and removing one of a correlated pair might help reduce that. There are lots of ways to detect correlation. Here's one:
library(purrr) # in order to use keep()
# select correlatable vars
toCorrelate<-mtcars %>% keep(is.numeric)
...
By default all enum values are resolved to numbers. Let's say if you have something like
enum MimeType {
JPEG,
PNG,
PDF
}
the real value behind e.g. MimeType.PDF will be 2.
But some of the time it is important to have the enum resolve to a different type. E.g. you receive the value fr...
Create groovy file by path $JENKINS_HOME/init.groovy.d/basic-security.groovy
In Ubuntu 16 Jenkins home directory places in /var/lib/jenkins
Place in file next code
#!groovy
import jenkins.model.*
import hudson.security.*
def instance = Jenkins.getInstance()
def hudsonRealm = new...
Open Jenkins default config file and add in JAVA_ARGS next key -Djenkins.install.runSetupWizard=false
In Ubuntu 16 default file places in /etc/default/jenkins
Create groovy file by path $JENKINS_HOME/init.groovy.d/basic-security.groovy
In Ubuntu 16 Jenkins home directory places in /var/li...
If you want to match a backslash in your regular expression, you'll have to escape it.
Backslash is an escape character in regular expressions. You can use '\\' to refer to a single backslash in a regular expression.
However, backslash is also an escape character in Java literal strings. To make a...
The update pattern in D3 version 3
A correct understanding of how the “enter”, “update” and “exit” selections work is fundamental for properly changing the dataviz using D3.
Since D3 version 3 (actually, since version 2), this snippet could set the transitions for both “enter” and “update” selecti...
Using canvas elements
HTML provides the canvas element for building raster-based images.
First build a canvas for holding image pixel information.
var canvas = document.createElement('canvas');
canvas.width = 500;
canvas.height = 250;
Then select a context for the canvas, in this case two-di...
To add the BottomNavigationView follow these steps:
Add in your build.gradle the dependency:
compile 'com.android.support:design:25.1.0'
Add the BottomNavigationView in your layout:
<android.support.design.widget.BottomNavigationView
xmlns:android="http://schemas.andro...