Infinispan

All

Intro

Reading more about JBoss and stuff, I came upon a cache mechanism called Infinispan. 100% open source and in Java.

Infinispan

It is a NoSQL data store used for key-value aka “distributed in-memory key/value data store with optional schema”.

It can be used – with Stream API – for map-reduce schemes. It follows the JS 107 standard.

Configuring cache: either programmatically or declaratively

From the User Guide, we can see the possibility to configure the cache using the CacheManager and the ConfigurationBuilder API, since CacheManager is Infinispan main entry point, the example as follow – programmatically:

EmbeddedCacheManager manager = new DefaultCacheManager("my-config-file.xml");
Cache defaultCache = manager.getCache();

 

For declarative you must specify the features on the configuration schema xml. The example was stolen from the source.

<infinispan>
   <cache-container default-cache="local">
      <transport cluster="mycluster"/>
      <local-cache name="local"/>
      <invalidation-cache name="invalidation" mode="SYNC"/>
      <replicated-cache name="repl-sync" mode="SYNC"/>
      <distributed-cache name="dist-sync" mode="SYNC"/>
   </cache-container>
</infinispan>

We can see here that the configuration applies to the default-cache on local

Features

Clustered cache: it’s a way to use several nodes for the cache information

Replicated cache: Just one node might fail, so it’s possible to replicate the data

Data Grid: you can use persist the information as a Datagrid

REFs

  Introduction

GraphQL

All

Intro

I just read about GraphQL and it’s quite good, very nice for the Flask API that I sometimes post here. This language will speed up the API by reducing the number of requests.

GraphQL

It’s basically a Query language for your api > there logo.

Well, with it you can speed-up the client and the server, faster than the REST approach way, especially that situation that you need to do subsequent queries on the same item.

You get only one request, instead of several – with a schema like this:

Example – with person: the original one was book (3:28)

type Person(id:27){

String name

String Address

}

Complete Course on youtube

The complete course is on youtube using MongoDB as the database, react as front-end and Node.js as back-end. The video has about 4hours but it is amazing

Side note: JP Morgan about Bitcoin

All

Although J.P. Morgan had criticized a lot on the past, I think they changed their minds, indeed.

In fact they created their own digital token: JPM Coin –  and it seems it has some real life utilization. Some of the digital coins projects I see lack exactly that, the real life utilization, although have good intentions.

An important fact the common user of crypto cannot use their currency, but only large investors.

CNBC new article here

The press release from JPM Morgan here.

Update: looks like now the coin is called Onyx and they now have other digital coin solutions.

Creating a Chrome Extension

All

Intro

Finally, I think I had an idea for an interesting chrome extension indeed.

Creating a Chrome extension

Following the tutorial it is simple to follow.

Hint: DO NOT download everything already built. Instead, build yourself, it’s quite useful and please, do some mods also.  It’s not difficult.

My extension

So my extension will help to get selected sentences and find them on google.  Pretty nice, I’ll integrate it with some python scripts I have.

That would be cool. For now, it’s pretty basic.

REFs

[1] https://developer.chrome.com/extensions/getstarted

 

JSP custom tag

All

Intro

Similar to ASP, which uses C#, JSP is the one with uses Java behind. To deploy those applications we need a servlet container, like Apache Tomcat or JBoss EAP – Undertow. JSP dynamic web content, as XML. Together.

Deploy

We need a servlet container so in this case, we can use Jetty for the demonstration. Eclipse Jetty is a Java HTTP (Web) server and Java Servlet container, I will talk more about it on another post.

JSP Custom TAG

One of the most interesting features in my opinion about JSP, which is a nice feature btw, is the possibility to create custom tags HTML based on the HTML rules – ofc. Just follow the template below with the attributes you need.

    TEMPLATE FOR HTML 4

<?xml version=”1.0″ encoding=”UTF-8″ ?>

<!DOCTYPE taglib
PUBLIC “-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN”
http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd”&gt;

<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>name</short-name>
<uri>/put_your_uri</uri>
<display-name>x</display-name>
<description>JSP Tag library for CPS application </description>
<tag>
<name>your_tag_name</name>
<tag-class>your_tag</tag-class>
<body-content>JSP</body-content>
<display-name> Any content</display-name>
<description>Example</description>
<attribute>

</attribute>

JSP Html 4 vs Html 5

Jsp will validate the HTML version on the begin of the page. Please use plain simple JavaScript in case you need validation.

 

JSP Specification

We can see the specification here

REFs

[1] https://download.oracle.com/otn-pub/jcp/jsp-2.2-mrel-oth-JSpec/jsp-2_2-mrel-spec.pdf?AuthParam=1549126534_f78333269b1bd20bab4bfcb8700cd010

Timber

All

Intro

Non-SQL is very useful and I’m a huge fan of MongoDB but relational database is not that bad!

While searching here and there, I came up with this very interesting thing called Timber, it merges tree structure properties with relational databases.

Summary: Timber is a native it is based on the TAX tree algebra supports updates.

XML Database?

Timber is this XML management database, where the data is storage directly and as such, the tree structure is preserved.

 

XQuery

fds fds

conf.Xml

More details on implementation can be found here

REFs

[1] http://dbgroup.eecs.umich.edu/timber/

log4j

All

Intro

One log framework to rule them all.

log4j

log4j is a reliable, fast and flexible logging framework (APIs) written in Java.

pom.xml

<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency>

Main components [1]

  • loggers: Responsible for capturing logging information.
  • appenders: Responsible for publishing logging information to various preferred destinations.
  • layouts: Responsible for formatting logging information in different styles.

 

Example

//logs an error message with parameter
	logger.error("This is error : " + parameter);
	
	//logs an exception thrown from somewhere
	logger.error("This is error", exception);

REFs

[1] https://www.tutorialspoint.com/log4j/log4j_overview.htm

 

 

Desktop Automation – Autokey

All

If you need to write several emails a day/messages irc’s, Autokey is certainly a nice tool to have. I got addicted to using it even on fb messages now!

One just needs to add a new phrase, add the content, and add the abbreviation and it is done.

In my case, I also need to reset the autokey for each new entry.

After that, I just write the abbreviation + space, that the value is replaced by the content. As described in the video below:

Gatling

All

Intro

During API development it’s very interesting/required to test the application in terms of response time for different loads. I’m using gatling for some tests here and it’s quite neat.

Apache JMeter

JMeter I’ll do a post about it later – which is not a browser, btw. I don’t know why they highlight this on the web site.

Loadrunner

Loadrunner, which Thread-based architecture, is actually from a company called Micro Focus – not opensource in fact!.

Gatling

It’s a tool to test loads since it’s based on messages, tests based on Scala – yup, not java or javascript. It overwrites the JVM limitations, therefore, so we can make much more accesses.

It uses to test http basically and the records the GUI.

Executing a performance test straight from the console.

It does not monitor back-end monitoring, as resources monitoring, like htop on the server.

 

 Class HttpSimulation1 extends Simulation {

  /* Place for arbitrary Scala code that is to be executed before the simulation begins. */

  before {

      println(“***** My simulation is about to begin! *****”)

  }

  /* Place for arbitrary Scala code that is to be executed after the simulation has ended. */

  after {

      println(“***** My simulation has ended! ******”)

  } 

  /*

   * A HTTP protocol builder is used to specify common properties of request(s) to be sent,

   * for instance the base URL, HTTP headers that are to be enclosed with all requests etc.

   */

  val theHttpProtocolBuilder = http

      .baseURL(http://computer-database.gatling.io&#8221;)

   /*

   * A scenario consists of one or more requests. For instance logging into a e-commerce

   * website, placing an order and then logging out.

   * One simulation can contain many scenarios.

   */

  /* Scenario1 is a name that describes the scenario. */

  val theScenarioBuilder = scenario(“Scenario1”)

      .exec(

          /* myRequest1 is a name that describes the request. */

          http(“myRequest1”)

              .get(“/”)

       )

  /*

   * Define the load simulation.

   * Here we can specify how many users we want to simulate, if the number of users is to increase

   * gradually or if all the simulated users are to start sending requests at once etc.

   * We also specify the HTTP protocol builder to be used by the load simulation

   */

  setUp(

      theScenarioBuilder.inject(atOnceUsers(1))

  ).protocols(theHttpProtocolBuilder)

}

Code from Krizsan, found here

REFs