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...
In following example we will create table movies with AWS Ruby SDK v2.
Here, each Movie as one unique Partition Key as id, and Range Key year. Apart from this we want to be able to query movies with their name, hence we will create a Global Secondary Index (GSI) name-year-index with name as Hash Ke...
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 ...
Run the following bash script as sudo
#!/bin/bash
# get deps
apt -y install build-essential libncurses5-dev libxml2-dev libsqlite3-dev libssl-dev libsrtp0-dev uuid-dev libjansson-dev
# download
cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-14-current.tar.gz...
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...
(function(){
var hashMap = {};
function isAnagram (str1, str2) {
if(str1.length !== str2.length){
return false;
}
// Create hash map of str1 character and increase value one (+1).
createStr1HashMap(str1);
/...
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...
ForeignKey field is used to create a many-to-one relationship between models.
Not like the most of other fields requires positional arguments.
The following example demonstrates the car and owner relation:
from django.db import models
class Person(models.Model):
GENDER_FEMALE = 'F'
G...
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...
Fugitive Vim is a plugin by Tim Pope that provides access to git commands that you can execute without leaving vim.
Some common commands include:
:Gedit - edit a file in the index and write it to stage the the changes
:Gstatus - equivalent of git status
:Gblame - brings up vertical split of outp...
display dialog "Password" default answer ""
set w to text returned of the result
if w = "Password" then
display notification "Correct"
end if
CREATE INDEX ord_customer_ix ON orders (customer_id);
By default, if we do not mention anything, oracle creates an index as a b-tree index. But we should know when to use it.
B-tree index stores data as binary tree format. As we know that, index is a schema object which stores some sort of entry...