Avoiding null variables while serializing with Jackson

I perform some CRUD operation by consuming REST APIs. Some of the entities I want to create do not have values for non-mandatory fields. When I pass those entities to servers, the call breaks with a NullPointerException. Hence I do not want to send a variable if it is null. We shall use JsonInclude annotation as shown below

@JsonInclude(JsonInclude.Include.NON_NULL)
String to;

Ansible: Missing sudo password

So here is the another error while getting the uname of the remote boxes

$ ansible webservers -b --become-user=myuser -m shell -a 'uname -a' -u myuser
192.168.1.139 | FAILED | rc=-1 >>
Missing sudo password

After executing it with explicit become password it worked.

$ ansible webservers -b --become-user=myuser -m shell -a 'uname -a' -u myuser --extra-vars "ansible_sudo_pass=mypassword"

Failed to connect to the host via ssh: user@IP: Permission denied (publickey,password).”

I tried to ping all servers in Ansible

This is what I have in /etc/ansible/hosts file

[webservers]
192.168.1.139

My ping command failed.

$ ansible webservers -m ping
192.168.10.139 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: pandian@192.168.10.139: Permission denied (publickey,password).",
    "unreachable": true
}

I updated the hosts file with credentials.

[webservers]
192.168.1.139 ansible_ssh_pass=password ansible_ssh_user=myuser

Does it work? Not yet

$ ansible webservers -m ping
192.168.10.139 | FAILED! => {
    "msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program"
}

I need to install

$ sudo apt-get install sshpass

Finally it works!

$ ansible webservers -m ping
192.168.1.139 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "ping": "pong"
}

Grassfield Tamil Blog Aggregator

I’m happy to introduce the brand new blog aggregator www.grassfield.org. Today is the day 1 🙂

This aggregates Tamil and English blogs. This platform is running using my opensource project jAtomRss. I’m happy to come out with a website, finally.

Thanking Sivakumar and Kannan for their technical support and Sindu for testing the same!

Uncaught Error: Cannot pass parameter 4 by reference

$qry = "insert into feed_info (site_url, feed_xml_url, enabled) values (?,?,?)";
$stmt->bind_param('sss', $obj["site_url"], $obj["feed_xml_url"],0);

This was the PHP code that threw this exception.

Uncaught Error: Cannot pass parameter 4 by reference

PHP error: “Cannot pass parameter 2 by reference” The pass by value 0 caused the issue, when the method is expecting a variable / pass by reference.

The following code fixed the problem.

$enabled=0;
$stmt->bind_param('sss', $obj["site_url"], $obj["feed_xml_url"],$enabled);

Jackson JSON Capitalization: Unrecognized field

Hi,

I need to covert the following snippet of JSON response to its relevant object. The key is ComponentType not componentType which didnt adhere to java variable standards.

{
"ComponentType": "APC_Ups",
"servers": [
"APC01"
]
}

Object coversion by Jackson failed with error com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field “ComponentType”

Jackson tries to search for the variable name as per java variable naming standards. As there is no variable defined as ‘componentType’, it fails. Defining right variable name using @JsonProperty will solve this problem!

@JsonProperty (“ComponentType”)
String ComponentType;

Ref: Jackson JSON field mapping capitalization?

Chennai T Nagar

Hide blocks in jQuery

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("p").click(function(){
    $(this).hide();
  });
  $("content").click(function(){
	$(this).hide();
  });
  $("#myid").click(function(){
	$(this).hide();
  });
  $(".myclass").click(function(){
	$(this).hide();
  });
});
</script>
</head>
<body>

<p>I am a paragraph</p>
<content>I am a content</content>
<ul id="myid">
<li>I am an unordered list identified as myid</li>
</ul>

<div class="myclass">
I am a div identified as myclass
</div>

</body>
</html>

The above snippet will help to hide the given blocks like in paragraph, content and unordered list blocks.

Initially it blocks everything. When we click any of the blocks, it will hide. After clicking the paragraph in the first line, this is what you see.

This helps to hide standard blocks using its tag or id or class names!