multiply-square-matrix-parallel(A, B)
n = A.lines
C = Matrix(n,n) //create a new matrix n*n
parallel for i = 1 to n
parallel for j = 1 to n
C[i][j] = 0
pour k = 1 to n
C[i][j] = C[i][j] + A[i][k]*B[k][j]
return C
matrix-vector(A,x)
n = A.lines
y = Vector(n) //create a new vector of length n
parallel for i = 1 to n
y[i] = 0
parallel for i = 1 to n
for j = 1 to n
y[i] = y[i] + A[i][j]*x[j]
return y
Suppose we have a simple class with validation annotations
public class UserDTO {
@NotEmpty
private String name;
@Min(18)
private int age;
//getters/setters
}
A controller to check the UserDTO validity.
@RestController
public class ValidationController {
@Reque...
Q-learning is a variant of model-free reinforcement learning. In Q-learning we want the agent to estimate how good a (state, action) pair is so that it can choose good actions in each state. This is done by approximating an action-value function (Q) that fits in equation below:
Where s and a are ...
Ex1:-
let str1 = 'stackoverflow';
let str2 = 'flowerovstack';
These strings are anagrams.
// Create Hash from str1 and increase one count.
hashMap = {
s : 1,
t : 1,
a : 1,
c : 1,
k : 1,
o : 2,
v : 1,
e : 1,
r : 1,
f : 1,
l : 1,
w : 1...
You get this exception mostly with form submissions. Laravel protects application from CSRF and validates every request and ensures the request originated from within the application. This validation is done using a token. If this token mismatches this exception is generated.
Quick Fix
Add this wi...
Solves problem of: access denied for user root using password YES
Stop mySQL:
sudo systemctl stop mysql
Restart mySQL, skipping grant tables:
sudo mysqld_safe --skip-grant-tables
Login:
mysql -u root
In SQL shell, look if users exist:
select User, password,plugin FROM mysql.user ;
U...
CREATE BITMAP INDEX
emp_bitmap_idx
ON index_demo (gender);
Bitmap index is used when data cardinality is low.
Here, Gender has value with low cardinality. Values are may be Male, Female & others.
So, if we create a binary tree for this 3 values while searching it will have unnecessary ...
Working with Kettle
There are two versions of Kettle aka Pentaho Data Integration :
Kettle CE (Community Edition)
Kettle EE (Enterprise Edition)
Documents aims mainly on Kettle CE edition.
Prerequisites
PDI requires the Oracle Java Runtime Environment (JRE) version 7. You can obtain a JRE ...
var MongoClient = require('mongodb').MongoClient;
//connection with mongoDB
MongoClient.connect("mongodb://localhost:27017/MyDb", function (err, db) {
//check the connection
if(err){
console.log("connection failed.");
}else{
...
The NamedParameterJdbcTemplate class adds support for programming
JDBC statements using named parameters, as opposed to programming JDBC
statements using only classic placeholder ( '?') arguments. The
NamedParameterJdbcTemplate class wraps a JdbcTemplate, and
delegates to the wrapped JdbcTempl...
Any @Component or @Configuration could be marked with @Profile annotation
@Configuration
@Profile("production")
public class ProductionConfiguration {
// ...
}
The same in XML config
<beans profile="dev">
<bean id="dataSource" class="&l...
Protractor Installation and Setup
Step 1: Download and install NodeJS from here. Make sure you have latest version of node. Here, I am using node v7.8.0. You will need to have the Java Development Kit(JDK) installed to run selenium.
Step 2: Open your terminal and type in the following command to i...
Let us create a simple Hello World console application and log something to the console using log4net. Once we have this running, we can scale it out to use it in real development scenarios in the following examples. Let's start small and build it up from there.
First, we need to create a simple Co...
Suppose you need to work on three different projects project A, project B and project C. project A and project B need python 3 and some required libraries. But for project C you need python 2.7 and dependent libraries.
So best practice for this is to separate those project environments. To create v...
Suppose you need to work on three different projects project A, project B and project C. project A and project B need python 3 and some required libraries. But for project C you need python 2.7 and dependent libraries.
So best practice for this is to separate those project environments.
For creati...
Supervised learning is a type of machine learning algorithm that uses a known data-set (called the training data-set) to make predictions.
Category of supervised learning:
Regression: In a regression problem, we are trying to predict results within a continuous output, meaning that we are trying...