public class LongestIncreasingSubsequence
{
private static int Lis(int[] input, int n)
{
int[] lis = new int[n];
int max = 0;
for(int i = 0; i < n; i++)
{
lis[i] = 1;
}
for (int i = 1; i < n; i++)
{
...
QGraphics can be used to organize complicated scenes of visual objects into a framework that makes them easier to handle.
There are three major types of objects used in this framework QGraphicsView, QGraphicsScene, and QGraphicsItems. QGraphicsItems are the basic visual items that exist in the scen...
'Base string
Dim exStr : exStr = " <Head>data</Head> "
'Left
Dim res: res = Left(exStr,6) 'res now equals " <Head"
'Right
Dim res: res = Right(exStr,6) 'res now equals "Head> "
'Mid
Dim res: res = Mid(exStr,8,4) 'res now equals "data"...
'Note: I use this method to extract non-html data in extracted GET telnet results
'This example effectively grabs every other vehicle that have start and finish
'characters, which in this case is "/".
'Resulting in an array like this:
'extractedData(0) = "/Jeep"
'extractedD...
Dim exStr : exStr = " <Head>data</Head> "
Dim res
res = Ucase(Replace(Mid(exStr, instr(exStr, ">")+1,4), "ata", "ark"))
'res now equals DARK
'instr(exStr, ">") returns 7
'Mid(" <Head>data</Head> ", 7+1,...
All that is needed to define a task is a declaration of it's type and a description:
lazy val exampleTask = taskKey[Unit]("An example task that will return no value.")
Because Unit is the type, this task is composed entirely of side-effects. Once defined, to implement actions:
example...
Using async initialization is a recommended way for application development. It uses the OpenCV Manager to access OpenCV libraries externally installed in the target system.
Code snippet implementing the async initialization:
public class MainActivity extends Activity implements CvCameraViewListen...
According to this approach all OpenCV binaries are included into your application package. It is designed mostly for development and debugging purposes. This approach is deprecated for the production code, async initialization is recommended.
If your application project doesn’t have a JNI part, jus...
This example covers some advanced features and use-cases for Exceptions.
Examining the callstack programmatically
Java SE 1.4
The primary use of exception stacktraces is to provide information about an application error and its context so that the programmer can diagnose and fix the problem. Som...
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...
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...
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/${...
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...
A feature that has near zero variance is a good candidate for removal.
You can manually detect numerical variance below your own threshold:
data("GermanCredit")
variances<-apply(GermanCredit, 2, var)
variances[which(variances<=0.0025)]
Or, you can use the caret package to find...
If a feature is largely lacking data, it is a good candidate for removal:
library(VIM)
data(sleep)
colMeans(is.na(sleep))
BodyWgt BrainWgt NonD Dream Sleep Span Gest
0.00000000 0.00000000 0.22580645 0.19354839 0.06451613 0.06451613 0.06451613
Pred ...
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)
...
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...