Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
How to get a segment from a URL using JS?
We can find a text or get a segment from a URL or web address using the JS split and slice function. Below is an example of a slice and split function in simple JavaScript code.
Lets assume we have a URL: https://rashidjorvee.blogspot.com/content/2015/javascript:getName_function/12032/live.html
When we run the split based on colon(:) it will return as below.
e.g. window.location.href.split(":").pop()
result ==> getName_function/12032/live.html
Now, from this if you want to read only few characters from any index, then do the slice on the URL.
e.g. window.location.href.split(":").pop().slice(0,7);
result ==> getName
How to read any attribute value using the element class name using JS?
Using the DOM function we could find the element using class name and then from that search list go to first index and get the required attribute.
document.getElementsByClassName('class_name')[0].getAttribute('id');
SQL queries to perform CURD operations
SELECT * FROM "user"
WHERE enabled = 'false'
SELECT * FROM "user"
WHERE email IN ('yumfawa48@gmail.com','rashid.jorvee@gmail.com')
SET enabled='true'
WHERE id='sql-tutorial'
What is Fascism?
Fascism is a term that referred to an environment created by people with fascist thought.
Who is fascist
Fascist is one who thinks he/she only have the right to live and use all the natural resources which is available on the earth and the universe, rest of the people who don't fit in their criteria or group has no right to live and have food.
Fascist society
A fascist society is a society where discrimination on the basis of color, race, faith, and sex takes place with the support of law enforcement agencies or government and with little contribution of the judiciary.
How hostname get resolved?
When we browse any website we use the hostname or domain name to access that website. Have you ever wonder how that hostname is getting mapped in the server and point to right application server to deliver the content to your browser? In this article we will study and understand how the hostname getting resolved on the server.
An application that is installed in our server can be accessed via browser, using IP address and port number or hostname. When you installed at that there is no hostname, you have only IP address to access, just for example in our local machine we use 127.0.0.0
Resolving Hostname
If we want to use a hostname instead of an IP address to connect to a remote device, the device that we are using to make the connection should be able to translate the hostname to an IP address. There are two ways to resolving a hostname to IP address. The first is creating host table on each router, and second is to build a Domain Name System(DNS) server.
1. Using Host Table
A host table provides name resolution, it does that only on the specific router that it was built upon. We use below command to build a host table on a router.
ip host <host_name> <port_number> <ip_address>
Note: default port number is 23.
2. Using Domain Name System(DNS)
If we are working with multiple devices, then we need not to create host table in each devices, instead of that we use DNS server to resolve the hostname.
Hence, DNS server makes the things easy and easy to maintain the entries in compare to host table.
Why there is no main method in Servlet?
When we run any program that has main method, the program runs the web server with the help of main method. And a web server runs the Servlet.
Simple Spring project example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; public class ImplCode { public static void main(String[] args) { ApplicationContext appContext=new FileSystemXmlApplicationContext("AppContextBeanFile.xml"); Fruit fruit=appContext.getBean("fruit", Fruit.class); Vegetable veg=(Vegetable) appContext.getBean("veg"); System.out.println(fruit.whoareyou()); System.out.println(veg.whoareyou()); } } |
Create a bean class Vegetable.java
1 2 3 4 5 6 7 8 9 10 11 12 13 | package rashiddemo; public class Vegetable { public String whoareyou() { String intro="I am vegetable!!"; return intro; } } |
Create another bean class Fruit.java
1 2 3 4 5 6 7 8 9 10 11 12 13 | package rashiddemo; public class Fruit { public String whoareyou() { String intro="I am fruit!"; return intro; } } |
Create a AppContextBeanFile.xml and add your bean classes using bean tag.
1 2 3 4 5 6 7 8 9 10 11 12 13 | <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="fruit" class="rashiddemo.Fruit"></bean> <bean id="veg" class="rashiddemo.Vegitable"></bean> </beans> |
OpenJDK 64-Bit Error Not enough space | errno=12
Solutions
1. You can restart the server, this way cache will get cleared and you will get the required space for execution.2. Increase the space for JVM or heap memory.
Puzzles
How can they cross the bridge in 17 minutes or less?
Answer: First Tom and John will cross (2 minutes). Then Tom will bring the flashlight back (1 minute). Next Sally and Connor will cross (10 minutes). Then John will bring the flashlight back (2 minutes). Finally John and Tom will cross (2 minutes). 2 + 1 + 10 + 2 + 2 = 17 minutes.