My First Post      My Facebook Profile      My MeOnShow Profile      W3LC Facebook Page      Learners Consortium Group      Job Portal      Shopping @Yeyhi.com









Wednesday, April 8, 2020

Story point Estimation guideline


A story point is a metric used in agile project management and development to estimate the difficulty of implementing a given user story, which is an abstract measure of effort required to implement it. In simple terms, a story point is a number that tells the team about the difficulty level of the story. Difficulty could be related to complexities, risks, and efforts involved.


Story point estimation, a kind of relative estimation, is typically performed at the Product Backlog Grooming Sessions and the Product Backlog is evaluated by the team who responsible for the actual development and testing work.


In most of the cases (and as defined by Scrum principles), the story pointing or estimation is done using some pre-decided base story. Every other story is pointed in respect to that story. However, if it is your first story or a new project, you can start with following simple chart.

Story points
Estimation effort
1< 1 day
21
32-3 days
53-5 days
85+ days
8+It is advised to break the story in simpler
Please note that this is what you do. Your style and the way your organization works might be slightly different. However, the basic idea remains the same. And the goal is also one - Success!

Cheers :)

Wednesday, March 11, 2020

find what uses a port like 8080 kill the process on mac

Many a times during debugging, you find that your port is already used. You can find at this point where it is used and kill the process.


Step 1: Find all processes using port
$ netstat -vanp tcp | grep 8080


Step 2: Kill the task
eg: $ sudo kill -9 73804


Refer screen shot below:



cheers :)



Sunday, March 8, 2020

Typechecker in hhvm and running Hack program

Let's start with writing a sample program of printing cubes of numbers. eg:

Using the editor of your choice (e.g., VSCode or vim), let's create a file called first.hack with the following code:
<<__entrypoint>> function main(): void { echo "Welcome to Hack! \n\nTutorial by Anwar Faiz\n\n"; \printf("Table of Cubes\n" . "----------------\n"); for ($i = -5; $i <= 5; ++$i) { \printf(" %2d %2d \n", $i, $i * $i * $i); } \printf("----------------\n"); exit(0); }
To see the result of Typechecking:
$ hh_client first.hack
You should see:
No errors!
* Note that however, you might get following error - Error: /Users/mfaiz/ECPCP/hhvm-hack/first.hack is not a directory
But that is other issue. i will explain in next post.

To run the program on client side:
$hhvm first.hack 
You will get following as result.

By the way by now I am already feeling like using Node like application for PHP. This is looking cool. Hurray! 
Take care readers. And pour in your thoughts :)




Friday, March 6, 2020

First Hello World using Hack & HHVM from Facebook

1. Install HHVM on MacOS via Homebrew:
brew tap hhvm/hhvm
brew install hhvm

The out-of-the-box HHVM configuration won't need tweaking by most new users. Notably, the JIT compiler that gives HHVM its speed is on by default. If you want to take a look at the configuration used, it's at /usr/local/etc/hhvm/php.ini in MacOS.



2. Test: After installing HHVM, change to the directory where your code lives, and start up HHVM:

hhvm -m server -p 8080
-m represents the mode and here indicates that HHVM is running in HTTP server mode.
-p configures the TCP port that HHVM uses to listen to HTTP requests. The default port is 80, the standard HTTP port. However, that port requires root access, so for this example, we will use port 8080.

This will start the server as follows and then you can test on browser.


3. Write a simple "Hello World" program named hello.hack:

<<__entrypoint>> function main(): noreturn{ echo "Hello World in Hack Language! \nThis is Anwar Jamal Faiz"; exit(0); }

Save this hello.hack in the same directory that you ran the hhvm command from above. Then, load http://localhost:8080/hello.hack in your browser and verify you see "Hello World!" appear.


See in browser:
You may also write the program as:
<<__entrypoint>>
function main(): noreturn{
  echo "Hello World in Hack Language! \nThis is Anwar Jamal Faiz";
  exit(0);
}




4.  You can directly run file using hhvm itself.

$ hhvm hello.hack




Note: You can configure HHVM too. Running HHVM automatically at boot as a service (instead of just on the command line as above) unfortunately does require some configuration. See the proxygen documentation for details. However, default settings are okay for any average usecase.


My First look of Hack Language over HHVM by Facebook

Hack is a great language in terms of the advantages it has over PHP. The hack language introduce a level of type safety and related concepts. Undoubtedly, with HHVM it becomes a faster processing language. It is more expressive, more economic, it is faster to write and catch more bugs. The key features as explained by Facebook itself are:

Fast Development
Hack reconciles the fast development cycle of a dynamically typed language with the discipline provided by static typing, while adding many features commonly found in other modern programming languages.


Type Checking
Hack provides instantaneous type checking by incrementally checking your files as you edit them. It typically runs in less than 200 milliseconds, making it easy to integrate into your development workflow without introducing a noticeable delay.


Built for HHVM
Hack is built specifically for HHVM, a high performance 


Type Annotations
Type annotations allow for code to be explicitly typed on parameters, class member variables and return values.


Generics
Generics allow classes and methods to be parameterized (i.e., a type associated when a class is instantiated or a method is called) in the same vein as statically typed languages like C# and Java).

Lambdas
Lambdas succinctly allow definition of first-class functions.


HHVM is an open-source virtual machine designed for executing programs written in Hack. HHVM uses a just-in-time (JIT) compilation approach to achieve superior performance while maintaining amazing development flexibility. HHVM should be used together with a webserver like the built in, easy to deploy Proxygen, or a FastCGI-based webserver on top of nginx or Apache.

Released in 2014, Hack is still not so much popular and I see following as the reasons.
  1. I cannot find any big hosting provider to support HHVM hosting and support for Hack language. You need to maintain your own server. This is one of the big issues that I see with Hack.
  2. Vast majority of php programmers do not build using TDD approach or do lots of whitebox testing. Hence, the benefit of type checking does not attract them much. For many hhvm is just a slightly faster incompatible php, no surprise they aren’t going to invest much there.
  3. Installing Hack on different systems require more technical knowledge. Novice programmers usually lack the skills of core OS. Also, on some systems you need to build HHVM from scratch using the source code repo.
  4. Backwards compatibility with PHP is not 100%. Almost all PHP code works in Hack but there are certain features of PHOP which is not supported in Hack. Hack may have some incompatibility with existing PHP codebases, which increases the cost of switching.
  5. Not everyone needs the amount of scalebilty the companies like Facebook need.
  6. Other bigger eCom and web companies are trying with new RAD tools like React and doing pretty well in their NodeJS world. Webservices are already build using Java or C# and they do not want to come to PHP of Hack.
  7. Hack doesn't allow templating of HTML and Hack code together, which is a popular feature of PHP. You need an engine in between.
  8. Last, but not the least, no one knows how far facebook itself will support the developemnt and Bug fixes in Hack or HHVM.

However, we should also understand that in the world of PHP, the language Hack becomes very useful. It will help developers catch some errors while writing the code itself. Further, the dev tools by Facebook and other contributors are also very exciting. So, I will be experimenting more with the language. Will keep you all posted about new features.

Tuesday, February 18, 2020

Pulse Secure Duo Authentication using phone call for VPN connection if you have multiple phones registered

Many of my corporate readers have asked me to write on this topic. And, when it actually happened with me as well, I was prompted to write. So, my readers this is on your demand ;)

Sometimes, you have more than one phone numbers registered in your Duo account. And you need to authenticate for your VPN connection.

Normally, you can do following:

  1. phone
  2. push to Duo application on that mobile
  3. VPN key copied from application, etc.
In phone case, you get a call on the phone registered. It will then ask you to press any key, in case you expect this call. If you press any number, the call gets authenticated.

But, if you have say 3 phones registered then what to do?

The solution is pretty simple!
Use - phone or phone2 or phone3 command etc.



Command: phone 
It shall call that phone. For first phone, default phone would work. For second phone, you need to use phone2 command. And so on.

Cheers ;)





Friday, January 31, 2020

Build using Maven - MVN and POM.xml

In order to build a Maven project you can use one of the following:

  • mvn clean install
  • mvn clean package etc.

This would build/compile and run the tests as well.

However, if you want to run the tests only then what would you do?

Sound similar? Yeah! we all often land up in this situation as an application developer. And, the solution is simple.


You can use mvn test to run unit test in Maven. Few examples :
# Run all the unit test classes.
$ mvn test

# Run a single test class.
$ mvn -Dtest=TestApp1 test

# Run multiple test classes.
$ mvn -Dtest=TestApp1,TestApp2 test

# Run a single test method from a test class.
$ mvn -Dtest=TestApp1#methodname test

# Run all test methods that match pattern 'testHello*' from a test class.
$ mvn -Dtest=TestApp1#testHello* test

# Run all test methods match pattern 'testHello*' and 'testMagic*' from a test class.
$ mvn -Dtest=TestApp1#testHello*+testMagic* test

The default maven-surefire-plugin is outdated, make sure update to the latest to support new features, like pattern matching or run a single test method, and etc.
pom.xml
 <build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.0</version>
            </plugin>

        </plugins>
    </build>

Thursday, January 30, 2020

Mapping template, Velocity Language & JsonPath: Guide to Api Gateway mapping templates mechanism

Amazon’s API Gateway provides the facilities to map an incoming request’s payload to match the required format of an integration backend. It uses the concept of “models” and “mapping templates” to specify the mapping between the client payload and the server payload.

The API Gateway mapping templates are used to transform an incoming payload into a different format. API Gateway allows you to define input mapping templates, for mapping the incoming request from a client to a server format, and output mapping templates, for mapping the outgoing response from the server to a client format.

Let us all remember that the mappings are defined using the Velocity Template Language combined with JSONPath expressions.

Velocity is a Java-based templating engine that uses a template language to reference objects in Java code. Velocity can be used to generate web XML, HTML or SQL from templates, for example. Here, we will use it to define the mapping between an input and output model.
A Velocity Template Language (VTL) template is composed of statements which begin with the # character and a followed by a directive. Also, it has references, which begin with the $ character. More generally, references begin with $ and are used to get or set something. Directives begin with # and are used to do something.
We can use the statement above to define an HTML template that sets a reference to a value, and retrieves that reference.

  
  #set( $foo = "Velocity" )
  Hello $foo World!
  
For more on VTL, consult the user guide.

In API Gateway mapping templates, the input to your Velocity template is defined by the reference variable $input. To access particular portions of the input JSON document within the template, use JSONPath.
JSONPath provides an XPath-like method of referring to a JSON structure. IN JSONPath, the abstract name $ refers to the root-level object. From this root-level object, you can use dot-notation to select more restrictive portions of the document. 
For example, to reference the playerId of the player model, you would use the following JSONPath expression.
$.playerId
or, you can use a bracket-notation to perform the same selection.
#['playerId']
More complex selections can be done using * for a wildcard, @ to refer to the current node in the document, array indexing, or recursive descent.

Now, we can put together a mapping template for our Player model. This template will just copy the input to the output with new names for field properties. In particular, it will convert an input document of
{
    "id": "AJamal",
    "alias": "Aha Jamal",
    "displayName": "Anwar Jamal Faiz",
    "profilePhotoUrl": "https://api.example.com/player/AJamal/avatar.png"
}
to an output document of
{
    "id": "AJamal",    "alias": "Aha Jamal",    "name": "Anwar Jamal Faiz",    "photo": "https://api.example.com/player/AJamal/avatar.png"}
The mapping to perform the above transformation is specified below, with some inline VTL comments added.
## Set the variable inputRoot to the root JSON document
#set($inputRoot = $input.path('$')) {

    ## Assign output properties to input properties
    "id": "$inputRoot.playerId",
    "alias": "$inputRoot.alias",
    "name": "$inputRoot.displayName",
    "photo": "$inputRoot.profilePhotoUrl"
}
Enjoy!!

Json schema validation for Api Gateway request

Amazon’s API Gateway provides the facilities to map an incoming request’s payload to match the required format of an integration backend. It uses the concept of “models” and “mapping templates” to specify the mapping between the client payload and the server payload.
A model defines the structure of the incoming payload using JSON Schema. The model is an optional, but not required, piece of API Gateway. By providing a model, you make it easier to define the upcoming mapping template that actually does the transformation between the client and server.
For example, we can define a incoming Player model using the following JSON payload.
{
    "id": "AJamal",
    "alias": "Aha Jamal",
    "displayName": "Anwar jamal Faiz",
    "photoUrl": "https://api.example.com/player/AJamal/avatar.png"
}


JSON Schema is a vocabulary allowing you validate JSON documents. The particular JSON payload being validated is called an instance, and the document describing what a valid payload looks like is called the schema.
JSON Schema is used to describe a JSON document, so it helps to understand what, exactly, a JSON document is composed of these primitives:
  • objects: {"field1": "value1", "field2": "value2"}
  • arrays: ["first", "second", "third"]
  • numbers: 42 or 3.1415926
  • strings: "Lorem ipsum dolor sit amet"
  • booleans: true or false
  • null: null
The responsibility of JSON Schema is to describe a JSON document built from the these primitives.
JSON Schema is itself specified using JSON with predefined semantics for keywords and values. Going back to our Player example, we can specify the JSON Schema for the incoming document as follows:
{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "id": { "type": "string" },
        "alias": { "type": "string" },
        "displayName": { "type": "string" },
        "photoUrl": { "type": "string" }
    }
}
This JSON Schema follows the Draft 4 specification and simply declares the types expected for each field in the request. 

For more details consult this guide.